Mercurial > repos > bimib > cobraxy
comparison COBRAxy/flux_to_map.py @ 197:1306b3543e57 draft
Uploaded
author | francesco_lapi |
---|---|
date | Thu, 21 Nov 2024 10:43:48 +0000 |
parents | 8b7d2e6b4995 |
children | 1dda40a60037 |
comparison
equal
deleted
inserted
replaced
196:07539860dbca | 197:1306b3543e57 |
---|---|
495 width = max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W) | 495 width = max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W) |
496 | 496 |
497 except ZeroDivisionError: pass | 497 except ZeroDivisionError: pass |
498 # TODO CHECK RV | 498 # TODO CHECK RV |
499 #if not reactionId.endswith("_RV"): # RV stands for reversible reactions | 499 #if not reactionId.endswith("_RV"): # RV stands for reversible reactions |
500 # Arrow(width, ArrowColor.fromFoldChangeSign(foldChange)).styleReactionElements(metabMap, reactionId) | 500 # Arrow(width, ArrowColor.fromFoldChangeSign(foldChange)).styleReactionElements(metabMap, reactionId) |
501 # continue | 501 # continue |
502 | 502 |
503 #reactionId = reactionId[:-3] # Remove "_RV" | 503 #reactionId = reactionId[:-3] # Remove "_RV" |
504 | 504 |
505 inversionScore = (values[3] < 0) + (values[4] < 0) # Compacts the signs of averages into 1 easy to check score | 505 inversionScore = (values[3] < 0) + (values[4] < 0) # Compacts the signs of averages into 1 easy to check score |
506 if inversionScore == 2: foldChange *= -1 | 506 if inversionScore == 2: foldChange *= -1 |
724 | 724 |
725 try: | 725 try: |
726 p_value, z_score = computePValue(l1, l2) | 726 p_value, z_score = computePValue(l1, l2) |
727 avg1 = sum(l1) / len(l1) | 727 avg1 = sum(l1) / len(l1) |
728 avg2 = sum(l2) / len(l2) | 728 avg2 = sum(l2) / len(l2) |
729 avg = fold_change(avg1, avg2) | 729 f_c = fold_change(avg1, avg2) |
730 if not isinstance(z_score, str) and max_z_score < abs(z_score): max_z_score = abs(z_score) | 730 if not isinstance(z_score, str) and max_z_score < abs(z_score): max_z_score = abs(z_score) |
731 tmp[reactId] = [float(p_value), avg, z_score, avg1, avg2] | 731 print(reactId, float(p_value), f_c, z_score, avg1, avg2) |
732 tmp[reactId] = [float(p_value), f_c, z_score, avg1, avg2] | |
732 except (TypeError, ZeroDivisionError): continue | 733 except (TypeError, ZeroDivisionError): continue |
733 | 734 |
734 return tmp, max_z_score | 735 return tmp, max_z_score |
735 | 736 |
736 def computeEnrichment(class_pat :Dict[str, List[List[float]]], ids :List[str]) -> List[Tuple[str, str, dict, float]]: | 737 def computeEnrichment(class_pat :Dict[str, List[List[float]]], ids :List[str]) -> List[Tuple[str, str, dict, float]]: |