diff --git a/screenpro/__init__.py b/screenpro/__init__.py index 5f25cd1..0dd6021 100644 --- a/screenpro/__init__.py +++ b/screenpro/__init__.py @@ -31,6 +31,6 @@ from .dashboard import DrugScreenDashboard -__version__ = "0.4.15" +__version__ = "0.4.16" __author__ = "Abe Arab" __email__ = 'abea@arcinstitute.org' # "abarbiology@gmail.com" diff --git a/screenpro/assays/__init__.py b/screenpro/assays/__init__.py index 28a3908..eee68c2 100644 --- a/screenpro/assays/__init__.py +++ b/screenpro/assays/__init__.py @@ -286,6 +286,20 @@ def calculateFlowBasedScreen(self, low_bin, high_bin, score_level, run_name=None run_name (str): name for the phenotype calculation run **kwargs: additional arguments to pass to runPhenoScore """ + if not run_name: run_name = score_level + if run_name in self.phenotypes.keys(): + raise ValueError(f"Phenotype calculation run '{run_name}' already exists in self.phenoypes!") + else: + self.phenotypes[run_name] = {} + self.phenotypes[run_name]['config'] = { + 'method':'ScreenPro2 - phenoscore', + 'low_bin':low_bin, + 'high_bin':high_bin, + 'test':self.test, + 'score_level':score_level, + } + self.phenotypes[run_name]['results'] = {} + # calculate phenotype scores delta_name, delta = runPhenoScore( self.adata, cond_ref=low_bin, cond_test=high_bin, n_reps=self.n_reps, @@ -293,15 +307,8 @@ def calculateFlowBasedScreen(self, low_bin, high_bin, score_level, run_name=None **kwargs ) - if not run_name: run_name = score_level - # save all results into a multi-index dataframe - self.phenotypes[run_name] = pd.concat({ - f'delta:{delta_name}': delta - }, axis=1) - - # save phenotype name for reference - self._add_phenotype_results(f'delta:{delta_name}') - + self._add_phenotype_results(run_name, f'delta:{delta_name}', delta) + def listPhenotypeScores(self, run_name='auto'): """ List available phenotype scores for a given run_name diff --git a/screenpro/phenoscore/_annotate.py b/screenpro/phenoscore/_annotate.py index e7993d7..3626728 100644 --- a/screenpro/phenoscore/_annotate.py +++ b/screenpro/phenoscore/_annotate.py @@ -17,6 +17,10 @@ 'rho':{ 'up_hit':'resistance_hit', 'down_hit':'sensitivity_hit' + }, + 'delta':{ + 'up_hit':'up_hit', + 'down_hit':'down_hit' } }