Skip to content

Instantly share code, notes, and snippets.

@endrebak
Last active April 24, 2018 07:42
Show Gist options
  • Save endrebak/9824f8ae22448946b10fc914b317bd0c to your computer and use it in GitHub Desktop.
Save endrebak/9824f8ae22448946b10fc914b317bd0c to your computer and use it in GitHub Desktop.
Simes' method Python
import pandas as pd
# A combined P-value was computed for each peak cluster using Simes’ method
# (19). For a cluster containing n windows, the combined P-value is defined as
# p{s}=min{np{r}/r;r=1,2…,n} where the p{r} are the individual window P-values sorted
# in increasing order. This provides weak control of the family-wise error rate
# across the set of null hypotheses for all windows in the cluster. In other
# words, p{s} represents evidence against the global null hypothesis, i.e. that
# no windows in the cluster are DB.
p_vals = pd.Series([0.01, 0.001, 0.1, 0.5, 0.05])
def simes(p_vals):
sorted = p_vals.sort_values()
ranks = pd.Series(range(1, len(p_vals) + 1))
multiplied = sorted * len(ranks)
results = multiplied/ranks.values
return min(results)
simes(p_vals)
# 0.005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment