Independent Hypothesis Weighting for large-scale multiple testing
Project description
pyIHW
Python implementation of Independent Hypothesis Weighting (IHW) by Ignatiadis & Huber (2016, Nature Methods).
IHW improves power in large-scale multiple testing by learning data-driven weights from an independent covariate while controlling FDR at a user-specified level.
Installation
pip install pyihw
Quick start
pyIHW ships with DESeq2 results from the airway RNA-seq dataset (Himes et al. 2014):
import numpy as np
from pyihw import ihw, load_airway, bh_threshold
pvalues, basemean = load_airway()
print(f"{len(pvalues)} hypotheses")
33469 hypotheses
Run IHW with baseMean as the covariate and compare to standard Benjamini-Hochberg:
result = ihw(pvalues, basemean, alpha=0.1, rng=np.random.default_rng(42))
t_bh = bh_threshold(pvalues, alpha=0.1)
bh_rejections = int(np.sum(pvalues <= t_bh))
print(f"BH rejections: {bh_rejections}")
print(f"IHW rejections: {result.n_rejections}")
print(f"Improvement: +{result.n_rejections - bh_rejections} discoveries")
BH rejections: 4099
IHW rejections: 4876
Improvement: +777 discoveries
Parameters
ihw(
pvalues,
covariates,
alpha,
*,
covariate_type="ordinal", # "ordinal" or "nominal"
nbins="auto", # number of covariate strata
nfolds=5, # cross-validation folds
adjustment_type="bh", # "bh" (FDR) or "bonferroni" (FWER)
null_proportion=False, # Storey's pi0 estimation
rng=None, # numpy.random.Generator for reproducibility
)
Reproducibility
Pass an rng argument to get deterministic results:
result = ihw(pvalues, covariates, alpha=0.1, rng=np.random.default_rng(42))
Dependencies
NumPy and SciPy only.
Acknowledgments
pyIHW is a Python reimplementation of the IHW R/Bioconductor package by Nikolaos Ignatiadis and Wolfgang Huber. The method is described in:
Ignatiadis, N., Klaus, B., Zaugg, J.B. et al. Data-driven hypothesis weighting increases detection power in genome-scale multiple testing. Nature Methods 13, 577–580 (2016). doi:10.1038/nmeth.3885
The bundled airway dataset is from Himes et al. (2014), PLoS ONE 9(6): e99625 (GEO GSE52778), processed through DESeq2.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyihw-0.2.0.tar.gz.
File metadata
- Download URL: pyihw-0.2.0.tar.gz
- Upload date:
- Size: 494.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b46ac5177ca45a459b9b25a4445d87a8e0e1dfc79b7e7962def14de05d3c5d9
|
|
| MD5 |
7e55e9c6fd53f982b9b4f7dd639e6733
|
|
| BLAKE2b-256 |
8dcbc7b7391ba8cdc11e7df7b7fb2bb44f5e940e9b847e08a5cf1b5796c53c1a
|
File details
Details for the file pyihw-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyihw-0.2.0-py3-none-any.whl
- Upload date:
- Size: 495.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f946aae217df6dba271ec3c0f8ccb24f8ef69c525be54fc13b73c72e7252cd88
|
|
| MD5 |
3be31c4c8387e54734d5b18570722b1c
|
|
| BLAKE2b-256 |
c76bae23cc9e0f8ea881e4eb90f160fb31c0b9911bdb89502a9857ec18297450
|