DESeq estimateSizeFactors() is returning error "Error: all(!is.na(value)) is not TRUE"
2
0
Entering edit mode
@abhishekyedugondla-14108
Last seen 7.2 years ago

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.

 

deseq2 error R estimatesizefactors zero • 6.3k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 5 days ago
United States

Can you try estimateSizeFactors(dds, type="poscount")?

This was implemented recently, although proposed a while ago on phyloseq/DESeq2 forums, and hopefully avoids users having to do their own estimation of the geometric means, etc.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

this is microbiome 16S data

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
fanli.gcb • 0
@fanligcb-10919
Last seen 7.0 years ago
Los Angeles, CA

Check to make sure all of the column sums of your count matrix are non-zero. I encountered this error and eventually figured out that it was due to a typo in my sample sheet (a misnamed sample ended up with all zero counts).

 

ADD COMMENT

Login before adding your answer.

Traffic: 538 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6