acore.differential_regulation package#
Differential regulation module.
- run_anova(df: DataFrame, alpha: float = 0.05, drop_cols: list[str] = ['sample', 'subject'], subject: str = 'subject', group: str = 'group', permutations: int = 0, correction: str = 'fdr_bh', is_logged: bool = True, non_par: bool = False) DataFrame[AnovaSchema] | DataFrame[AnovaSchemaMultiGroup][source]#
Performs statistical test for each protein in a dataset. Checks what type of data is the input (paired, unpaired or repeated measurements) and performs posthoc tests for multiclass data (i.e., when there are more than two groups, posthoc tests such as pairwise t-tests or Tukey’s HSD are used to determine which specific groups differ after finding a significant overall effect). Multiple hypothesis correction uses permutation-based if permutations>0 and Benjamini/Hochberg if permutations=0.
- Parameters:
df (pd.DataFrame) – pandas dataframe with samples as rows and protein identifiers as columns (with additional columns ‘group’, ‘sample’ and ‘subject’).
alpha (float) – error rate for multiple hypothesis correction
drop_cols (list) – column labels to be dropped from the dataframe
subject (str) – column with subject identifiers
group (str) – column with group identifiers
permutations (int) – number of permutations used to estimate false discovery rates.
correction (str) – method of pvalue correction see apply_pvalue_correction for methods, use methods available in acore.multiple_testing
is_logged (bool) – whether data is log-transformed
non_par (bool) – if True, normality and variance equality assumptions are checked and non-parametric test Mann Whitney U test if not passed
- Returns:
DataFrame adhering to AnovaSchema or AnovaSchemaMultiGroup.
- Return type:
DataFrame[AnovaSchema] | DataFrame[AnovaSchemaMultiGroup]
Example:
result = run_anova(df, alpha=0.05, drop_cols=["sample",'subject'], subject='subject', group='group', permutations=50 )
- run_ancova(df: DataFrame, covariates: list[str], alpha: float = 0.05, drop_cols: list[str] = ['sample', 'subject'], subject: str = 'subject', group: str = 'group', permutations: int = 0, correction: str = 'fdr_bh', is_logged: bool = True, non_par: bool = False) DataFrame[AncovaSchema][source]#
Performs statistical test for each protein in a dataset. Checks what type of data is the input (paired, unpaired or repeated measurements) and performs posthoc tests for multiclass data. Multiple hypothesis correction uses permutation-based if permutations>0 and Benjamini/Hochberg if permutations=0.
- Parameters:
df (pd.DataFrame) – Pandas DataFrame with samples as rows and protein identifiers and covariates as columns (with additional columns ‘group’, ‘sample’ and ‘subject’).
covariates (list) – list of covariates to include in the model (column in df)
alpha (float) – error rate for multiple hypothesis correction
drop_cols (list) – column labels to be dropped from the DataFrame
subject (str) – column with subject identifiers
group (str) – column with group identifiers
permutations (int) – number of permutations used to estimate false discovery rates.
correction (str) – method of pvalue correction see apply_pvalue_correction for methods, use methods available in acore.multiple_testing
is_logged (bool) – whether data is log-transformed
non_par (bool) – if True, normality and variance equality assumptions are checked and non-parametric test Mann Whitney U test if not passed
- Returns:
DataFrame adhering to AncovaSchema
- Return type:
DataFrame[AncovaSchema]
Example:
result = run_ancova(df, covariates=['age'], alpha=0.05, drop_cols=["sample",'subject'], subject='subject', group='group', permutations=50 )
- run_diff_analysis(df: DataFrame, boolean_array: Series, event_names: tuple[str, str] = ('1', '0'), ttest_vars=('alternative', 'p-val', 'cohen-d')) DataFrame[source]#
Differential analysis procedure between two groups. Calculaes mean per group and t-test for each variable in vars between two groups.
- run_mixed_anova(df, alpha=0.05, drop_cols=['sample'], subject='subject', within='group', between='group2', correction='fdr_bh')[source]#
In statistics, a mixed-design analysis of variance model, also known as a split-plot ANOVA, is used to test for differences between two or more independent groups whilst subjecting participants to repeated measures. Thus, in a mixed-design ANOVA model, one factor (a fixed effects factor) is a between-subjects variable and the other (a random effects factor) is a within-subjects variable. Thus, overall, the model is a type of mixed-effects model (source)
- Parameters:
df (pd.DataFrame) – Pandas DataFrame with samples as rows and protein identifiers as columns (with additional columns ‘group’, ‘sample’ and ‘subject’).
alpha (float) – error rate for multiple hypothesis correction
drop_cols (list) – column labels to be dropped from the DataFrame
subject (str) – column with subject identifiers
within (str) – column with within factor identifiers
between (str) – column with between factor identifiers
correction (str) – method of pvalue correction see apply_pvalue_correction for methods, use methods available in acore.multiple_testing
- Returns:
Pandas DataFrame
- Return type:
pd.DataFrame
Example:
result = run_mixed_anova(df, alpha=0.05, drop_cols=['sample'], subject='subject', within='group', between='group2', )
- run_repeated_measurements_anova(df, alpha=0.05, drop_cols=['sample'], subject='subject', within='group', permutations=50, correction='fdr_bh', is_logged=True) DataFrame[source]#
Performs repeated measurements anova and pairwise posthoc tests for each protein in dataframe.
- Parameters:
df (pd.DataFrame) – Pandas DataFrame with samples as rows and protein identifiers as columns (with additional columns ‘group’, ‘sample’ and ‘subject’).
alpha (float) – error rate for multiple hypothesis correction
drop_cols (list) – column labels to be dropped from the DataFrame
subject (str) – column with subject identifiers
within (str) – column with within factor identifiers
permutations (int) – number of permutations used to estimate false discovery rates
correction (str) – method of pvalue correction see apply_pvalue_correction for methods, use methods available in acore.multiple_testing
is_logged (bool) – whether data is log-transformed
- Returns:
Pandas DataFrame
Example:
result = run_repeated_measurements_anova(df, alpha=0.05, drop_cols=['sample'], subject='subject', within='group', permutations=50 )
- run_ttest(df, condition1, condition2, alpha=0.05, drop_cols=['sample'], subject='subject', group='group', paired=False, correction='fdr_bh', permutations=0, is_logged=True, non_par=False)[source]#
Runs t-test (paired/unpaired) for each protein in dataset and performs permutation-based (if permutations>0) or Benjamini/Hochberg (if permutations=0) multiple hypothesis correction.
- Parameters:
df (pd.DataFrame) – Pandas DataFrame with samples as rows and protein identifiers as columns (with additional columns ‘group’, ‘sample’ and ‘subject’).
condition1 (str) – first of two conditions of the independent variable
condition2 (str) – second of two conditions of the independent variable
alpha (float) – error rate for multiple hypothesis correction
drop_cols (list) – column labels to be dropped from the DataFrame
subject (str) – column with subject identifiers
group (str) – column with group identifiers (independent variable)
paired (bool) – paired or unpaired samples
correction (str) – method of pvalue correction see apply_pvalue_correction for methods
permutations (int) – number of permutations used to estimate false discovery rates.
is_logged (bool) – data is log-transformed
non_par (bool) – if True, normality and variance equality assumptions are checked and non-parametric test Mann Whitney U test if not passed
- Returns:
Pandas DataFrame with columns ‘identifier’, ‘group1’, ‘group2’, ‘mean(group1)’, ‘mean(group2)’, ‘std(group1)’, ‘std(group2)’, ‘Log2FC’, ‘FC’, ‘rejected’, ‘T-statistics’, ‘p-value’, ‘correction’, ‘-log10 p-value’, and ‘method’.
Example:
result = run_ttest(df, condition1='group1', condition2='group2', alpha = 0.05, drop_cols=['sample'], subject='subject', group='group', paired=False, correction='fdr_bh', permutations=50 )
- run_two_way_anova(df, drop_cols=['sample'], subject='subject', group=['group', 'secondary_group'])[source]#
Run a 2-way ANOVA when data[‘secondary_group’] is not empty
- Parameters:
- Returns:
Two DataFrames, anova results and residuals.
Example:
result = run_two_way_anova(data, drop_cols=['sample'], subject='subject', group=['group', 'secondary_group'] )
Submodules#
- acore.differential_regulation.format_test_table module
- acore.differential_regulation.tests module
calc_means_between_groups()calc_ttest()calculate_ttest()calculate_thsd()calculate_pairwise_ttest()complement_posthoc()calculate_anova()calculate_ancova()calculate_repeated_measures_anova()calculate_mixed_anova()pairwise_ttest_with_covariates()format_anova_table()calculate_pvalue_from_tstats()eta_squared()omega_squared()