# HG changeset patch # User francesco_lapi # Date 1747393004 0 # Node ID 1402c2beb8f2a7ccf3cb60b7185b3ea6ce73524d # Parent 5c70b653539b006b6f81bcfd7a40e539cacd0061 Uploaded diff -r 5c70b653539b -r 1402c2beb8f2 COBRAxy/marea.py --- a/COBRAxy/marea.py Fri May 16 10:56:24 2025 +0000 +++ b/COBRAxy/marea.py Fri May 16 10:56:44 2025 +0000 @@ -63,6 +63,11 @@ type = float, default = 0.1, help = 'P-Value threshold (default: %(default)s)') + + parser.add_argument( + '-adj' ,'--adjusted', + type = utils.Bool("adjusted"), default = False, + help = 'Apply the FDR (Benjamini-Hochberg) correction (default: %(default)s)') parser.add_argument( '-fc', '--fChange', @@ -774,6 +779,18 @@ except (TypeError, ZeroDivisionError): continue + # Apply multiple testing correction if set by the user + if ARGS.adjusted: + + # Retrieve the p-values from the comparisonResult dictionary + reactIds = list(comparisonResult.keys()) + pValues = [comparisonResult[reactId][0] for reactId in reactIds] + + # Apply the Benjamini-Hochberg correction and update + adjustedPValues = st.multipletests(pValues, method="fdr_bh")[1] + for i, reactId in enumerate(reactIds): + comparisonResult[reactId][0] = adjustedPValues[i] + return comparisonResult, max_z_score def computeEnrichment(class_pat: Dict[str, List[List[float]]], ids: List[str], *, fromRAS=True) -> List[Tuple[str, str, dict, float]]: