# Problems subsetting

**URL:** <https://discourse.scverse.org/t/problems-subsetting/1268>\
**Category:** scanpy\
**Created:** [March 27, 2023, 9:05pm UTC](https://discourse.scverse.org/t/problems-subsetting/1268 "2023-03-27T21:05:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReneVQ](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/renevq/32/602_2.png) [@ReneVQ](https://discourse.scverse.org/u/ReneVQ)\
**Post date:** [March 27, 2023, 9:05pm UTC](https://discourse.scverse.org/t/problems-subsetting/1268/1 "2023-03-27T21:05:35Z")

</div>

Hi, I’m new to scanpy. I’ve had a pretty good go of it, running in RStudio, but I’ve run into an issue trying to subset a cluster in my dataset. I’m doing Inner ear scRNA seq, and want to look at differences in my IHC cluster. However, when I input the code:

adata\_subset = adata[adata.obs[“leiden”] == “IHC”]

I get the error message:

AttributeError: ‘AnnData’ object has no attribute ‘\_X’

Looking at my anndata object, it returns:  
AnnData object with n\_obs × n\_vars = 1600 × 20182  
obs: ‘orig.ident’, ‘nCount\_RNA’, ‘nFeature\_RNA’, ‘percent.mt’, ‘percent\_Rp.sl.’, ‘percent\_Hblist’, ‘RNA\_snn\_res.1.2’, ‘seurat\_clusters’, ‘RNA\_snn\_res.0.8’, ‘RNA\_snn\_res.0.4’, ‘n\_genes\_by\_counts’, ‘total\_counts’, ‘total\_counts\_mt’, ‘pct\_counts\_mt’, ‘leiden’, ‘dpt\_pseudotime’, ‘distance’, ‘louvain’  
var: ‘vst.mean’, ‘vst.variance’, ‘vst.variance.expected’, ‘vst.variance.standardized’, ‘vst.variable’, ‘highly\_variable’, ‘means’, ‘dispersions’, ‘dispersions\_norm’, ‘mt’, ‘n\_cells\_by\_counts’, ‘mean\_counts’, ‘pct\_dropout\_by\_counts’, ‘total\_counts’  
uns: ‘dendrogram\_leiden’, ‘diffmap\_evals’, ‘hvg’, ‘iroot’, ‘leiden’, ‘leiden\_colors’, ‘leiden\_sizes’, ‘neighbors’, ‘paga’, ‘pca’, ‘umap’, ‘rank\_genes\_groups’, ‘louvain’, ‘louvain\_colors’  
obsm: ‘X\_diffmap’, ‘X\_pca’, ‘X\_tsne’, ‘X\_umap’  
varm: ‘PCs’  
obsp: ‘connectivities’, ‘distances’

So ‘leiden’ IS in .obs, but for some reason it won’t give me the subset I need. Any help would be appreciated.

Additionally, how would I go about separating the IHCs based on TdTomato expression to compare transcriptomes?

Thanks
