multiblock-pls-model-fitting
Summary
Fit a Multi-Block Partial Least Squares (MB-PLS) discriminant model to integrate and analyze multi-assay LC-MS metabolomics blocks (e.g., HPOS, LPOS, LNEG) for classification or regression tasks. MB-PLS leverages the NIPALS algorithm to model covariance structure across blocks while predicting a single response variable.
When to use
You have split multi-assay LC-MS intensity data into training (90%) and test (10%) subsets with assay-specific column prefixes, and you need to fit a discriminant or regression model that respects the block structure (separate assays) while jointly predicting a phenotypic outcome (e.g., disease status, gender) encoded as numeric Y.
When NOT to use
- Input is already a single aggregated feature table (not multi-block or multi-assay)
- Response variable is continuous and you require prediction intervals or heteroscedastic uncertainty quantification (use regression instead of discriminant model)
- Sample sizes are <50 per class (k-fold cross-validation with n_splits=5 becomes unstable)
Inputs
- List of pandas DataFrames (one per assay block, e.g., [HPOS_train, LPOS_train, LNEG_train])
- Numeric response vector (y_train: encoded phenotype, e.g., 1 for female, 0 for male)
- Training data split fraction (default 90%)
- Assay-specific column name prefixes (e.g., 'HPOS_', 'LPOS_', 'LNEG_')
Outputs
- Fitted MamsiPls model object with learned loadings and latent variable weights
- Optimal number of latent variables identified by cross-validation
- Model performance metrics on test set (accuracy, recall, specificity, F1-score, AUC)
- MB-PLS latent variable scores for downstream interpretation
How to apply
Instantiate MamsiPls with n_components=1 (or a small integer), then call fit([block1, block2, block3], y) where each block is a pandas DataFrame with unit-variance standardization (standardize=True) applied. The NIPALS algorithm iteratively fits latent variables across blocks. After fitting, use estimate_lv() with k-fold cross-validation (n_splits=5) and AUC metric to identify the optimal number of latent variables, stopping when the plateau_threshold (e.g., 0.01) is reached. Refit the model with the optimal component count and evaluate on the held-out test set using evaluate_class_model() to record accuracy, recall, specificity, F1-score, and AUC.
Related tools
- mbpls (Provides the MamsiPls class wrapping the MB_PLS NIPALS algorithm for multi-block PLS model fitting) — https://github.com/kopeckylukas/py-mamsi
- scikit-learn (train_test_split() for stratified train/test data partitioning; provides AUC metric for cross-validation)
- pandas (Loads and structures multi-assay LC-MS intensity data; applies column name prefixes; concatenates blocks)
- numpy (Numerical array operations for internal NIPALS iterations and latent variable computations)
Examples
from mamsi.mamsi_pls import MamsiPls
mamsipls = MamsiPls(n_components=1)
mamsipls.fit([hpos_train, lpos_train, lneg_train], y_train)
mamsipls.estimate_lv([hpos_train, lpos_train, lneg_train], y_train, metric='auc')
metrics = mamsipls.evaluate_class_model([hpos_test, lpos_test, lneg_test], y_test)
Evaluation signals
- Cross-validation AUC curve plateaus (change < plateau_threshold=0.01) and indicates a clear optimal number of latent variables
- Test set AUC, accuracy, and F1-score are within expected ranges for the phenotype (e.g., AUC > 0.70 for binary classification)
- Model loadings (weights) on each block are non-zero and interpretable in the context of known metabolic pathways
- Latent variable scores are orthogonal (zero correlation) across components
- MB-VIP scores computed from the fitted model show expected feature importance ranking (significant metabolites rank higher than background features)
Limitations
- NIPALS is iterative and sensitive to initialization; reproducibility requires setting random_state or seed consistently
- Assumes block structures (assays) are balanced in sample size; severe imbalance may bias latent variable estimation toward larger blocks
- Unit-variance standardization (standardize=True) assumes all features on similar scales; highly skewed or long-tailed metabolite intensities may require prior log-transformation or robust scaling
- Model does not account for missing data; all blocks must have complete cases for each sample
- Optimal latent variable count is data-dependent and dataset-specific; no universal recommendation provided in the literature
Evidence
- [methods] Fit MB-PLS discriminant model on training data using MamsiPls with NIPALS algorithm and unit-variance standardization (standardize=True): "Fit MB-PLS discriminant model on training data using MamsiPls with NIPALS algorithm and unit-variance standardization (standardize=True)."
- [methods] Estimate optimal number of latent variables using k-fold cross-validation (n_splits=5) with AUC metric via MamsiPls.estimate_lv(), identifying the model plateau threshold (plateau_threshold=0.01): "Estimate optimal number of latent variables using k-fold cross-validation (n_splits=5) with AUC metric via MamsiPls.estimate_lv(), identifying the model plateau threshold (plateau_threshold=0.01)."
- [methods] Refit MB-PLS with optimal latent variable count and evaluate on independent test set using MamsiPls.evaluate_class_model(), recording accuracy, recall, specificity, F1-score, and AUC: "Refit MB-PLS with optimal latent variable count and evaluate on independent test set using MamsiPls.evaluate_class_model(), recording accuracy, recall, specificity, F1-score, and AUC."
- [readme] MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets: "MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets."
- [readme] mamsipls = MamsiPls(n_components=1); mamsipls.fit([hpos, lpos, lneg], y): "mamsipls = MamsiPls(n_components=1)
mamsipls.fit([hpos, lpos, lneg], y)"
- [readme] Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) algorithm: "Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) algorithm."
1---2name: multiblock-pls-model-fitting3description: Use when you have split multi-assay LC-MS intensity data into training (90%) and test (10%) subsets with assay-specific column prefixes, and you need to fit a discriminant or regression model that respects the block structure (separate assays) while jointly predicting a phenotypic outcome (e.4license: CC-BY-4.05---67# multiblock-pls-model-fitting89## Summary1011Fit a Multi-Block Partial Least Squares (MB-PLS) discriminant model to integrate and analyze multi-assay LC-MS metabolomics blocks (e.g., HPOS, LPOS, LNEG) for classification or regression tasks. MB-PLS leverages the NIPALS algorithm to model covariance structure across blocks while predicting a single response variable.1213## When to use1415You have split multi-assay LC-MS intensity data into training (90%) and test (10%) subsets with assay-specific column prefixes, and you need to fit a discriminant or regression model that respects the block structure (separate assays) while jointly predicting a phenotypic outcome (e.g., disease status, gender) encoded as numeric Y.1617## When NOT to use1819- Input is already a single aggregated feature table (not multi-block or multi-assay)20- Response variable is continuous and you require prediction intervals or heteroscedastic uncertainty quantification (use regression instead of discriminant model)21- Sample sizes are <50 per class (k-fold cross-validation with n_splits=5 becomes unstable)2223## Inputs2425- List of pandas DataFrames (one per assay block, e.g., [HPOS_train, LPOS_train, LNEG_train])26- Numeric response vector (y_train: encoded phenotype, e.g., 1 for female, 0 for male)27- Training data split fraction (default 90%)28- Assay-specific column name prefixes (e.g., 'HPOS_', 'LPOS_', 'LNEG_')2930## Outputs3132- Fitted MamsiPls model object with learned loadings and latent variable weights33- Optimal number of latent variables identified by cross-validation34- Model performance metrics on test set (accuracy, recall, specificity, F1-score, AUC)35- MB-PLS latent variable scores for downstream interpretation3637## How to apply3839Instantiate MamsiPls with n_components=1 (or a small integer), then call fit([block1, block2, block3], y) where each block is a pandas DataFrame with unit-variance standardization (standardize=True) applied. The NIPALS algorithm iteratively fits latent variables across blocks. After fitting, use estimate_lv() with k-fold cross-validation (n_splits=5) and AUC metric to identify the optimal number of latent variables, stopping when the plateau_threshold (e.g., 0.01) is reached. Refit the model with the optimal component count and evaluate on the held-out test set using evaluate_class_model() to record accuracy, recall, specificity, F1-score, and AUC.4041## Related tools4243- **mbpls** (Provides the MamsiPls class wrapping the MB_PLS NIPALS algorithm for multi-block PLS model fitting) — https://github.com/kopeckylukas/py-mamsi44- **scikit-learn** (train_test_split() for stratified train/test data partitioning; provides AUC metric for cross-validation)45- **pandas** (Loads and structures multi-assay LC-MS intensity data; applies column name prefixes; concatenates blocks)46- **numpy** (Numerical array operations for internal NIPALS iterations and latent variable computations)4748## Examples4950```51from mamsi.mamsi_pls import MamsiPls52mamsipls = MamsiPls(n_components=1)53mamsipls.fit([hpos_train, lpos_train, lneg_train], y_train)54mamsipls.estimate_lv([hpos_train, lpos_train, lneg_train], y_train, metric='auc')55metrics = mamsipls.evaluate_class_model([hpos_test, lpos_test, lneg_test], y_test)56```5758## Evaluation signals5960- Cross-validation AUC curve plateaus (change < plateau_threshold=0.01) and indicates a clear optimal number of latent variables61- Test set AUC, accuracy, and F1-score are within expected ranges for the phenotype (e.g., AUC > 0.70 for binary classification)62- Model loadings (weights) on each block are non-zero and interpretable in the context of known metabolic pathways63- Latent variable scores are orthogonal (zero correlation) across components64- MB-VIP scores computed from the fitted model show expected feature importance ranking (significant metabolites rank higher than background features)6566## Limitations6768- NIPALS is iterative and sensitive to initialization; reproducibility requires setting random_state or seed consistently69- Assumes block structures (assays) are balanced in sample size; severe imbalance may bias latent variable estimation toward larger blocks70- Unit-variance standardization (standardize=True) assumes all features on similar scales; highly skewed or long-tailed metabolite intensities may require prior log-transformation or robust scaling71- Model does not account for missing data; all blocks must have complete cases for each sample72- Optimal latent variable count is data-dependent and dataset-specific; no universal recommendation provided in the literature7374## Evidence7576- [methods] Fit MB-PLS discriminant model on training data using MamsiPls with NIPALS algorithm and unit-variance standardization (standardize=True): "Fit MB-PLS discriminant model on training data using MamsiPls with NIPALS algorithm and unit-variance standardization (standardize=True)."77- [methods] Estimate optimal number of latent variables using k-fold cross-validation (n_splits=5) with AUC metric via MamsiPls.estimate_lv(), identifying the model plateau threshold (plateau_threshold=0.01): "Estimate optimal number of latent variables using k-fold cross-validation (n_splits=5) with AUC metric via MamsiPls.estimate_lv(), identifying the model plateau threshold (plateau_threshold=0.01)."78- [methods] Refit MB-PLS with optimal latent variable count and evaluate on independent test set using MamsiPls.evaluate_class_model(), recording accuracy, recall, specificity, F1-score, and AUC: "Refit MB-PLS with optimal latent variable count and evaluate on independent test set using MamsiPls.evaluate_class_model(), recording accuracy, recall, specificity, F1-score, and AUC."79- [readme] MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets: "MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets."80- [readme] mamsipls = MamsiPls(n_components=1); mamsipls.fit([hpos, lpos, lneg], y): "mamsipls = MamsiPls(n_components=1)81mamsipls.fit([hpos, lpos, lneg], y)"82- [readme] Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) algorithm: "Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) algorithm."