Convert Logp value to P value
2
2
Entering edit mode
4.4 years ago
tothepoint ▴ 940

Dear All,

I am having trouble with P value conversion for my data. I tried following this post but could not understand how I can get the P value out of LogP value or -log10 (p-value). Please share your experience I can get P value out of the data in either R or excel.

rsid         CHR  LOGPVALUE
rs3243810    1    3.835343448
rs3287090    1    3.835343448
rs3283061    1    2.225202326
rs3393481    1    2.225202326

Regards
Devender

snp csv R • 3.9k views
ADD COMMENT
0
Entering edit mode

You need to know which base you're using for your log.

ADD REPLY
3
Entering edit mode
4.4 years ago

Hi,

To obtain the p-value from the -log10(p-value) you can try (assuming that you are working from R, and the example data that you presented is called data):

data$pvalue <- 10**-(data$LOGPVALUE)

You can apply the formula on excel too: https://stackoverflow.com/questions/53913175/how-to-do-an-inverse-log-transformation-in-r

I hope this helps,

António

ADD COMMENT
0
Entering edit mode

Sorry, this does not work.

ADD REPLY
0
Entering edit mode

Now, I think it works. I missed the sign "-".

ADD REPLY
0
Entering edit mode

It works smoothly. Thank you so much.

ADD REPLY
3
Entering edit mode
4.4 years ago
Ram 44k

I'm assuming a few things here:

  1. Your data was in CSV format, which you read into a data.frame in R using something like read.table or read.csv
  2. The "log" transform was base-2
  3. The data.frame column names are the same as you mention above
  4. Your data.frame is named df
log_base <- 2 #Change this if your log is base-10 or is a natural log (base e)
df$PVALUE <- log_base ^ -df$LOGPVALUE
ADD COMMENT
0
Entering edit mode

Dear Sir, I tried the above method but it leads to P-value greater than 1.

ADD REPLY
1
Entering edit mode

Your base is probably not 2 then. The ** and ^ operators are equivalent - now that Antonio's solution works for you, use it and remember that there are two options to exponentiate in R.

> 2 ** 10
[1] 1024
> 2 ^ 10
[1] 1024
ADD REPLY

Login before adding your answer.

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