The world of statistics can often feel like a tangled web, especially when dealing with multiple hypothesis testing. As researchers sift through vast amounts of data, they may inadvertently fall into the trap of false positives. Enter MultiPy, a Python package designed to tackle this very issue by controlling both the family-wise error rate (FWER) and the false discovery rate (FDR). Below, we’ll guide you through the setup of MultiPy while providing insights into its features and functionalities.
Understanding Multiple Hypothesis Testing
Imagine you’re a detective sifting through a mountain of evidence. Each piece might seem significant on its own, but when viewed collectively, many items may lead down the wrong path. This is similar to hypothesis testing; testing multiple hypotheses without correction increases the chances of false positives. The MultiPy package helps ensure that your significant findings hold water.
Installing MultiPy
Installation of MultiPy can be done in a couple of ways. You can either use pip, which is quick and easy, or manually clone the repository for the latest version.
Using pip
bash
pip install multipy
Manual Installation
bash
git clone https://github.com/puolival/multipy.git
cd multipy
python setup.py install
Required Dependencies
Before you dive in, make sure you have the necessary dependencies installed. MultiPy requires:
- NumPy (version 1.10.2 or later)
- SciPy (version 0.17.0 or later)
- Matplotlib (version 2.1.0 or later)
- Seaborn (version 0.8.0 or later)
- scikit-image (version 0.13.0 or later)
While the codes may work with earlier versions, compatibility hasn’t been thoroughly tested.
Controlling FWER and FDR
MultiPy implements various methods to control the FWER and FDR, ensuring the integrity of your statistical findings:
Methods for Controlling FWER
- Bonferroni Correction
- Šidák Correction
- Hochberg’s Procedure
- Holm-Bonferroni Procedure
- Permutation Tests
- Random Field Theory (RFT) Based Approaches
Methods for Controlling FDR
- Benjamini-Hochberg Procedure
- Storey-Tibshirani q-value Procedure
- Adaptive Linear Step-Up Procedure
- Two-Stage Linear Step-Up Procedure
Quick Example: Controlling FWER
Here’s a quick example demonstrating how to apply Šidák correction with MultiPy:
python
from multipy.data import neuhaus
from multipy.fwer import sidak
pvals = neuhaus()
significant_pvals = sidak(pvals, alpha=0.05)
print(zip([:.4f.format(p) for p in pvals], significant_pvals))
Quick Example: Controlling FDR
And here’s how you can use the Linear Step-Up (LSU) method for FDR control:
python
from multipy.fdr import lsu
from multipy.data import neuhaus
pvals = neuhaus()
significant_pvals = lsu(pvals, q=0.05)
print(zip([:.4f.format(p) for p in pvals], significant_pvals))
Visualizing Results
Understanding the outcome of your analyses is just as important as performing them. MultiPy offers visualization methods to create diagnostic plots:
python
from multipy.data import two_group_model
from multipy.fdr import qvalue
from multipy.viz import plot_qvalue_diagnostics
tstats, pvals = two_group_model(N=25, m=1000, pi0=0.5, delta=1)
_, qvals = qvalue(pvals)
plot_qvalue_diagnostics(tstats, pvals, qvals)
Troubleshooting
If you encounter any issues, don’t hesitate to report bugs or suggest improvements by opening an issue on GitHub.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Final Thoughts
As you embark on your journey with MultiPy, remember that controlling the rate of false positives is vital for extracting reliable insights from your data. Explore, test, and visualize effectively, and may your research shine with integrity!
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

