So upstream seems to be working well, I have run into an issue where the estimatesizefactors is returning a strange error. Input is:
dds <- dds[ rowSums(counts(dds)) > 1, ] cts <- counts(dds) geoMeans <- apply(cts, 1, function(row) if (all(row == 0)) 0 else exp(mean(log(row[row != 0])))) dds <- estimateSizeFactors(dds, geoMeans=geoMeans)
This returns the error
> Error: all(!is.na(value)) is not TRUE
This results in a downstream error of:
>estimating size factors
Error in estimateSizeFactorsForMatrix(counts(object), locfunc = locfunc, :
every gene contains at least one zero, cannot compute log geometric means
Ran the following to troubleshoot:
traceback() table(rowSums(counts(dds) == 0 )) table(colSums(counts(dds) == 0))
Resulted in :
> traceback()
6: stop("every gene contains at least one zero, cannot compute log geometric means")
5: estimateSizeFactorsForMatrix(counts(object), locfunc = locfunc,
geoMeans = geoMeans, controlGenes = controlGenes)
4: .local(object, ...)
3: estimateSizeFactors(object)
2: estimateSizeFactors(object)
1: rlogTransformation(dds)
> table(rowSums(counts(dds) == 0 ))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
10933 926 705 560 488 450 417 396 384 402 419 419 467 469 534
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
582 723 908 799 567 622 539 588 546 550 651 646 702 727 833
31 32 33 34 35
713 348 94 7 1
> table(colSums(counts(dds) == 0))
6372 6503 6575 6699 6757 6847 6923 6994 7005 7009 7024 7105 7203 7307 7377
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
8246 8280 8447 8557 8804 8907 9655 9783 10338 10345 10358 10485 10504 10524 10606
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
10699 10700 11427 11544 11580 29115
1 1 1 1 1 1
Don't See any zero numbers in the tables so I am unsure as to what is causing this error. The fix of removing all values less than 1 should have fixed it no? Please advise.
Hi,
I got this error, and tried estimateSizeFactors(dds, type="poscount"), but that error is still there. If I add 1 to each cell of the count table, the error is gone. Is it valid to just add 1?
Thanks! Leran
I wouldn’t add one. If you have no genes without 0s, it may indicate you should be using a different scaling factor procedure. Is this single cell or microbiome?
this is microbiome 16S data
I don't think DESeq2 is appropriate for microbiome (there are a couple of threads on this).
If the size factor doesn't work, neither will the downstream steps.
Thanks Michael, I double checked and found that there are 4 samples are with 0 taxa. When I remove them, the software works fine!
Leran