Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recovering all genes for subsets #168

Closed
notimenocall opened this issue Mar 10, 2020 · 4 comments
Closed

recovering all genes for subsets #168

notimenocall opened this issue Mar 10, 2020 · 4 comments

Comments

@notimenocall
Copy link

Hi,
Thanks for the great package!
I would like to perform scvelo on a subset. To do that, I clustered my data with highly variable genes and subset the cluster of interest. At this point, the vars only contain the hvgs, and so I usually do the following to recover all the genes for reclustering:
T_cells = adata[adata.obs.louvain.str.contains('T cells')] T_cells=sc.AnnData(T_cells.raw.X,obs=T_cells.obs,var=T_cells.raw.var)
However, this approach does not recover the 'layers' (spliced/unspliced). Is there an easy way to do this that I missed?
Thanks again!

@VolkerBergen
Copy link
Contributor

Why not just T_cells = adata[adata.obs.louvain.str.contains('T cells')].copy() without the second command. Or is there a reason for creating a new anndata?

@notimenocall
Copy link
Author

Thanks for your quick response!
Because the adata only contains hvg and I was trying to recover all the genes with the 2nd line from the T_cells.raw, so I can re-select hvg again just from the T cells cluster. However, this approach does not recover the 'layers' (spliced/unspliced).

@VolkerBergen
Copy link
Contributor

.raw has no layers, because it is only meant to store .X for DE testing, so the layers are not restorable anymore for all genes at this point. You would have to re-read the data and then subset to the T_cells. The pre-computed (on hvg) cluster annotations, embeddings etc. can then be load into the anndata object.

@notimenocall
Copy link
Author

Okay. It makes sense to me. I just want to make sure I didn't miss any magical function to could accomplish this. Thank you very much again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants