This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Conditional modification of counts in the DESeq Data Set

Hi All,

I know it should be simple but I am really struggling. I want to change zeros to 1s. Here is what I tried so far:

> dds[ counts(dds)[counts(dds) == "0"] <- 1]
Error in validObject(object) : 
  invalid class "DESeqDataSet" object: the count data is not in integer mode
>
> dds[ revalue(as.factor(counts(dds))), c("0"="1") ]
Error: cannot subset by character when rownames are NULL

The count data is in fact integer, so I don't know why the first option fails. For the second, the syntax doesn't seem correct, but it is somehow beyond me to get it right...

deseq2

I think this is very important to not hack the data. Genes or transcripts not having any expression is fine. Also if the library quality is poor you might end up with not having mRNA abundances for few genes. The best is to check the house keeping genes if they are in line or not or you have ERCC spike-ins you can check them to understand the library quality unless the FASTQC report is not that informative. But simply pushing 0 counts to 1 is not correct. If you want to select for DE with genes above a certain threshold then that is a different thing. But why do you intend to replace all 0 values to 1. This will change the distribution of your genes across samples and also across conditions.

Yes, I couldn't agree more. I needed that only to prove something...

1 answer

I'm not sure why you'd want to replace zero values, but you can do it this way:

assay(dds)[assay(dds) == 0] <- 1

Log in to answer this question.