Hi,
I am kind of new to R so I apologize if I don't give all the info that is need. I will keep and eye on this post and add any additional info that is requested. So I have two conditions in my dataset, fed and starved. The "fed" samples are my controls and the "starved" samples are my affected. So what I want to do is do a fed vs starved comparison and I have had great success so far with DESeq2. For whatever reason, DESeq2 wants me to do a starved vs fed comparison (this is likely to be something I am missing), which is a bit annoying. I have been able to fix the problem by doing the following
dds <- DESeq(dds)
res2 <- results(dds, contrast = c("condition","fed","starved"))
res2
log2 fold change (MLE): condition fed vs starved
Wald test p-value: condition fed vs starved
DataFrame with 13728 rows and 6 columns
baseMean log2FoldChange lfcSE stat
<numeric> <numeric> <numeric> <numeric>
FBgn0000008 193.7874 -0.2987684 0.2707192 -1.10361006
FBgn0000014 110.4600 -0.1016940 0.4402129 -0.23101088
FBgn0000015 164.1642 -0.1506553 0.3030172 -0.49718392
FBgn0000017 1111.0239 0.0169430 0.1874026 0.09040964
FBgn0000018 109.2123 -0.8891501 0.3812173 -2.33239674
So are you can see, the comparison is fed vs starved. If I were to run just the default this is what I get, which is not what I want.
dds <- DESeq(dds)
res <- results(dds)
res
log2 fold change (MLE): condition starved vs fed
Wald test p-value: condition starved vs fed
DataFrame with 13728 rows and 6 columns
baseMean log2FoldChange lfcSE stat
<numeric> <numeric> <numeric> <numeric>
FBgn0000008 193.7874 0.2987684 0.2707192 1.10361006
FBgn0000014 110.4600 0.1016940 0.4402129 0.23101088
FBgn0000015 164.1642 0.1506553 0.3030172 0.49718392
FBgn0000017 1111.0239 -0.0169430 0.1874026 -0.09040964
FBgn0000018 109.2123 0.8891501 0.3812173 2.33239674
So the issue I am having is when I go to make an MA-plot. So when I run the following, I have no issue. I get an MA-plot with the correct comparison fed vs starved.
plotMA(res2, ylim=c(-2,2))
There is a lot of data in the graph so I want to shrink it down. There is an option for that and this is where I start to run into my issue. So when I run the following command to get a list of coefficients, this is what I get
resultsNames(dds)
[1] "Intercept" "condition_starved_vs_fed"
So my little trick before will no longer work. To shrink the data I have to pick the correct coefficient for the following command to work
resLFC <- lfcShrink(dds, coef="condition_fed_vs_starved", type="apeglm")
I would like to make an MA-plot with the following command but I am unable to without the correct coefficient.
plotMA(resLFC, ylim=c(-2,2))
So my question is, how can I correct/add a coefficient so I am able to make this MA-plot? I know this is something I am doing wrong. I am just too new to R and DESeq2 to figure it out. Any help would be amazing!!
Thanks
Kevin! You're the man! Sorry for the late response, I was trying to get your second option to work. I really appreciate your response! I was able to get both of your options to work.
I had to play with what you wrote a bit. I had to run the following to get the data in the right order
This gave me the fed vs starved condition. When I ran what you wrote I kept getting the starved vs fed, which is okay! I just had to switch things around a tiny bit. Wouldn't have got here with out you! I really appreciate you well written response.
Okay, no worries.