This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2 cannot compute log geometric means

Hi,

Could anyone please suggest how can get rid of the below error in DESeq2 analysis?

 library('DESeq2')
    countMatrix = read.table("Count.txt",header=T,sep='\t',check.names=F)
    dim(countMatrix)
    colData <- read.table("metadata.txt", check.names=F)
    rownames(colData)
    dim(colData)
    colnames(countMatrix)
    all(rownames(colData) %in% colnames(countMatrix))
    count <- countMatrix[,-1] 
    rownames(count) <- countMatrix[,1]
    rownames(count) 

all(rownames(colData) %in% colnames(count))

all(rownames(colData) == colnames(count))

count <- count[, rownames(colData)]
all(rownames(colData) == colnames(count))

dds <- DESeqDataSetFromMatrix(countData=count,colData=colData,design=~Season)
keep <- rowSums(counts(dds)) >= 10
dds <- dds[keep,]
dds <- DESeq(dds, test="Wald")
estimating size factors
Error in estimateSizeFactorsForMatrix(counts(object), locfunc = locfunc,  :
  every gene contains at least one zero, cannot compute log geometric means

Thanks

deseq2 rna-seq r

1 answer

check this: link

Thanks, but I am not sure how to add pseudocount 1 to count data and then how I should proceed further? after estimating the size factor should I use the wald test command?

add a pseudo-count value of '1' to your data
 estimateSizeFactors(dds, type = 'iterate')
dds <- DESeq(dds, test="Wald")

Thanks

Before doing that, did you check if your count matrix has one or more samples with all 0 values? Is so, simply run:

dds<-estimateSizeFactors(dds, type = 'iterate')
dds <- DESeq(dds, test="Wald")

I checked samples count with below command shows that no samples with all 0.

    > all.zero <- apply(count, 2, function(x) all(x==0))
    > all.zero
        PN0086D.1.S1     PN0086D.2.S2     PN0086D.3.S3     PN0086D.4.S4
               FALSE            FALSE            FALSE            FALSE
        PN0086D.5.S5     PN0086D.6.S6     PN0086D.7.S7     PN0086D.8.S8
               FALSE            FALSE  

Should I now used the further command like this?
dds<-estimateSizeFactors(dds, type = 'iterate')
dds <- estimateDispersions(dds)
dds <- nbinomWaldTest(dds)

Many thanks

Just use:

dds<-estimateSizeFactors(dds, type = 'iterate')
dds <- DESeq(dds, test="Wald")

Log in to answer this question.