MarioniLab / DropletUtils

Clone of the Bioconductor repository for the DropletUtils package.
https://bioconductor.org/packages/devel/bioc/html/DropletUtils.html
54 stars 25 forks source link

Cannot convert to Seurat object #73

Closed dahun73 closed 2 years ago

dahun73 commented 3 years ago

Hello !!

I just tried using DropletUtils to eliminate empty cells. In my sample, after eliminating empty cell, there are large number of cells(I remember almost 80k cells).

However, I could not convert to Seurat object because of large scale of this sample. In this situation, how can I keep analyzing this data? I heard that one suggestion is down sampling. But I want to process all these cells.

my second question is... why filtered cell number using cellranger is completely different with using DropletUtils? After filtering using cellranger, filtered cell number is 7k.

Here is my codes:

rownames(sce) = uniquifyFeatureNames(rowData(sce)$ID, rowData(sce)$Symbol)
colnames(sce) = sce$Barcode

my.counts=counts(sce)
br.out <- barcodeRanks(my.counts)

plot(br.out$rank, br.out$total, log="xy", xlab="Rank", ylab="Total")
o <- order(br.out$rank)
lines(br.out$rank[o], br.out$fitted[o], col="red")

abline(h=metadata(br.out)$knee, col="dodgerblue", lty=2)
abline(h=metadata(br.out)$inflection, col="forestgreen", lty=2)
legend("bottomleft", lty=2, col=c("dodgerblue", "forestgreen"), 
       legend=c("knee", "inflection"))

set.seed(100)
e.out <- emptyDrops(my.counts)

is.cell <- e.out$FDR <= 0.001
sum(is.cell, na.rm=TRUE)

is.cell[is.na(is.cell)] <- FALSE

names(is.cell) <- colnames(sce)
sce$cells_kept <- is.cell

sce <- sce[, sce$cells_kept == T]
sce
###class: SingleCellExperiment 
dim: 32285 81756 
metadata(1): Samples
assays(1): counts
rownames(32285): Xkr4 Gm1992 ... AC234645.1 AC149090.1
rowData names(3): ID Symbol Type
colnames(81756): AAACCCAAGAACAGGA-1 AAACCCAAGATTACCC-1 ...
  TTTGTTGTCTGGTTGA-1 TTTGTTGTCTTTACAC-1
colData names(3): Sample Barcode cells_kept
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
###

logcounts(sce) <- log2(counts(sce) + 1)

Error in asMethod(object) : 
  Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102

Thank you in advance

Dahun

LTLA commented 3 years ago

In this situation, how can I keep analyzing this data? I heard that one suggestion is down sampling. But I want to process all these cells.

I don't really know what the problem is with the Seurat converter - that's outside of my purview - but downstream analyses with 80k cells is not too difficult, see the OSCA book.

my second question is... why filtered cell number using cellranger is completely different with using DropletUtils?

Hard to say. Maybe your experiment has poor differentiation between ambient RNA and cell-containing droplets, so the different decisions made by the two implementations have a large effect on the results. You could follow the discussion in #66 regarding the CellRanger variant of emptyDrops.

dahun73 commented 2 years ago

@LTLA

I'm sorry for late responding. Thank you for kind reply :)