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 diff --git a/screenpro/assays/__init__.py b/screenpro/assays/__init__.py index 1cf0776..28a3908 100644 --- a/screenpro/assays/__init__.py +++ b/screenpro/assays/__init__.py @@ -345,16 +345,6 @@ def buildPhenotypeData(self, run_name='auto',db_rate_col='pop_doubling', **kwarg 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 = [] @@ -363,10 +353,16 @@ 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 = untreated, + treated = cond_test, # should be part of "treated" list! + 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 +372,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) 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.')