From 2174e219c409fbe271101eee7f972fd948e45f17 Mon Sep 17 00:00:00 2001 From: abearab Date: Sat, 21 Sep 2024 22:13:09 -0700 Subject: [PATCH 1/4] add pycairo --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 2313478..dc52bce 100644 --- a/environment.yml +++ b/environment.yml @@ -19,6 +19,7 @@ dependencies: - mscorefonts - rust>=1.72 - polars>0.20 + - pycairo - pip - pip: - pyarrow From 5315355ffeb7c1be47048ce336982240722ebb78 Mon Sep 17 00:00:00 2001 From: abearab Date: Sat, 21 Sep 2024 23:15:47 -0700 Subject: [PATCH 2/4] update docs --- screenpro/phenoscore/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/screenpro/phenoscore/__init__.py b/screenpro/phenoscore/__init__.py index f60427a..009b9bc 100644 --- a/screenpro/phenoscore/__init__.py +++ b/screenpro/phenoscore/__init__.py @@ -25,8 +25,9 @@ from .phenostat import matrixStat, multipleTestsCorrection -def runPhenoScore(adata, cond_ref, cond_test, score_level, var_names='target', test='ttest', - growth_rate=1, n_reps='auto', keep_top_n = None, collapse_var=False, +def runPhenoScore(adata, cond_ref, cond_test, score_level, + var_names='target', collapse_var=False, + test='ttest', growth_rate=1, n_reps='auto', keep_top_n = None, num_pseudogenes='auto', pseudogene_size='auto', count_layer=None, count_filter_type='mean', count_filter_threshold=40, ctrl_label='negative_control' @@ -39,6 +40,7 @@ def runPhenoScore(adata, cond_ref, cond_test, score_level, var_names='target', t cond_test (str): condition test score_level (str): score level var_names (str): variable names to use as index in the result dataframe + collapse_var (str): variable to use for `getBestTargetByTSS` function, default is False test (str): test to use for calculating p-value ('MW': Mann-Whitney U rank; 'ttest' : t-test) growth_rate (int): growth rate n_reps (int): number of replicates @@ -127,7 +129,7 @@ def runPhenoScore(adata, cond_ref, cond_test, score_level, var_names='target', t filter_threshold=count_filter_threshold ) - # get best best transcript as lowest p-value for each target + # get the best transcript as lowest p-value for each target if collapse_var not in [False, None]: if collapse_var not in result.columns: raise ValueError(f'collapse_var "{collapse_var}" not found in result columns.') From 542a8c220ae0552ad6f7ac33605a05f4156f85ca Mon Sep 17 00:00:00 2001 From: abearab Date: Mon, 23 Sep 2024 16:13:11 -0700 Subject: [PATCH 3/4] update `buildPhenotypeData` --- screenpro/assays/__init__.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/screenpro/assays/__init__.py b/screenpro/assays/__init__.py index 1cf0776..cff22c3 100644 --- a/screenpro/assays/__init__.py +++ b/screenpro/assays/__init__.py @@ -344,18 +344,6 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg else: raise ValueError('Only `compare_reps` run_name is supported for now!') - untreated = self.phenotypes[run_name]['config']['untreated'] - treated = self.phenotypes[run_name]['config']['treated'] - - if type(treated) != list: treated = [treated] - - if db_rate_col: - #TODO: fix `_calculateGrowthFactor` and `_getTreatmentDoublingRate` - growth_factor_table = self._calculateGrowthFactor( - untreated = untreated, treated = treated, - db_rate_col = db_rate_col - ) - pdata_list = [] for phenotype_name in self.listPhenotypeScores(run_name=run_name): @@ -363,10 +351,15 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg score_tag, comparison = phenotype_name.split(':') cond_test, cond_ref = comparison.split('_vs_') + #TODO: fix `_calculateGrowthFactor` and `_getTreatmentDoublingRate` if db_rate_col: - growth_rate_reps=growth_factor_table.query( + growth_rate_reps = self._calculateGrowthFactor( + untreated = cond_ref, treated = cond_test, + db_rate_col = db_rate_col + ).query( f'score=="{score_tag}"' ).set_index('replicate')['growth_factor'].to_dict() + else: growth_rate_reps=None @@ -376,7 +369,6 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg growth_rate_reps=growth_rate_reps, **kwargs ) - # obs = growth_factor_table.loc[pdata_df.index,:], pdata_list.append(pdata) From 0685fec002bf937e54e62c5c19c9884678fcbc3a Mon Sep 17 00:00:00 2001 From: abearab Date: Mon, 23 Sep 2024 16:55:43 -0700 Subject: [PATCH 4/4] mend --- screenpro/assays/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/screenpro/assays/__init__.py b/screenpro/assays/__init__.py index cff22c3..28a3908 100644 --- a/screenpro/assays/__init__.py +++ b/screenpro/assays/__init__.py @@ -344,6 +344,8 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg else: raise ValueError('Only `compare_reps` run_name is supported for now!') + untreated = self.phenotypes[run_name]['config']['untreated'] + pdata_list = [] for phenotype_name in self.listPhenotypeScores(run_name=run_name): @@ -354,7 +356,8 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg #TODO: fix `_calculateGrowthFactor` and `_getTreatmentDoublingRate` if db_rate_col: growth_rate_reps = self._calculateGrowthFactor( - untreated = cond_ref, treated = cond_test, + untreated = untreated, + treated = cond_test, # should be part of "treated" list! db_rate_col = db_rate_col ).query( f'score=="{score_tag}"'