changeset 241:1058a2803472 draft

Uploaded
author luca_milaz
date Sat, 03 Aug 2024 13:59:47 +0000
parents b28a2a7569ac
children 83a62e7743b3
files marea_2/flux_to_map.py
diffstat 1 files changed, 18 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/flux_to_map.py	Sat Aug 03 13:47:37 2024 +0000
+++ b/marea_2/flux_to_map.py	Sat Aug 03 13:59:47 2024 +0000
@@ -62,72 +62,34 @@
         default = 1.5, 
         help = 'Fold-Change threshold (default: %(default)s)')
     
-    parser.add_argument(
-        "-ne", "--net",
-        type = utils.Bool("net"), default = False,
-        help = "choose if you want net enrichment for RPS")
 
     parser.add_argument(
         '-op', '--option',
         type = str, 
         choices = ['datasets', 'dataset_class'],
         help='dataset or dataset and class')
-    
-    #RAS:
-    parser.add_argument(
-        "-ra", "--using_RAS",
-        type = utils.Bool("using_RAS"), default = True,
-        help = "choose whether to use RAS datasets.")
 
     parser.add_argument(
-        '-id', '--input_data',
+        '-idf', '--input_data_fluxes',
         type = str,
-        help = 'input dataset')
+        help = 'input dataset fluxes')
     
     parser.add_argument(
-        '-ic', '--input_class',
-        type = str, 
-        help = 'sample group specification')
+        '-icf', '--input_class_fluxes', 
+        type = str,
+        help = 'sample group specification fluxes')
     
     parser.add_argument(
-        '-ids', '--input_datas',
-        type = str,
-        nargs = '+', 
-        help = 'input datasets')
-    
-    parser.add_argument(
-        '-na', '--names',
+        '-idsf', '--input_datas_fluxes', 
         type = str,
         nargs = '+', 
-        help = 'input names')
-    
-    #RPS:
-    parser.add_argument(
-        "-rp", "--using_RPS",
-        type = utils.Bool("using_RPS"), default = False,
-        help = "choose whether to use RPS datasets.")
-    
-    parser.add_argument(
-        '-idr', '--input_data_rps',
-        type = str,
-        help = 'input dataset rps')
+        help = 'input datasets fluxes')
     
     parser.add_argument(
-        '-icr', '--input_class_rps', 
-        type = str,
-        help = 'sample group specification rps')
-    
-    parser.add_argument(
-        '-idsr', '--input_datas_rps', 
+        '-naf', '--names_fluxes', 
         type = str,
         nargs = '+', 
-        help = 'input datasets rps')
-    
-    parser.add_argument(
-        '-nar', '--names_rps', 
-        type = str,
-        nargs = '+', 
-        help = 'input names rps')
+        help = 'input names fluxes')
     
     #Output:
     parser.add_argument(
@@ -151,7 +113,7 @@
         choices = [utils.Model.HMRcore, utils.Model.ENGRO2, utils.Model.Custom])
 
     args :argparse.Namespace = parser.parse_args()
-    if args.using_RAS and not args.using_RPS: args.net = False
+    args.net = True
 
     return args
           
@@ -448,7 +410,7 @@
         # we assume the reactionIds also don't encode reaction dir if they don't mind it when styling the map.
         if not mindReactionDir: return "R_" + reactionId
 
-        #TODO: this is clearly something we need to make consistent in RPS
+        #TODO: this is clearly something we need to make consistent in fluxes
         return (reactionId[:-3:-1] + reactionId[:-2]) if reactionId[:-2] in ["_F", "_B"] else f"F_{reactionId}" # "Pyr_F" --> "F_Pyr"
 
     def toStyleStr(self, *, downSizedForTips = False) -> str:
@@ -467,12 +429,12 @@
 INVALID_ARROW = Arrow(Arrow.MIN_W, ArrowColor.Invalid)
 INSIGNIFICANT_ARROW = Arrow(Arrow.MIN_W, ArrowColor.Invalid, isDashed = True)
 
-def applyRpsEnrichmentToMap(rpsEnrichmentRes :Dict[str, Union[Tuple[float, FoldChange], Tuple[float, FoldChange, float, float]]], metabMap :ET.ElementTree, maxNumericZScore :float) -> None:
+def applyFluxesEnrichmentToMap(fluxesEnrichmentRes :Dict[str, Union[Tuple[float, FoldChange], Tuple[float, FoldChange, float, float]]], metabMap :ET.ElementTree, maxNumericZScore :float) -> None:
     """
-    Applies RPS enrichment results to the provided metabolic map.
+    Applies fluxes enrichment results to the provided metabolic map.
 
     Args:
-        rpsEnrichmentRes : RPS enrichment results.
+        fluxesEnrichmentRes : fluxes enrichment results.
         metabMap : the metabolic map to edit.
         maxNumericZScore : biggest finite z-score value found.
     
@@ -482,7 +444,7 @@
     Returns:
         None
     """
-    for reactionId, values in rpsEnrichmentRes.items():
+    for reactionId, values in fluxesEnrichmentRes.items():
         pValue = values[0]
         foldChange = values[1]
         z_score = values[2]
@@ -692,7 +654,7 @@
         return
 
     for reactId, enrichData in tmp.items(): tmp[reactId] = tuple(enrichData)
-    applyRpsEnrichmentToMap(tmp, core_map, max_z_score)
+    applyFluxesEnrichmentToMap(tmp, core_map, max_z_score)
 
 def computePValue(dataset1Data: List[float], dataset2Data: List[float]) -> Tuple[float, float]:
     """
@@ -883,13 +845,8 @@
     # getMap will None-check the customPath and panic when the model IS custom but there's no file (good). A cleaner
     # solution can be derived from my comment in FilePath.fromStrPath
 
-    #if ARGS.using_RAS:
-    #    ids, class_pat = getClassesAndIdsFromDatasets(ARGS.input_datas, ARGS.input_data, ARGS.input_class, ARGS.names)
-    #    computeEnrichment(core_map, class_pat, ids)
-    
-    if ARGS.using_RPS:
-        ids, class_pat = getClassesAndIdsFromDatasets(ARGS.input_datas_rps, ARGS.input_data_rps, ARGS.input_class_rps, ARGS.names_rps)
-        computeEnrichment(core_map, class_pat, ids, fromRAS = False)
+    ids, class_pat = getClassesAndIdsFromDatasets(ARGS.input_datas_fluxes, ARGS.input_data_fluxes, ARGS.input_class_fluxes, ARGS.names_fluxes)
+    computeEnrichment(core_map, class_pat, ids, fromRAS = False)
     
     # create output files: TODO: this is the same comparison happening in "maps", find a better way to organize this
     if ARGS.comparison == "manyvsmany":