7 releases

0.1.6 Jun 28, 2024
0.1.5 Feb 6, 2024
0.1.4 Aug 23, 2022

#137 in Science

Download history 16/week @ 2024-07-18 23/week @ 2024-07-25 18/week @ 2024-08-01 75/week @ 2024-08-08 23/week @ 2024-08-15 33/week @ 2024-08-22 33/week @ 2024-08-29 271/week @ 2024-09-05 31/week @ 2024-09-12 20/week @ 2024-09-19 58/week @ 2024-09-26 98/week @ 2024-10-03 25/week @ 2024-10-10 10/week @ 2024-10-17 30/week @ 2024-10-24 27/week @ 2024-10-31

95 downloads per month
Used in 3 crates

MIT license

18KB
326 lines

adjustp

Summary

This is a crate to perform pvalue adjustments for multiple hypothesis tests and is inspired by the R function p.adjust.

There are currently only three methods available: Bonferroni, Benjamini-Hochberg, and Benjamini-Yekutieli.

This crate gives a single interface for each of these multiple hypothesis corrections and does not expect the p-values to be presorted before calculating.

Usage

The main interface for the tests is through the adjust function, which takes a slice of f64 and a Procedure. If you are using ndarray you can use this easily with the .as_slice() function.

Basic Usage

Here's an example for a Bonferroni correction.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::Bonferroni);
assert_eq!(qvalues, vec![0.5, 1.0, 1.0, 1.0, 0.5]);

And another example for a BenjaminiHochberg adjustment.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::BenjaminiHochberg);
assert_eq!(qvalues, vec![0.25, 0.33333333333333337, 0.375, 0.4, 0.25]);

And another example for a BenjaminiYekutieli adjustment.

use adjustp::{adjust, Procedure};

let pvalues = vec![0.1, 0.2, 0.3, 0.4, 0.1];
let qvalues = adjust(&pvalues, Procedure::BenjaminiYekutieli);
assert_eq!(qvalues, vec![0.5708333333333333, 0.7611111111111111, 0.8562500, 0.91333333333333333, 0.5708333333333333]);

Dependencies

~150KB