plger / scDblFinder

Methods for detecting doublets in single-cell sequencing data
https://plger.github.io/scDblFinder/
GNU General Public License v3.0
162 stars 17 forks source link

How can I add results to back my original file #98

Closed karabicicim closed 8 months ago

karabicicim commented 8 months ago

Hi, I would like to thank you for this great toll. I successfully find doublets. However, I am not sure how can ı add this doublet information back to my Seurat object to remove doublets.

My code line:

library(scDblFinder)
sce_fibro <- as.SingleCellExperiment(fibro)
dblt <- findDoubletClusters(sce_fibro, sce_fibro$SCT_snn_res.0.1)

set.seed(3435)
sce.dbl_h <- scDblFinder(sce_fibro, clusters="SCT_snn_res.0.1")
 table(sce.dbl_h$scDblFinder.class, sce.dbl_h$SCT_snn_res.0.1)

and ı obtain : 0 1 2 3 4 singlet 607 581 439 268 82 doublet 17 28 21 15 18

So I would like to remove doublets from my initial fibro seurat object. I attempt to load sce.dbl_h$scDblFinder.class data to fibro but I dind't find a good approach for it.

Could anyone guide me please how should ı remove doublets after I discovered them?

Thank you!

plger commented 8 months ago

You're running 2 methods.

findDoubletClusters gives infos about each cluster, in case some of them are entirely composed of doublets. You can use that info to remove entire clusters if you want to. Most often, though, doublets do not form their own clusters (because doublet so the same type are, and they're often an unequal mixture of two cell types).

scDblFinder assigns each cell the probability of being a doublet. The documentation indicate how to put that info back into a Seurat object. If you want to filter them out you can simply do:

fibro <- fibro[,which(sce.dbl_h$scDblFinder.class=="singlet")]
karabicicim commented 8 months ago

Dear plger,

Thank you for your kind answer. It is perfectly works for me!

Best,