chris-mcginnis-ucsf / DoubletFinder

R package for detecting doublets in single-cell RNA sequencing data
414 stars 109 forks source link

Error seu@assays$RNA$counts : $ operator not defined for this S4 class. for doubletFinder( ) #207

Open chingyaousf opened 5 months ago

chingyaousf commented 5 months ago

Error seu@assays$RNA$counts : $ operator not defined for this S4 class. If the issue of compatibility since I couldn't upgrade Seurat package to ‘5.1.0’ in the server which has no issue of running?

packageVersion("DoubletFinder") [1] ‘2.0.4’ packageVersion("Seurat") [1] ‘4.3.0.1’

Find doublets using DoubletFinder

suppressMessages(require(DoubletFinder)) nExp <- round(ncol(seurat_object) * 0.04) # expect 4% doublets seurat_object <- doubletFinder(seurat_object, pN = 0.25, pK = 0.09, nExp = nExp, PCs = 1:10) Error in seu@assays$RNA$counts : $ operator not defined for this S4 class

Hui-XiangZhang commented 5 months ago

I have the same question when using Seurat 4.3 . Who can sovle this?

chingyaousf commented 5 months ago

I attempted to solve this issue and it appears to have worked. For detailed instructions, please check the following link: [Fix for DoubletFinder Error in seu@assays$RNA$counts Operator Not Defined for this S4 Class] https://github.com/chingyaousf/fix--doubletFinder-Error-in-seu-assays-RNA-counts-operator-not-defined-for-this-S4-class

ricardo-aaron commented 5 months ago

Yes, changing seu@assays$RNA$counts to seu@assays$RNA@counts in doubletFinder.R AND paramSweep.R and reinstalling DoubletFinder works.

02-i-need-healing commented 2 months ago

Agreee with ricardo-aaron, it works!

I have modified the corresponding code and compressed it into a zip file. You can save it to your folder and use the following command to install and load it:

remotes::install_local("your path/DoubletFinder.zip")

DoubletFinder.zip