satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

HTODemux error "Cells with zero counts exist as a cluster" #2549

Closed NaCo-Pt closed 4 years ago

NaCo-Pt commented 4 years ago

Dear community

I have simular problems as in issue #1273. This was closed in April by satijalab with the comment "These are good ideas and we will explore." and I would like to reopen the discussion.

I'm testing HTOdemux on my dataset of 4 samples (3'RNAseq V3 10x). In each sample we mixed material coming from 5 different mice tagged with an HTO.

I followed the Demultiplexing with hashtag oligos (HTOs) vignette (https://satijalab.org/seurat/v3.1/hashing_vignette.html) dealing with each sample (5HTOs) at a time.

when I try to demultiplex tp3ctr.hashtag <- HTODemux(tp3ctr.hashtag, assay = "HTO", positive.quantile = 0.99)

I get the error: Error in HTODemux(tp3ctr.hashtag, assay = "HTO", positive.quantile = 0.99) : Cells with zero counts exist as a cluster.

I tried different quantile and different init parameters, same result. As in issue #1273 my data looks different from the one in the tutorial

**tp3ctr.hashtag@assays$HTO@counts[,c(1:10,166:176)] 6 x 21 sparse Matrix of class "dgCMatrix" [[ suppressing 21 column names ‘AGGGATGGTGAGTATA’, ‘CCTTCCCAGCCCAACC’, ‘GTTCATTGTCCTCTTG’ ... ]]

sampleA-ACCCACCAGTAAGAC . . . . . . . . . . . . . . . . . . . . . sampleB-GGTCGAGAGCATTCA . . . . . . . . . . . . . . . . . . . . . sampleC-CTTGCCGCATGTCAT . . . . . . . . . . . . . . . . . . . . . sampleD-AAAGCATTCTTCACG . . . . . . . . . . . . . . . . . . . . . sampleE-CTTTGTCTTTGTGAG . . . . . . . . . . . . . . . . . . . . . unmapped . . . . . . . . . . . . . . . . . . . 5 .**

And I get the same error if I exclude the "unmapped" row. I also tried MULTIseqDemux() as suggested by satijalab, but I get a different error: Error in model(x) : could not find function "model" Did someone already solved this problem before, could you help? what is recommended to do by the developers? Best wishes

McStber commented 4 years ago

Hi,

I got the same error with my dataset and would be also very interested for any recommendations!!

Best regards, Michael

tbukur commented 4 years ago

Hi, I realized that running CITESeq with the whitelist provided by 10XGenomics results in a table of 737k columns where most of the values are zeroes. Try removing all cell barcodes with zero counts before demultiplexing. That helped in my case. Cheers Thomas

DanielWendisch commented 4 years ago

Hi, also try removing other HTO's that might have not worked. And don't forget to normalize afterwards: NormalizeData(x, normalization.method = "CLR"

Best, Daniel

Acctually now I see that you selected a
6 x 21 sparse Matrix of class "dgCMatrix". 21 cells are quite few... -> Did you select columns instead of rows? Try this(comma!):

tp3ctr.hashtag@assays$HTO@counts[c(1:10,166:176,)]

satijalab commented 4 years ago

The underlying issue is that we cannot demultiplex cells that have no HTO counts (there's no information to demultiplex). Please remove these cells prior to creating the analysis. You should also remove any HTOs that have 0 counts for all cells.

joeytai2010 commented 4 years ago

I found the same problem. How to remove HTOs that have 0 counts?

AlexandrePelletier commented 4 years ago

same problem here, even if I remove all cells with 0 HTO counts, and HTO with too few count i have the same error. after filtering my matrix is 2 HTO * 2417 cells). I tried also to keep only cells with >2 or 5 count, but same issue

Interestingly, when I keep the "unmapped" row of my HTO matrix, the HTODemux() works well. Any Idea why ?

DanielWendisch commented 4 years ago

Did you do CLR-Normalization afterwards?

AlexandrePelletier commented 4 years ago

Yes, I do

joschif commented 3 years ago

I am seeing the same error after filtering out 0 counts and doing CLR-Normalization.

shannjiang commented 3 years ago

I am seeing the same error after filtering out 0 counts and doing CLR-Normalization.

I am seeing the same error after filtering out 0 counts and doing CLR-Normalization. Did you finally resolve it @astair

sirusb commented 3 years ago

I think that this line : https://github.com/satijalab/seurat/blob/b56d194939379460db23380426d3896b54d91ab6/R/preprocessing.R#L366-L368 Should be changed to :

if ( sum(colSums(average.expression) == 0) > 0) {
    stop("Cells with zero counts exist as a cluster.")
  }
majorkazer commented 3 years ago

I am getting this error now using Seurat 4.0.0. I have also filtered out any cells with 0 HTO counts.

yurasong commented 3 years ago

Same here. I am using latest Seurat version and returns same error even I managed the CLR normalization.

Meggie-MH commented 3 years ago

got the same error

Meggie-MH commented 3 years ago

I think that this line : https://github.com/satijalab/seurat/blob/b56d194939379460db23380426d3896b54d91ab6/R/preprocessing.R#L366-L368

Should be changed to :

if ( sum(colSums(average.expression) == 0) > 0) {
    stop("Cells with zero counts exist as a cluster.")
  }

Thank you for providing the possible solution. I tried this and got an error message:

Error in fitdist(data = values.use, distr = "nbinom") : data must be a numeric vector of length greater than 1 Called from: fitdist(data = values.use, distr = "nbinom") Error during wrapup: unimplemented type (29) in 'eval'

royfrancis commented 3 years ago

Even if it is not zero, having too few counts causes fitdist() inside HTODemux() to fail. In my case, I checked rowSums(hto) and one of my samples had only 2 antibody counts.

TS_A_0301 TS_A_0302 TS_A_0303 TS_A_0304 TS_A_0305 TS_A_0306 
    45641    116515     81441    376322      9301         2 

Removing this sample fixed the error.

moutazhelal commented 2 years ago

Hi @royfrancis , I ran to the same error and I discover that I choose raw_feature_bc_matrix files instead of filtered_feature_bc_matrix as input to my Read10X. I changed the file directory and it worked. I hope it works for you too.

Best, Moutaz