Conditional modification of counts in the DESeq Data Set
1
0
Entering edit mode
7.2 years ago

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 • 2.1k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
7.2 years ago
James Ashmore ★ 3.5k

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
ADD COMMENT

Login before adding your answer.

Traffic: 1378 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