Hello,
Sorry if the title is not clear!
I have an anndata object:
adata
Out[10]:
AnnData object with n_obs × n_vars = 13779 × 36601
obs: 'doublet', 'doublet_score'
var: 'gene_ids', 'feature_types'
I used DoubletDetection package to detect dublets in my reads matrix after creating the Anndata object immediately (before filtering or qc), and added the results to .obs like this:
import doubletdetection
clf = doubletdetection.BoostClassifier()
doublets = clf.fit(adata.X).predict()
adata.obs['doublet'] = doublets
doublet_score = clf.doublet_score()
adata.obs['doublet_score'] = doublet_score
After detecting doublets it gives result as “0” for not a doublet and “1” for a doublet.
adata.obs['doublet'].value_counts()
Out[3]:
0.0 12697
1.0 1074
Name: doublet, dtype: int64
What I want to do is remove all cells that have doublet value of “1” before continuing the rest of the analsysis, what I’ve tried to do is:
adata= adata[adata.obs["doublet"].isin[('0')],:]
or
adata= adata[~adata.obs["doublet"].isin[('1')],:]
However, it does not remove doublets but either removes all cells or keep all cells
Out[38]:
View of AnnData object with n_obs × n_vars = 0 × 36601
obs: 'doublet', 'doublet_score'
var: 'gene_ids', 'feature_types'
Out[42]:
View of AnnData object with n_obs × n_vars = 13779 × 36601
obs: 'doublet', 'doublet_score'
var: 'gene_ids', 'feature_types'
How can I filter those cells? Is there a manual way like extracting the matrix with doublets data as a csv and deleting cells, then reading again?
Thanks in advance…