mioXpektron.analysis.prepare
Prepare feature matrices from pipeline or tabular outputs.
Functions
|
Return non-metadata columns, attempting to detect m/z-like headers. |
|
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/Groupcolumns and m/z feature columns (typical exported CSV), orAn aligned matrix from
align_peaks()whereSampleNameand optionallyGroupare 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
SampleNameandGrouponly.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_colandlabel_col.
- Return type: