mioXpektron.analysis.prepare

Prepare feature matrices from pipeline or tabular outputs.

Functions

infer_feature_columns(df, *[, meta_cols])

Return non-metadata columns, attempting to detect m/z-like headers.

prepare_matrix(df, *[, label_col, ...])

Build a sample-by-feature matrix and group labels from pipeline output.

mioXpektron.analysis.prepare.prepare_matrix(df, *, label_col='Group', sample_col='SampleName', meta_cols=None, feature_cols=None, coerce_numeric=True, fill_na=0.0)[source]

Build a sample-by-feature matrix and group labels from pipeline output.

Accepts either:

  • A long table with SampleName / Group columns and m/z feature columns (typical exported CSV), or

  • An aligned matrix from align_peaks() where SampleName and optionally Group are index levels.

Parameters:
  • df (DataFrame) – Input table or aligned feature matrix.

  • label_col (str) – Column or index level containing group labels.

  • sample_col (str) – Column or index level containing sample identifiers.

  • meta_cols (Sequence[str] | None) – Additional metadata columns to exclude from features. Defaults to SampleName and Group only.

  • feature_cols (Sequence[str] | None) – Explicit feature column names. When omitted, all non-metadata columns are used.

  • coerce_numeric (bool) – If True, coerce feature columns to numeric (invalid values become NaN).

  • fill_na (float) – Value used to fill missing feature values after coercion.

Returns:

  • X – Feature matrix (samples x m/z), index aligned with meta.

  • y – Group labels indexed like X.

  • meta – Metadata frame with at least sample_col and label_col.

Return type:

Tuple[DataFrame, Series, DataFrame]

mioXpektron.analysis.prepare.infer_feature_columns(df, *, meta_cols=('SampleName', 'Group'))[source]

Return non-metadata columns, attempting to detect m/z-like headers.

Parameters:
Return type:

List[str]