Hi all,
I am new to R but I am analyzing my RNA-Seq data with DESeq2. I managed to use plotCounts
to generate a plot for a gene with the smallest adjusted p-value (which.min(resTC$padj)
) by following the instruction.
However, I don't know how to make plots for other genes which also have small adjusted p-values. I tried both gene_id
and which(resTC$padj)<0.05
but they won't work (please see comment for my error messages)
This is the only plot that I can make:
Here is my data constuction:
sampleFiles <- grep("count",list.files(directory),value=TRUE)
condition <- factor(c(rep("control",2), rep("rapid",3), rep("slow",3),
rep("control",2), rep("rapid",3), rep("slow",3),
rep("control",2), rep("rapid",3), rep("slow",3)))
timepoints <- factor(c(rep("t1",8), rep("t2",8), rep("t3",8)))
sampleTable <- data.frame(condition = as.factor(condition),
timepoints = as.factor(timepoints))
d.deseq<-DESeqDataSetFromMatrix(countData = countdata,
colData = sampleTable,
design = ~condition+timepoints+condition:timepoints)
ddsTC$condition <- relevel(ddsTC$condition, ref="control")
ddsTC<-DESeq(d.deseq, test="LRT", reduced = ~ condition+timepoints)
resTC<-results(ddsTC, alpha = 0.05)
resTCOrdered <- resTC[order(resTC$padj),]
Here is how I make the plot. I only know how to use which.min(resTC$padj)
:
data<-plotCounts(ddsTC, which.min(resTC$padj),intgroup = c("timepoints","condition"), returnData = TRUE)
ggplot(data, mapping = aes(x=timepoints, y=count, color=condition, group=condition))+geom_point()+stat_smooth(se=F, method="loess")+scale_y_log10()
Hi Devon,
Thank you for your response. When tried
row.names(resTC)[which(resTC$padj)<0.05]
, R warned me thatError in which(resTC$padj) : argument to 'which' is not logical
.However, when I change the position of
<
and triedwhich(resTC$padj<0.05)]
, it worked.Also, I can use
which(resSig$hgnc_symbol=="SLC22A13")
to check specific genes. Thanks!Oops, you found my typo :P I see you figured it out, though :)