Obtaining p-value and fold-change from a table
2
0
Entering edit mode
2.2 years ago
Yoosef ▴ 60

Hello I have analyzed my microarray data using R language , and my final data including p-value and fold change is ready. I am used to save the data as an excel file to sort my data. However, this time I want to try to obtain these data using R. How can I obtain data from this table with the following conditions:

  1. p-value < 0.05
  2. logfc >1.2 or <-1.2

Also, I was wondering to know what is the difference between p-value and adjusted p-value in expression studies results?

R limma microarray • 1.7k views
ADD COMMENT
3
Entering edit mode
2.2 years ago

df <- df[df$p < 0.05 & abs(df$logfc) > 1.2,]

Adjust as necessary for your code/object. Google "subsetting a dataframe in R" for more information. Note that post-hoc filtering like this renders your p-values meaningless and is best avoided where possible. It's better to alter your testing threshold to include the effect size such that the null hypothesis is changed to incorporate it.

As for your second question, this primer on multiple testing correction may help.

ADD COMMENT
0
Entering edit mode

Thanks for your help. Should I add the other rule with &? I mean log fc Higher than 1.2 or lower that -1.2. How should I say this? Also, I found an instruction which used "topTable" from limma package. The point is that I should define an 'Absolut fold change' to it. What is Absolut fold change?

ADD REPLY
1
Entering edit mode

My command already has both cases for fold change covered, as it uses the abs() function to get the absolute values of the fold change column. Therefore, any negative value will be made positive, thus allowing the values between -1.2 and 1.2 to be properly ignored. If the abs function wasn't being used, then yes, you could include the rule for the opposite direction as well, e.g.:

df <- df[df$p < 0.05 & df$logfc > 1.2 & df$logfc < -1.2,]

ADD REPLY
0
Entering edit mode

Thanks a lot. Interestingly, when I try to obtain my data using such codes, I get no results in response. However, when I save my table as an excel file, there are plenty of genes with my criteria. I think your first suggestion about avoiding post-hoc filtering is the answer.

ADD REPLY
3
Entering edit mode
2.2 years ago
Gordon Smyth ★ 7.5k

Since you're using the limma package, you could have generated the table you wanted in the first place by adding p=0.05 and lfc=log2(1.2) to the topTable call, for example

topTable(fit, coef=YourContrast, p=0.05, lfc=log2(1.2))

See help("topTable") and please read the Note on that page.

I suspect you probably mean fold-change > 1.2 rather than log-fold-change > 1.2 because the latter cutoff would be unusual and not very sensible.

ADD COMMENT
0
Entering edit mode

Thanks for your help. I could not not how should I define a range with lfc. I want to get the data which have expressed higher than 1.2 fold change or lower than -1.2 fold change. I actually do not know how to get such data with lfc in toptable.

ADD REPLY
1
Entering edit mode

The code I have shown you does exactly that.

ADD REPLY

Login before adding your answer.

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