Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
improve score names
Browse files Browse the repository at this point in the history
  • Loading branch information
abearab committed Aug 24, 2023
1 parent 91b4c6c commit 2e45ed6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions screenpro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def runPhenoScoreByReps(adata,
ctrl_label='negCtrl', test='ttest', math='log2(x+1)'):
"""Calculate phenotype score and p-values comparing `cond2` vs `cond1`
"""
result_name = f'{cond2}_vs_{cond1}'
print(f'\t{cond2} vs {cond1}')

count_layer = 'seq_depth_norm'
Expand Down Expand Up @@ -41,7 +42,7 @@ def runPhenoScoreByReps(adata,
# run ttest on replicates
pvalues = ttest_rel(y, x, axis=1)[1]

return phenotype_score, pvalues
return phenotype_score, pvalues, result_name
else:
raise ValueError(f'Test "{test}" not recognized')

Expand Down Expand Up @@ -84,18 +85,18 @@ def calculateDrugScreen(self,
"""Calculate gamma, rho, and tau phenotype scores using given `method` in `scoreLevel`
"""
if method == 'ByReps':
gamma, gamma_pv = runPhenoScoreByReps(
gamma, gamma_pv, gamma_name= runPhenoScoreByReps(
self.adata, cond1=t0, cond2=untreated, growth_rate=growth_rate)
tau, tau_pv = runPhenoScoreByReps(
tau, tau_pv, tau_name = runPhenoScoreByReps(
self.adata, cond1=t0, cond2=treated, growth_rate=growth_rate)
rho, rho_pv = runPhenoScoreByReps(
rho, rho_pv, rho_name = runPhenoScoreByReps(
self.adata, cond1=untreated, cond2=treated, growth_rate=growth_rate)
targets = self.adata.var.index.str.split('_[-,+]_').str[0].to_list()

self.phenotypes[scoreLevel] = pd.concat({
'rho': convertResultsToDataFrame(self.adata, targets, rho, rho_pv),
'gamma': convertResultsToDataFrame(self.adata, targets, gamma, gamma_pv),
'tau': convertResultsToDataFrame(self.adata, targets, tau, tau_pv)
f'rho:{rho_name}': convertResultsToDataFrame(self.adata, targets, rho, rho_pv),
f'gamma:{gamma_name}': convertResultsToDataFrame(self.adata, targets, gamma, gamma_pv),
f'tau:{tau_name}': convertResultsToDataFrame(self.adata, targets, tau, tau_pv)
}, axis=1)

elif method == 'ByGuideSet':
Expand Down

0 comments on commit 2e45ed6

Please sign in to comment.