This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert Logp value to P value

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

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

2 answers

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

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

It works smoothly. Thank you so much.

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

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

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

Log in to answer this question.