Question: R: How to convert log2FC (Fold Change) obtained by limma's topTable() function to FC
5
gravatar for komal.rathi
4.9 years ago by
komal.rathi3.4k
Children's Hospital of Philadelphia, Philadelphia, PA
komal.rathi3.4k wrote:

Hi everyone,

I have a microarray set of 26933 genes and 6 samples (3 controls and 3 mutants). I calculated differential expressed genes using limma's topTable() function. I got a result of this format:

> head(res.new)
             logFC   AveExpr         t      P.Value    adj.P.Val        B
17291881 -2.157936  9.021125 -41.49770 3.218440e-09 3.829474e-05 10.82552
17357688 -2.364349  7.160051 -41.15755 3.397181e-09 3.829474e-05 10.79753
17224251  1.820522 10.665778  37.01446 6.816679e-09 3.829474e-05 10.41426
17239845 -2.025497 10.054660 -35.87667 8.366167e-09 3.829474e-05 10.29350
17304523 -1.830077 10.117184 -35.36567 9.191590e-09 3.829474e-05 10.23680
17229782  2.716749  7.911040  35.24054 9.407763e-09 3.829474e-05 10.22267

The logFC values are log2(FC). How do I convert the values (positive and negative) to normal fold changes?

I tried this:

#take 2^(absolute(log2FoldChange))

> res.new$FC<-2^(abs(res.new$logFC)) 

#change the sign of FC according to log2FC

> res.new$FC<-ifelse(res.new$logFC<0,res.new$FC*(-1),res.new$FC*1) 

But I am not sure if I am correct. Please let me know.

Thanks!

limma toptable microarray R • 34k views
ADD COMMENTlink modified 2.9 years ago by Biostar ♦♦ 20 • written 4.9 years ago by komal.rathi3.4k
7
gravatar for Devon Ryan
4.9 years ago by
Devon Ryan88k
Freiburg, Germany
Devon Ryan88k wrote:

res.new$FC <- 2^res.new$logFC

Negative log2 fold-changes are just less than 1.

ADD COMMENTlink written 4.9 years ago by Devon Ryan88k
4
gravatar for scottwilliamrobinson
4.1 years ago by
United Kingdom
scottwilliamrobinson120 wrote:

Agree with Devon Ryan's conversion assuming limma's "LogFC" is actually log2(FC), but if I remember correctly it isn't. The value they give here is actually the difference of the means of the log2-transformed values, ie:

Actual log2(FC) = log2(mean(Group1/Group2))
Limma's "Log(FC)" = mean(log2(Group1)) - mean(log2(Group2))

These will give similar values but not the same (at least in the cases I have looked at). I think the rationale is that it is more appropriate since the statistical tests are being done on the log2-transformed data.

Probably also worth saying that if you are outputting a 'TopTable' for a continuous variable in your model then Log(FC) will actually be the beta coefficient.

ADD COMMENTlink written 4.1 years ago by scottwilliamrobinson120

I'm confused. I think you're right about Limma's calculation. It seems like Limma's "Log(FC)" is actual fold change just involved log2-transformed values. In this case, how can we get the normal fold change? And how can we set the cut off value for Limma's "Log(FC)" since Log(FC)=1 doesn't mean FC=2? 

Thanks!

ADD REPLYlink written 4.0 years ago by henryshm1220

It seems "Actual log2(FC) = log2(mean(Group1/Group2)) " should be "Actual log2(FC) = log2( mean(Group1)/mean(Group2) ) ". And you mean limma's logFC version is more rationale? Thank you. Generally, the expression value has been logged. 

ADD REPLYlink modified 3.1 years ago • written 3.1 years ago by Zhilong Jia1.4k

The way scottwilliamrobinson presented it is how limma/DESeq2/edgeR/everything else actually do it. For count data one uses a log2 link so that the opimization isn't constrained. So what you end up with are expected values on the log2-scale, which are then subtracted to produce logFC. Realistically speaking, the difference between actual logFC and what all of the tools will produce is minor unless there are outliers. In either case, 2^logFC is still a decent representation of the actual fold change.

ADD REPLYlink written 3.1 years ago by Devon Ryan88k
1
gravatar for summerela
4.6 years ago by
summerela90
United States
summerela90 wrote:

Here's a really easy to use function: http://svitsrv25.epfl.ch/R-doc/library/gtools/html/foldchange.html

ADD COMMENTlink written 4.6 years ago by summerela90
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 765 users visited in the last hour