Determining direction of logFC in limma
Entering edit mode
pt2395 • 0
Last seen 8.0 years ago
United States

I'm sure this is an easy question, but I'm fairly new to using limma and R and I'd appreciate any help or guidance. I've run a paired limma analysis trying to look at differentially expressed genes in a pre-post experiment design. I'm trying to understand what direction my logFC values represent i.e. whether the gene is being up regulated or down regulated from pre to post or post to pre. My code is as follows: 


d<-read.table("expressionDataHFNIH5-7-14.txt", header=T, row.names=1)
names(d)<-gsub(".CEL", "", gsub("X", "", names(d)))
d<-round(d, 5)

write.table(d, file="filepath.txt", quote=F, sep='\t')

#create a design matrix
#congestion 1=pre and 2=post

design <- cbind(ID = c(1,1,2,2,7,7,8,8,9,9,10,10,11,11,14,14,16,16,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,33,33,34,34,35,35,36,36,37,37,39,39,40,40,41,41), Congestion=c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2))

Congestion<-factor(design[,2], levels=c("1","2"))

#create a design matrix

fit <- lmFit(e, design)
fit <- eBayes(fit)

topTable(fit, coef = "Congestion2", adjust = "fdr")

topt2<-topTable(fit, coef = "Congestion2", adjust.method = "fdr", n=Inf,"p")

Thank you! 



logFC limma • 3.1k views
Entering edit mode
Aaron Lun ★ 28k
Last seen 50 minutes ago
The city by the bay

Your Congestion2 coefficient represents the log-fold change of your "2" samples over your "1" samples (i.e., post over pre). When you drop this coefficient during your DE comparison, the reported log-fold change corresponds to the value of this coefficient. Thus, you can interpret positive values as being upregulated in the post condition compared to pre, and negative values as being downregulated.

Incidentally, if you ever get confused, it's always a good idea to look at the expression values to figure out what's going on. In this case, you can pick a couple of the top DE genes and have a look at the direction of change within each patient for those genes. This is also a good way to check that you've set up the design and contrasts correctly for more complicated experiments; it never hurts to be on the safe side.

Entering edit mode

Thank you! One more question for my understanding, is it post over pre because of the way in which I've ordered it in my levels and design matrix? So if I decided that I wanted to determine my log-fold change of my "1" samples over my "2" samples then I would need to interchange their order to derive that value? 

ah never mind you just answered it. Thank you so much for your help. 


Entering edit mode

Yeah, model.matrix will choose the first level as the "reference". You should be able to flip it around by setting levels=c("2","1") in the construction of the Congestion variable, in which case you should end up with Congestion1 as the relevant coefficient to drop for your DE testing.

Entering edit mode

Thank you so much! This was really helpful. 


Login before adding your answer.

Traffic: 624 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6