Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter extreme p-values using .Machine$double.xmin #110

Open
amstilp opened this issue Mar 14, 2024 · 1 comment
Open

Filter extreme p-values using .Machine$double.xmin #110

amstilp opened this issue Mar 14, 2024 · 1 comment

Comments

@amstilp
Copy link
Contributor

amstilp commented Mar 14, 2024

In https://github.com/UW-GAC/analysis_pipeline assoc_plots, instead of hardcoding the threshold for p-value to 38.5, use .Machine$double.xmin to calculate the threshold that can be used. The current code is:

if ("stat" %in% names(assoc)) {
    extreme <- abs(assoc$stat) > 38.5
    if (any(extreme)) assoc$pval[extreme] <- 5e-324
}

5e-324 was probably chosen based on this information from ?.Machine:

     Note that on most platforms smaller positive values than
     ‘.Machine$double.xmin’ can occur.  On a typical R platform the
     smallest positive double is about ‘5e-324’.

but it's most reliable to use the value in .Machine. The code would then change to:

if ("stat" %in% names(assoc)) {
    extreme <- assoc$stat^2 > qchisq(.Machine$double.xmin, df=1, lower.tail=F)
    if (any(extreme)) assoc$pval[extreme] <- .Machine$double.xmin
}

A p-value of 5e-324 and eg 2.225074e-308 (from .Machine$double.xmin on my machine) are basically the same, anyway.

@amstilp amstilp transferred this issue from UW-GAC/analysis_pipeline Mar 15, 2024
@amstilp amstilp changed the title Change pval=0 detection to use .Machine$double.xmin Filter extreme p-values using .Machine$double.xmin Mar 15, 2024
@amstilp
Copy link
Contributor Author

amstilp commented Mar 15, 2024

Instead of making this change in analysis_pipeline, better to make it in GENESIS. Any function calling pchisq should then filter extremely low p-values using the above code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant