Mercurial > repos > bimib > cobraxy
changeset 297:1402c2beb8f2 draft
Uploaded
author | francesco_lapi |
---|---|
date | Fri, 16 May 2025 10:56:44 +0000 |
parents | 5c70b653539b |
children | bc8cbaacafd0 |
files | COBRAxy/marea.py |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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]]: