How to subset anndata by clusters and their gene markers?
Hello, I want to subset anndata on basis of each cluster and their gene id/marker but having trouble executing it. Not sure how I can subset .obs, since the cluster information is stored in observation, which subsequently subsets corresponding ...
I tried using adata_dub_gene_6 = adata[adata.obs["leiden"] == "6"].var which was no different from doing just adata.var which outputs all the genes (metadata) of the anndata.
Thank you!
• 3,801 views
•
link
1 answer
You can define a subset with adata_dub_gene_6 = adata[adata.obs['leiden'].isin('6')], you should treat your obs like a Pandas DataFrame.
With isin(['5', '6']) you can select a list of values and retrieve it from adata.
• 0 views
•
link
Log in to answer this question.