Skip to content

Commit

Permalink
improve Docstrings
Browse files Browse the repository at this point in the history
related to #41
  • Loading branch information
abearab committed Apr 6, 2024
1 parent 2c10b93 commit ef37050
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions screenpro/phenoScore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@


def calculateDelta(x, y, math, level):
"""
Calculate log ratio of y / x.
"""Calculate log ratio of y / x.
`level` == 'all' (i.e. averaged across all values, oligo and replicates)
`level` == 'col' (i.e. averaged across columns, replicates)
Parameters:
Args:
x (np.array): array of values
y (np.array): array of values
math (str): math to use for calculating score
Expand Down Expand Up @@ -55,10 +54,9 @@ def calculateDelta(x, y, math, level):


def calculatePhenotypeScore(x, y, x_ctrl, y_ctrl, growth_rate, math, level):
"""
Calculate phenotype score normalized by negative control and growth rate.
"""Calculate phenotype score normalized by negative control and growth rate.
Parameters:
Args:
x (np.array): array of values
y (np.array): array of values
x_ctrl (np.array): array of values
Expand All @@ -81,10 +79,9 @@ def calculatePhenotypeScore(x, y, x_ctrl, y_ctrl, growth_rate, math, level):


def matrixTest(x, y, x_ctrl, y_ctrl, math, level, test = 'ttest', growth_rate = 1):
"""
Calculate phenotype score and p-values comparing `y` vs `x` matrices.
"""Calculate phenotype score and p-values comparing `y` vs `x` matrices.
Parameters:
Args:
x (np.array): array of values
y (np.array): array of values
x_ctrl (np.array): array of values
Expand Down Expand Up @@ -114,10 +111,9 @@ def matrixTest(x, y, x_ctrl, y_ctrl, math, level, test = 'ttest', growth_rate =
def runPhenoScore(adata, cond1, cond2, math, score_level, test,
growth_rate=1, n_reps=2, keep_top_n = None,num_pseudogenes=None,
get_z_score=False,ctrl_label='negCtrl'):
"""
Calculate phenotype score and p-values when comparing `cond2` vs `cond1`.
"""Calculate phenotype score and p-values when comparing `cond2` vs `cond1`.
Parameters:
Args:
adata (AnnData): AnnData object
cond1 (str): condition 1
cond2 (str): condition 2
Expand Down Expand Up @@ -269,10 +265,9 @@ def runPhenoScore(adata, cond1, cond2, math, score_level, test,


def seqDepthNormalization(adata):
"""
Normalize counts by sequencing depth.
"""Normalize counts by sequencing depth.
Parameters:
Args:
adata (AnnData): AnnData object
"""
# normalize counts by sequencing depth
Expand Down Expand Up @@ -306,7 +301,7 @@ def addPseudoCount():
def calculateZScorePhenotypeScore(score_df,ctrl_label='negCtrl'):
"""Calculate z-score normalized phenotype score.
Parameters:
Args:
score_df (pd.DataFrame): dataframe of scores that includes `score` and `targetType` columns
ctrl_label (str): control label, default is 'negCtrl'
Expand All @@ -322,10 +317,9 @@ def calculateZScorePhenotypeScore(score_df,ctrl_label='negCtrl'):


def runPhenoScoreForReplicate(screen, x_label, y_label, score, growth_factor_table, get_z_score=False, ctrl_label='negCtrl'):
"""
Calculate phenotype score for each pair of replicates.
"""Calculate phenotype score for each pair of replicates.
Parameters:
Args:
screen: ScreenPro object
x_label: name of the first condition in column `condition` of `screen.adata.obs`
y_label: name of the second condition in column `condition` of `screen.adata.obs`
Expand Down Expand Up @@ -373,10 +367,9 @@ def runPhenoScoreForReplicate(screen, x_label, y_label, score, growth_factor_tab


def generatePseudoGeneLabels(adata, num_pseudogenes=None, ctrl_label='negCtrl'):
"""
Generate new labels per `num_pseudogenes` randomly selected non targeting oligo in `adata.var`.
"""Generate new labels per `num_pseudogenes` randomly selected non targeting oligo in `adata.var`.
Parameters:
Args:
adata (AnnData): AnnData object
num_pseudogenes (int): number of pseudogenes
ctrl_label (str): control label
Expand Down

0 comments on commit ef37050

Please sign in to comment.