Skip to content

GEX MIL Pipeline

--workflow gex_mil

Ingests Seurat objects, exports 10x-like count matrices, merges per-sample counts into a joint AnnData, then trains an scVI + attention-MIL model for subject-level classification from gene expression profiles. GPU required.

Samplesheet requirement: Must include a SubjectId column for MIL bag construction (donor-level training split).


Stage-by-stage dataflow

Stage Module Input Output Compute
INGEST rdiscvr/ingest_* LabKey / URL / local file {sample_id}.rds CPU
EXPORT_COUNTS cellmembrane/seurat Seurat RDS {sample_id}_counts/ CPU
GEX_MERGE_COUNTS mil_ton/gex_merge Collected count directories merged_gex.h5ad (cell × gene AnnData) + cell_metadata.csv CPU
TRAIN_GEX_MIL mil_ton/train_gex_mil merged_gex.h5ad Trained MIL model, predictions, loss curves GPU

Container images

  • ghcr.io/gwmcelfresh/mil-ton:latest — contains GEX merge + MIL training code

Parameters

Parameter Default Description
--scvi_latent 50 scVI latent dimension
--scvi_epochs 200 scVI training epochs
--mil_lr 1e-3 MIL learning rate
--mil_epochs 100 MIL training epochs
--milton_donor_col SubjectId Column identifying donors for MIL bag construction
--milton_label_col disease_status Target label column
--milton_cells_per_donor 2000 Max cells sampled per donor

Outputs

outputs/gex_mil/:

File Description
merged_gex.h5ad Joint cell × gene AnnData with scVI latent embedding
mil_model.pt Trained attention-MIL model checkpoint
mil_predictions.csv Per-donor predictions and attention weights
loss_history.png Training/validation loss curves

Running locally

bash template/gw/run.sh --workflow gex_mil

Requires samplesheet with SubjectId column. Use the default samplesheet.csv generated by fetch_example_data.sh.

For the generated code-level reference, see API Reference → Workflows.