Skip to content

Commit

Permalink
Merge pull request #15 from LIVVkit/mkstratos/mvk_fdr_fix
Browse files Browse the repository at this point in the history
Use the BH correction rather than BY
  • Loading branch information
mkstratos authored Sep 12, 2024
2 parents 8236001 + d0b4808 commit 7dc4387
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion evv4esm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


__version_info__ = (0, 5, 1)
__version_info__ = (0, 5, 2)
__version__ = ".".join(str(vi) for vi in __version_info__)

PASS_COLOR = "#389933"
Expand Down
12 changes: 8 additions & 4 deletions evv4esm/extensions/ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ def run(name, config):
details, img_gal = main(args)

table_data = pd.DataFrame(details).T
uc_rejections = (table_data["K-S test stat"] < args.alpha).sum()

_hdrs = [
"h0",
"K-S test stat",
"K-S test p-val",
"K-S test p-val cor",
"T test stat",
"T test p-val",
"mean test case",
Expand Down Expand Up @@ -268,6 +271,7 @@ def run(name, config):
if len(rejects) < critical
else "statistically different"
],
"Un-corrected rejections": [uc_rejections],
}
),
)
Expand Down Expand Up @@ -327,6 +331,7 @@ def summarize_result(results_page):
summary["Rejecting"] = elem.data["Rejecting"][0]
summary["Critical value"] = elem.data["Critical value"][0]
summary["Ensembles"] = elem.data["Ensembles"][0]
summary["Uncorrected Rejections"] = elem.data["Un-corrected rejections"][0]
break

return {"": summary}
Expand Down Expand Up @@ -397,17 +402,16 @@ def compute_details(annual_avgs, common_vars, args):
# Create a null hypothesis rejection column for un-corrected p-values
detail_df["h0_uc"] = detail_df["K-S test p-val"] < args.alpha

(detail_df["h0_c"], detail_df["pval_c"]) = smm.fdrcorrection(
detail_df["K-S test p-val"], alpha=args.alpha, method="n", is_sorted=False
(detail_df["h0_c"], detail_df["K-S test p-val cor"]) = smm.fdrcorrection(
detail_df["K-S test p-val"], alpha=args.alpha, method="p", is_sorted=False
)

if args.uncorrected:
_testkey = "h0_uc"
else:
_testkey = "h0_c"

for var in common_vars:
details[var]["K-S test p-val"] = detail_df.loc[var, "pval_c"]
details[var]["K-S test p-val cor"] = detail_df.loc[var, "K-S test p-val cor"]

if details[var]["T test stat"] is None:
details[var]["h0"] = "-"
Expand Down

0 comments on commit 7dc4387

Please sign in to comment.