Skip to content

Commit

Permalink
fix: allow bad degrees-of-freedom
Browse files Browse the repository at this point in the history
chore: bump version
  • Loading branch information
zietzm committed Jul 24, 2024
1 parent e9ef32f commit 88832b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "igwas"
version = "1.0.9"
version = "1.0.10"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 7 additions & 1 deletion src/stats/sumstats.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use statrs::distribution::ContinuousCDF;
use statrs::distribution::StudentsT;

Expand All @@ -9,7 +10,12 @@ pub fn compute_neg_log_pvalue(t_statistic: f32, degrees_of_freedom: i32) -> f32
f if f.is_nan() => f32::NAN,
f if f.is_infinite() => f32::INFINITY,
_ => {
let t_dist = StudentsT::new(0.0, 1.0, dof).unwrap();
if dof <= 1.0 {
return f32::NAN;
}
let t_dist = StudentsT::new(0.0, 1.0, dof)
.with_context(|| format!("Failed to compute t-statistic for dof {}", dof))
.unwrap();
let p = 2.0 * t_dist.cdf(-t.abs());
-p.log10() as f32
}
Expand Down

0 comments on commit 88832b9

Please sign in to comment.