How to subset anndata by clusters and their gene markers?
1
0
Entering edit mode
2.2 years ago
Emily ▴ 70

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!

anndata python scanpy scrna scvi • 2.2k views
ADD COMMENT
1
Entering edit mode
2.2 years ago
zorbax ▴ 650

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.

ADD COMMENT

Login before adding your answer.

Traffic: 2184 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6