Mercurial > repos > bimib > cobraxy
comparison COBRAxy/marea.py @ 287:c8622bca2480 draft
Uploaded
author | francesco_lapi |
---|---|
date | Wed, 14 May 2025 09:23:52 +0000 |
parents | eaa623b4b703 |
children | d1d732d1705c |
comparison
equal
deleted
inserted
replaced
286:eaa623b4b703 | 287:c8622bca2480 |
---|---|
369 reactionId : the provided reaction ID. | 369 reactionId : the provided reaction ID. |
370 | 370 |
371 Returns: | 371 Returns: |
372 Tuple[str, str]: either a single str ID for the correct arrow head followed by an empty string or both options to try. | 372 Tuple[str, str]: either a single str ID for the correct arrow head followed by an empty string or both options to try. |
373 """ | 373 """ |
374 print("getArrowHeadElementId: ", reactionId) | |
374 if reactionId.endswith("_RV"): reactionId = reactionId[:-3] #TODO: standardize _RV | 375 if reactionId.endswith("_RV"): reactionId = reactionId[:-3] #TODO: standardize _RV |
375 elif ReactionDirection.fromReactionId(reactionId) is not ReactionDirection.Unknown: | 376 elif ReactionDirection.fromReactionId(reactionId) is not ReactionDirection.Unknown: |
377 print(f"getArrowHeadElementId: {reactionId} this was not unknown.") | |
376 return reactionId[:-3:-1] + reactionId[:-2], "" # ^^^ Invert _F to F_ | 378 return reactionId[:-3:-1] + reactionId[:-2], "" # ^^^ Invert _F to F_ |
377 | 379 |
378 return f"F_{reactionId}", f"B_{reactionId}" | 380 return f"F_{reactionId}", f"B_{reactionId}" |
379 | 381 |
380 class ArrowColor(Enum): | 382 class ArrowColor(Enum): |
381 """ | 383 """ |
382 Encodes possible arrow colors based on their meaning in the enrichment process. | 384 Encodes possible arrow colors based on their meaning in the enrichment process. |
383 """ | 385 """ |
384 Invalid = "#BEBEBE" # gray, fold-change under treshold | 386 Invalid = "#BEBEBE" # gray, fold-change under treshold |
387 Transparent = "#ffffff00" # transparent, not significant p-value | |
385 UpRegulated = "#ecac68" # orange, up-regulated reaction | 388 UpRegulated = "#ecac68" # orange, up-regulated reaction |
386 DownRegulated = "#6495ed" # lightblue, down-regulated reaction | 389 DownRegulated = "#6495ed" # lightblue, down-regulated reaction |
387 | 390 |
388 UpRegulatedInv = "#FF0000" | 391 UpRegulatedInv = "#FF0000" |
389 # ^^^ bright red, up-regulated net value for a reversible reaction with | 392 # ^^^ bright red, up-regulated net value for a reversible reaction with |
432 if not mindReactionDir: | 435 if not mindReactionDir: |
433 return self.applyTo(getArrowBodyElementId(reactionId), metabMap, self.toStyleStr()) | 436 return self.applyTo(getArrowBodyElementId(reactionId), metabMap, self.toStyleStr()) |
434 | 437 |
435 # Now we style the arrow head(s): | 438 # Now we style the arrow head(s): |
436 idOpt1, idOpt2 = getArrowHeadElementId(reactionId) | 439 idOpt1, idOpt2 = getArrowHeadElementId(reactionId) |
440 print("styleReactionElements: ", idOpt1, idOpt2) | |
437 self.applyTo(idOpt1, metabMap, self.toStyleStr(downSizedForTips = True)) | 441 self.applyTo(idOpt1, metabMap, self.toStyleStr(downSizedForTips = True)) |
438 if idOpt2: self.applyTo(idOpt2, metabMap, self.toStyleStr(downSizedForTips = True)) | 442 if idOpt2: self.applyTo(idOpt2, metabMap, self.toStyleStr(downSizedForTips = True)) |
439 | 443 |
440 # TODO: this seems to be unused, remove | 444 # TODO: this seems to be unused, remove |
441 def getMapReactionId(self, reactionId :str, mindReactionDir :bool) -> str: | 445 def getMapReactionId(self, reactionId :str, mindReactionDir :bool) -> str: |
494 | 498 |
495 if math.isnan(pValue) or (isinstance(foldChange, float) and math.isnan(foldChange)): continue | 499 if math.isnan(pValue) or (isinstance(foldChange, float) and math.isnan(foldChange)): continue |
496 | 500 |
497 if isinstance(foldChange, str): foldChange = float(foldChange) | 501 if isinstance(foldChange, str): foldChange = float(foldChange) |
498 if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow | 502 if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow |
503 print("Invalid pValue: ", pValue) | |
499 INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId) | 504 INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId) |
500 continue | 505 continue |
501 | 506 |
502 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1): | 507 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1): |
508 print("Invalid fc: ", foldChange) | |
503 INVALID_ARROW.styleReactionElements(metabMap, reactionId) | 509 INVALID_ARROW.styleReactionElements(metabMap, reactionId) |
504 continue | 510 continue |
505 | 511 |
506 width = Arrow.MAX_W | 512 width = Arrow.MAX_W |
507 if not math.isinf(foldChange): | 513 if not math.isinf(foldChange): |