How to plot MD plot in limma
1
0
Entering edit mode
thkapell ▴ 10
@tkapell-14647
Last seen 22 months ago
Helmholtz Center Munich, Germany

Hi all,

I have been having difficulties creating a MD plot for my dataset for quite some time. Could someone explain to me what exactly the input should be (R asks for two column dataframe, but what values should the columns be? I have the normalised, fitted data of all my contrasts in hand) and whether there is a specific argument to set up the differential colouring of DE and non-DE genes (or whether this is printed automatically based on the input data).

Thanks,

Theo

limma plotMD • 2.9k views
ADD COMMENT
0
Entering edit mode

Thank you for the link you provided. However, the case study analysed is a 2 factor x 3 level one. The challenge I have is that I am using a single factor design with 4 levels. I used the exactTest function for fitting a linear model as shown in the code below:

 

data<-read.delim("Study1_counttable.txt")

sample_info<-read.delim('Study1_columntable.txt')

data.dge<-DGEList(data)

counts.per.million<-cpm(data.dge$counts)

table(rowSums(counts.per.million>1)>=3)
keep.exprs<-rowSums(counts.per.million>1)>=3
table(keep.exprs)
data.dge.removed<-data.dge[keep.exprs,,keep.lib.sizes=F]

tmm<-calcNormFactors(data.dge.removed,method='TMM')
design<-model.matrix(~0+treatment)         
rownames(design)<-colnames(tmm)
colnames(design)<-levels(sample_info_ordered$condition)

y<-estimateDisp(tmm) 
y$common.dispersion
plotBCV(y)

et<-exactTest(y)

plotMD(et, values=c(1,-1), col=c("red","blue"))

ADD REPLY
0
Entering edit mode

There are problems with your DE code here. You seem to be mixing up some code from the edgeR glm pipeline and some code from the edgeR classic pipeline in a way that doesn't go together. exactTest() assumes that you have set the group membership as part of the DGEList, but your code doesn't do that. On the other hand, exactTest() doesn't make any use of design matrices, so there is no purpose in creating one.

If you ran the code you give here, you would certainly get an error message from exactTest().

ADD REPLY
2
Entering edit mode
@gordon-smyth
Last seen 1 hour ago
WEHI, Melbourne, Australia

All your questions would be answered by help("plotMD.DGEList") or help("plotMD").

It's hard to understand what the difficulty could be, since you simply use plotMD(fit). In what way have you been having difficulties? Have you actually tried the plotMD function, or is it simply a matter of not knowing what function to use? If the former, then show us what code you tried that lead to difficulties.

Have you looked at the example case studies that use plotMD, like this one:

   https://f1000research.com/articles/5-1438

Your reference to a "two column data.frame" seems strange to me, because there is no documentation for an MD plot anywhere in R that calls for a two column data.frame. My only guess is that perhaps you have read the plotMA help page in geneplotter by mistake, but even that calls for a three column data.frame.

Later

In your second post you have now given the code you are using. I still don't see what the "challenge" is however. You seem to have been able to make an MD plot without any problems. There is no difficulty at all with your experimental design, in fact it's even simpler than the F1000Research example. You could BTW have simply used

plotMD(et)

which is even simpler than what you have, and would give the same plot. Did you try this?

As you can see, plotMD does color the DE genes automatically, and you obviously know how to change the colours yourself anyway. Of course, if there aren't actually any DE genes, then nothing will be highlighted.

So I ask again, what is the problem?

 

ADD COMMENT
0
Entering edit mode

Thank you, I got this now. The problem was in the exactTest function and not in the plotMD. I do print the plots right now.

ADD REPLY

Login before adding your answer.

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