mioXpektron.utils.analysis
Deprecated study-level analysis entry point.
Use mioXpektron.analysis instead. This module re-exports the public API
and keeps a CLI-compatible main() for legacy scripts.
Functions
|
|
|
Legacy CLI wrapper around |
- class mioXpektron.utils.analysis.AnalysisConfig(outdir='analysis_outputs', label_col='Group', sample_col='SampleName', group_a=None, group_b=None, reference_group=None, top_n_features=25, transform='log1p', random_state=0, embedding_methods=None, run_umap=False, run_tsne=False, umap_n_neighbors=15, umap_min_dist=0.1, tsne_perplexity=30.0, run_ml_benchmark=False, include_xgboost=True, ml_top_n_plot=10, run_ml_tuning=False, ml_tune_top_n=3, run_shap=False, run_cnmf=False, cnmf_k_list=None, cnmf_reps=30, cnmf_beta='frobenius', cnmf_top_features=15)[source]
Bases:
objectConfiguration for
AnalysisWorkflow.- Parameters:
outdir (str)
label_col (str)
sample_col (str)
group_a (str | None)
group_b (str | None)
reference_group (str | None)
top_n_features (int)
transform (str)
random_state (int)
run_umap (bool)
run_tsne (bool)
umap_n_neighbors (int)
umap_min_dist (float)
tsne_perplexity (float)
run_ml_benchmark (bool)
include_xgboost (bool)
ml_top_n_plot (int)
run_ml_tuning (bool)
ml_tune_top_n (int)
run_shap (bool)
run_cnmf (bool)
cnmf_reps (int)
cnmf_beta (str)
cnmf_top_features (int)
- class mioXpektron.utils.analysis.AnalysisWorkflow(data, config=None, *, models=None)[source]
Bases:
objectOrchestrate univariate stats, embeddings, ML, and optional cNMF.
- Parameters:
data (pd.DataFrame)
config (Optional[AnalysisConfig])
models (Optional[Mapping[str, Any]])
- mioXpektron.utils.analysis.bh_fdr(pvals)[source]
Benjamini–Hochberg FDR correction for a 1D array of p-values.
- mioXpektron.utils.analysis.choose_k_by_pac(results)[source]
Select the rank with the lowest PAC score.
- mioXpektron.utils.analysis.compute_univariate_tests(X, y, *, group_a=None, group_b=None, reference_group=None, eps=1e-12)[source]
Welch t-test per feature with log2 fold-change (group_a / group_b).
When
group_aandgroup_bare omitted, the two largest groups by sample count are compared.reference_groupsets the denominator for log2 fold-change and defaults togroup_b.
- mioXpektron.utils.analysis.main(input_file, outdir, topn=25, umap=False, tsne=False, shap=False, cnmf=False, k_list=None, cnmf_reps=30, cnmf_beta='frobenius', ml_benchmark=False, ml_tuning=False)[source]
Legacy CLI wrapper around
AnalysisWorkflow.
- mioXpektron.utils.analysis.plot_heatmap_top_features(X, y, res, savepath, *, top_n=25, label_col='Group')[source]
Heatmap of top differential features (z-scored), samples ordered by group.
- mioXpektron.utils.analysis.plot_pca(X_scaled, y, savepath, *, random_state=0)[source]
PCA scatter plot coloured by group labels.
- mioXpektron.utils.analysis.plot_umap(X_scaled, y, savepath, *, n_neighbors=15, min_dist=0.1, random_state=0)[source]
UMAP embedding plot when umap-learn is installed.
- mioXpektron.utils.analysis.plot_volcano(res, savepath, *, group_a=None, group_b=None, q_thresh=0.05, fc_thresh=1.0)[source]
Volcano plot of log2 fold-change versus -log10(p-value).
- mioXpektron.utils.analysis.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:
- mioXpektron.utils.analysis.run_cnmf(X_pos, k_list, *, R=30, max_iter=1000, beta='frobenius', random_seeds=None, outdir=None)[source]
Run consensus NMF across multiple rank values.