Can't change anndata dimensions


I clustered some cells using the top 3000 genes with the highest variance, removed some cell types I am not interested in and now I want to cluster them again using a new set of top variable genes.

My object has 78016 obs and 3000 vars. However, all genes are still there in adata.raw.X. Because I want to select these new genes, I have tried using adata2.X=adata2.raw.X. This returns the message ValueError: Data matrix has wrong shape (78016, 22633), need to be (78016, 3000).

Anyway to overcome this?