enter image description hereenter image description here enter image description here
Hello. I am a beginner who is studying scanpy. I'm trying to subset from multiple obs in scanpy.
I can subset clusters in one obs. However, I want to subset clusters of 'pEMT' and 'Oxphos' among 'obs' at the same time as one adata.
Is there a way?
The image shows that 'pEMT' and 'Oxphos' are columns in the obs dataframe.
If you are subsetting the adata object based on pMET as
adata[adata.obs['pMET']==somevalue]
and subsetting based on Oxphos asadata[adata.obs['Oxphos']==somevalue]
you can "and" the conditions as this to subset based on the both of the columns:adata[(adata.obs['pMET']==somevalue) & (adata.obs['Oxphos']==somevalue)]
Note that
adata.obs['somecolumn']==somevalue
returns a Series object of booleans. You can do element-wise boolean arithemtic on these, for example you can use & (and), | (or), ~ (not) operators.