proteometer.stats#

Classes#

Functions#

recalculate_adj_pval(df, comparisons)

Recalculates adjusted p-values for specified comparisons.

recalculate_adj_pval_proteinwise(df, comparisons[, ...])

Recalculates adjusted p-values for specified comparisons, computed protein-wise.

log2_transformation(→ pandas.DataFrame)

Applies log2 transformation to specified intensity columns in a DataFrame.

anova(→ pandas.DataFrame)

Performs ANOVA on specified columns of a DataFrame.

pairwise_ttest(→ pandas.DataFrame)

Performs pairwise t-tests for specified treatment and control groups.

calculate_pairwise_scalars(→ pandas.DataFrame)

Calculates pairwise scalars based on significance thresholds.

calculate_all_pairwise_scalars(→ pandas.DataFrame)

Calculates pairwise scalars for all specified t-test groups.

Module Contents#

class proteometer.stats.TTestGroup[source]#
treat_group: str[source]#
control_group: str[source]#
treat_samples: collections.abc.Sequence[str][source]#
control_samples: collections.abc.Sequence[str][source]#
label()[source]#
proteometer.stats.recalculate_adj_pval(df: pandas.DataFrame, comparisons: list[str])[source]#

Recalculates adjusted p-values for specified comparisons.

Parameters:
  • df (pd.DataFrame) – DataFrame containing p-values and adjusted p-values.

  • comparisons (list[str]) – List of comparison names. Each comparison should have a p-value and adjusted p-value indicated by a “_pval” and “_adj-p” suffix, respectively.

Returns:

DataFrame with recalculated adjusted p-values.

Return type:

pd.DataFrame

proteometer.stats.recalculate_adj_pval_proteinwise(df: pandas.DataFrame, comparisons: list[str], protein_col: str = 'Protein')[source]#

Recalculates adjusted p-values for specified comparisons, computed protein-wise.

See: - Schopper et al. Nature Protocols, 12(11):2391-2410, October 2017. - Nagel et al. Cellular Proteomics, 24(4):100934, April 2025.

Parameters:
  • df (pd.DataFrame) – DataFrame containing p-values and adjusted p-values.

  • comparisons (list[str]) – List of comparison names. Each comparison should have a p-value and adjusted p-value indicated by a “_pval” and “_adj-p” suffix, respectively.

Returns:

DataFrame with recalculated adjusted p-values.

Return type:

pd.DataFrame

proteometer.stats.log2_transformation(df2transform: pandas.DataFrame, int_cols: collections.abc.Sequence[str]) pandas.DataFrame[source]#

Applies log2 transformation to specified intensity columns in a DataFrame.

Parameters:
  • df2transform (pd.DataFrame) – DataFrame containing the data to transform.

  • int_cols (Sequence[str]) – List of intensity column names to apply the transformation.

Returns:

DataFrame with log2-transformed intensity columns.

Return type:

pd.DataFrame

proteometer.stats.anova(df: pandas.DataFrame, anova_cols: list[str], metadata: pandas.DataFrame, anova_factors: collections.abc.Sequence[str], sample_col: str) pandas.DataFrame[source]#

Performs ANOVA on specified columns of a DataFrame.

Parameters:
  • df (pd.DataFrame) – DataFrame containing the data for analysis.

  • anova_cols (list[str]) – List of column names to analyze.

  • metadata (pd.DataFrame) – Metadata containing sample information.

  • anova_factors (Sequence[str], optional) – Factors for ANOVA analysis.

  • sample_col (str, optional) – Column name for sample identifiers.

Returns:

DataFrame with ANOVA p-values and adjusted p-values.

Return type:

pd.DataFrame

proteometer.stats.pairwise_ttest(df: pandas.DataFrame, pairwise_ttest_groups: collections.abc.Iterable[TTestGroup]) pandas.DataFrame[source]#

Performs pairwise t-tests for specified treatment and control groups.

Parameters:
  • df (pd.DataFrame) – DataFrame containing the data for analysis.

  • pairwise_ttest_groups (Iterable[TTestGroup]) – Iterable of TTestGroup objects defining the groups.

Returns:

DataFrame with t-test results, including p-values and adjusted p-values.

Return type:

pd.DataFrame

proteometer.stats.calculate_pairwise_scalars(prot: pandas.DataFrame, pairwise_ttest_name: str | None = None, sig_type: str = 'pval', sig_thr: float = 0.05) pandas.DataFrame[source]#

Calculates pairwise scalars based on significance thresholds.

Parameters:
  • prot (pd.DataFrame) – DataFrame containing pairwise t-test results.

  • pairwise_ttest_name (str | None, optional) – Name of the pairwise t-test column. Defaults to None.

  • sig_type (str, optional) – Type of significance metric (e.g., “pval”). Defaults to “pval”.

  • sig_thr (float, optional) – Significance threshold. Defaults to 0.05.

Returns:

DataFrame with calculated scalars.

Return type:

pd.DataFrame

proteometer.stats.calculate_all_pairwise_scalars(prot: pandas.DataFrame, pairwise_ttest_groups: collections.abc.Iterable[TTestGroup], sig_type: str = 'pval', sig_thr: float = 0.05) pandas.DataFrame[source]#

Calculates pairwise scalars for all specified t-test groups.

Parameters:
  • prot (pd.DataFrame) – DataFrame containing pairwise t-test results.

  • pairwise_ttest_groups (Iterable[TTestGroup]) – Iterable of TTestGroup objects defining the groups.

  • sig_type (str, optional) – Type of significance metric (e.g., “pval”). Defaults to “pval”.

  • sig_thr (float, optional) – Significance threshold. Defaults to 0.05.

Returns:

DataFrame with calculated scalars for all groups.

Return type:

pd.DataFrame