YinLiLin / CMplot

📊 Circular and Rectangular Manhattan Plot
499 stars 111 forks source link

Error: p values should be at range of (0, 1). #85

Open kaanokay opened 1 year ago

kaanokay commented 1 year ago

Hi,

thank you for developing such a good tool.

When I created a data frame like pig60K data, I encountered an error: "Error in CMplot(input2, type = "p", plot.type = "m", LOG10 = TRUE, threshold = NULL, : p values should be at range of (0, 1)." When I checked range of pvalues with range() function, range of them is between 0 and 1. Could you help me with this? I have no GWAS data but I expected that another very similar data supposed to be draw in R with your tool. My data is entirely the same with example data pig60K.

Best regards.

YinLiLin commented 1 year ago

Hi, this issue has been fixed, please update to the new version and try again.

anbai106 commented 1 year ago

Hey, I used the new version (installed two days ago). The same error occurs. I checked the P-value of the GWAS summary statistics, and they are in the range of [0, 1], with some NANs, but I assume the software will take into account the NANs.

Armandjg commented 1 year ago

The range is exclusive-- you have to add/subtract a tiny value from 0 and 1. Eg., 0 + .000000000001.

anbai106 commented 1 year ago

The range is exclusive-- you have to add/subtract a tiny value from 0 and 1. Eg., 0 + .000000000001.

I understand this solution - but this solution may not make sense for a very small P-value, e.g., -log10(P) = 250. I still get the same error after setting the 0.00000 (many other zeros) to 1e-250.

What is the smalles P-value that the software can read (not to set it to 0)? One of my GWAS can reach -log10(P-value) = 182, but the errors occurred on another GWAS, whose most significant P-value: -log10(P-value) = 282

I think the problem is that the software treated extremely small values as 0...

YinLiLin commented 1 year ago

Thank you for the question. I am not sure if R can recognize 'NANs' as missing values, we generally use 'NA' instead, it may be more appropriate to replace 'NANs' with 'NA', and try again. For the range of p-value, the smallest value that R can handle is 2.225074e-308 as shown in the following:

> .Machine[3:4]
$double.xmin
[1] 2.225074e-308

$double.xmax
[1] 1.797693e+308
anbai106 commented 1 year ago

Thank you! Indeed, my lowest P-value for one phenotype is too small... After setting it to be e-200, the plot worked properly!

@YinLiLin I have another question: How can I set different colors for the SNPs passing the genome-wide p-value threshold for two phenotypes (weight and height)? Say yellow for weight and blue for height?

The parameter signal.col can only be a character, but not a vector to assign different colors. Did I miss something?

Thank you for this wonderful visualization package!

Best

YinLiLin commented 1 year ago

Thank you for the feedback. Sorry that it is currently not available to set different colors for the significant SNP of different traits, the signal.col is designed to color the SNPs located in different intervals of multiple thresholds.

Best, LL

Leweibo commented 4 months ago

R 10^(-411.632)
it returns 0

It works with setting LOG10=FALSE