Mercurial > repos > bimib > cobraxy
comparison COBRAxy/marea.py @ 297:1402c2beb8f2 draft
Uploaded
author | francesco_lapi |
---|---|
date | Fri, 16 May 2025 10:56:44 +0000 |
parents | 7b8d9de81a86 |
children | 8ae278b4a5d5 |
comparison
equal
deleted
inserted
replaced
296:5c70b653539b | 297:1402c2beb8f2 |
---|---|
61 parser.add_argument( | 61 parser.add_argument( |
62 '-pv' ,'--pValue', | 62 '-pv' ,'--pValue', |
63 type = float, | 63 type = float, |
64 default = 0.1, | 64 default = 0.1, |
65 help = 'P-Value threshold (default: %(default)s)') | 65 help = 'P-Value threshold (default: %(default)s)') |
66 | |
67 parser.add_argument( | |
68 '-adj' ,'--adjusted', | |
69 type = utils.Bool("adjusted"), default = False, | |
70 help = 'Apply the FDR (Benjamini-Hochberg) correction (default: %(default)s)') | |
66 | 71 |
67 parser.add_argument( | 72 parser.add_argument( |
68 '-fc', '--fChange', | 73 '-fc', '--fChange', |
69 type = float, | 74 type = float, |
70 default = 1.5, | 75 default = 1.5, |
772 if np.isfinite(z_score) and max_z_score < abs(z_score): max_z_score = abs(z_score) | 777 if np.isfinite(z_score) and max_z_score < abs(z_score): max_z_score = abs(z_score) |
773 comparisonResult[reactId] = [float(p_value), avg, z_score, sum(l1) / len(l1), sum(l2) / len(l2)] | 778 comparisonResult[reactId] = [float(p_value), avg, z_score, sum(l1) / len(l1), sum(l2) / len(l2)] |
774 | 779 |
775 except (TypeError, ZeroDivisionError): continue | 780 except (TypeError, ZeroDivisionError): continue |
776 | 781 |
782 # Apply multiple testing correction if set by the user | |
783 if ARGS.adjusted: | |
784 | |
785 # Retrieve the p-values from the comparisonResult dictionary | |
786 reactIds = list(comparisonResult.keys()) | |
787 pValues = [comparisonResult[reactId][0] for reactId in reactIds] | |
788 | |
789 # Apply the Benjamini-Hochberg correction and update | |
790 adjustedPValues = st.multipletests(pValues, method="fdr_bh")[1] | |
791 for i, reactId in enumerate(reactIds): | |
792 comparisonResult[reactId][0] = adjustedPValues[i] | |
793 | |
777 return comparisonResult, max_z_score | 794 return comparisonResult, max_z_score |
778 | 795 |
779 def computeEnrichment(class_pat: Dict[str, List[List[float]]], ids: List[str], *, fromRAS=True) -> List[Tuple[str, str, dict, float]]: | 796 def computeEnrichment(class_pat: Dict[str, List[List[float]]], ids: List[str], *, fromRAS=True) -> List[Tuple[str, str, dict, float]]: |
780 """ | 797 """ |
781 Compares clustered data based on a given comparison mode and applies enrichment-based styling on the | 798 Compares clustered data based on a given comparison mode and applies enrichment-based styling on the |