Exporting DEGs obtained from DESeq2
1
0
Entering edit mode
13 months ago
camillab. ▴ 160

Hi,

I am not sure if my "action" is against the rules of biostar, and if so, please cancel my post.

My question has been discussed on bioconductor but I have realized that I may not get an an answer so I decided to open a new question and ask it here. Again, if this is against the rule, I apologies and please feel free to cancel my post.

I am doing Deseq2 on 6 samples (control vs treatment):

dds <- DESeqDataSetFromTximport(txi, sampleTable, design = ~condition)
dds <- dds[rowSums(counts(dds)) >= 10,]
dds$condition <- relevel(dds$condition, ref = "Control")
dds <- DESeq(dds)

and I got the DEGs (FDR < 0.05 and FC +/- 1.5, getting 193 up and 158down regulated genes respectively) using this code:

cond1 <- results(dds, contrast=c("condition","Treatment","Control"), alpha = 0.05, lfcThreshold = 0.585)
summary(cond1)

and I get:

out of 22695 with nonzero total read count
adjusted p-value < 0.05
LFC > 0.58 (up)    : 193, 0.85%
LFC < -0.58 (down) : 158, 0.7%
outliers [1]       : 21, 0.093%
low counts [2]     : 1760, 7.8%
(mean count < 3)
[1] see 'cooksCutoff' argument of ?results
[2] see 'independentFiltering' argument of ?results

But I cannot export an excel/csv file with ONLY those genes. Indeed, I get basically the whole dataset (> 21000 genes - I don't know the exact number).

However when I try to export it write.csv(cond1, file="test.csv")

I got the whole dataset (22695 rows). On the note following the bioconductor post, if I do:

sum(cond1$padj < 0.05 & cond1$log2FoldChange > 0.585, na.rm=TRUE)
sum(cond1$padj < 0.05 & cond1$log2FoldChange < -0.585, na.rm=TRUE)

I have concordance between the summary table and these sums.

I have also trying to remove NA doing:

resFilt <- subset(cond1, !is.na(padj < 0.05))

and I get 20915 genes (so less than before but still way too many that my DEG). What am I doing wrong in exporting the file?

Thank you!

Camilla

R Deseq2 • 1.1k views
ADD COMMENT
0
Entering edit mode

What does dim(as.data.frame(cond1)) give you?

ADD REPLY
0
Entering edit mode

It's a large DESeqResults. I got the same results even doing it write.csv(as.data.frame(cond1), file="Detst.csv").

the dimension is [1] 22695 6

ADD REPLY
0
Entering edit mode

You can separate up and down regulated results like this, save then in table and merge them later.

cond1_upregulated = cond1[cond1$padj < 0.05 & cond1$log2FoldChange > 0.585 ,]
cond1_downregulated = cond1[cond1$padj < 0.05 & cond1$log2FoldChange  <   -0.585 ,]
ADD REPLY
0
Entering edit mode

Thanks, I tried but it says Error: logical subscript contains NAs . and if I try:

tes <- na.omit(cond1)

and then run your code substituting cond1 with tes I got : Error: subscript is a logical vector with out-of-bounds TRUE values

ADD REPLY
3
Entering edit mode
13 months ago
bk11 ★ 3.0k

Try this then-

 up <- cond1[which(cond1$log2FoldChange > 0.585 & cond1$padj < 0.05),]
 down <-cond1[which(cond1$log2FoldChange < -0.585 & cond1$padj < 0.05),]
ADD COMMENT
0
Entering edit mode

yes! it worked! THANK YOU VERY MUCH!

ADD REPLY

Login before adding your answer.

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