@@ -286,22 +286,29 @@ def calculateFlowBasedScreen(self, low_bin, high_bin, score_level, run_name=None
286286 run_name (str): name for the phenotype calculation run
287287 **kwargs: additional arguments to pass to runPhenoScore
288288 """
289+ if not run_name : run_name = score_level
290+ if run_name in self .phenotypes .keys ():
291+ raise ValueError (f"Phenotype calculation run '{ run_name } ' already exists in self.phenoypes!" )
292+ else :
293+ self .phenotypes [run_name ] = {}
294+ self .phenotypes [run_name ]['config' ] = {
295+ 'method' :'ScreenPro2 - phenoscore' ,
296+ 'low_bin' :low_bin ,
297+ 'high_bin' :high_bin ,
298+ 'test' :self .test ,
299+ 'score_level' :score_level ,
300+ }
301+ self .phenotypes [run_name ]['results' ] = {}
302+
289303 # calculate phenotype scores
290304 delta_name , delta = runPhenoScore (
291305 self .adata , cond_ref = low_bin , cond_test = high_bin , n_reps = self .n_reps ,
292306 test = self .test , score_level = score_level ,
293307 ** kwargs
294308 )
295309
296- if not run_name : run_name = score_level
297- # save all results into a multi-index dataframe
298- self .phenotypes [run_name ] = pd .concat ({
299- f'delta:{ delta_name } ' : delta
300- }, axis = 1 )
301-
302- # save phenotype name for reference
303- self ._add_phenotype_results (f'delta:{ delta_name } ' )
304-
310+ self ._add_phenotype_results (run_name , f'delta:{ delta_name } ' , delta )
311+
305312 def listPhenotypeScores (self , run_name = 'auto' ):
306313 """
307314 List available phenotype scores for a given run_name
0 commit comments