Question: Convert Logp value to P value
0
gravatar for devarora
5 weeks ago by
devarora160
SouthKorea
devarora160 wrote:

Dear All,

I am having trouble with P value conversion for my data. I tried follwoing Biostar Post but couldnot 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

logp snp P csv R • 127 views
ADD COMMENTlink modified 5 weeks ago by RamRS28k • written 5 weeks ago by devarora160

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

ADD REPLYlink written 5 weeks ago by Jean-Karim Heriche23k
3
gravatar for antonioggsousa
5 weeks ago by
antonioggsousa920 wrote:

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 COMMENTlink modified 5 weeks ago by RamRS28k • written 5 weeks ago by antonioggsousa920

Sorry, this does not work.

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by antonioggsousa920

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

ADD REPLYlink written 5 weeks ago by antonioggsousa920

It works smoothly. Thank you so much.

ADD REPLYlink written 5 weeks ago by devarora160
1
gravatar for RamRS
5 weeks ago by
RamRS28k
Houston, TX
RamRS28k wrote:

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 COMMENTlink modified 5 weeks ago • written 5 weeks ago by RamRS28k

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

ADD REPLYlink written 5 weeks ago by devarora160
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
ADD REPLYlink written 5 weeks ago by RamRS28k
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: 825 users visited in the last hour