This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2 Pre-filtering and Subsetting

I have a dds object in DEseq2 and I wanted to do row means filtering on my object. I have 30 total samples, therefore I have 30 total columns in the count table. I'd like to filter all read counts lower than 30 for each treatment (for rows 1-15 and rows 16-30). I've tried the following code:

keep = rowMeans(counts(dds[,c(1:15,16:30)])) >=30
dds_30=dds[keep,]

but I do not think this is working. Would anybody be able to help?

rna-seq r

1 answer

I'm not sure what your dds variable looks like, but this should work judging by your current code.

dds_30 <- dds[rowMeans(counts(dds)[, 1:15]) >= 30 & rowMeans(counts(dds)[, 16:30]) >= 30, ]

Thanks but I wanted to filter the row means by treatment (only filtering out those with row means less than 30 between samples 1 - 15 and 16-30, separately). Would I just do:

dds_30 <- dds[rowMeans(counts(dds)[, 1:15;16:30]) >= 30, ]

In your original post, you had c(1:15,16:30), which is the same as 1:30.

I'm still a bit confused what you are trying to do. Can you describe it in a little more detail?

My apologies. My dds variable is two plant genotypes over a period of time and each sample 1 - 30 in my dds object belongs to a genotype. Columns 1 - 15 belong to one genotype (Three replicates for 5 time points) and columns 16 - 30 belong to another. What I would like to do is row means filter by treatment (remove all row means less than 30 for samples 1-15 even though they might be = 45 in samples 16 - 30, and vice versa). That way I would only get row means in the DDS object that are >=30 when you subset rows 1 - 15 and rows 16 - 30. I know it's more complicated than is usual in DEseq2 and might be advised against but our lab uses a specific protocol in DEseq. Thanks for your help.

I think I know what you mean now. Both the row means of columns 1:15, and the row means of columns 16:30 need to be equal to or greater than 30 to keep the row. I edited the answer to reflect this.

Log in to answer this question.