scmidas.api

Contents

scmidas.api#

High-level conveniences on top of the MIDAS class.

scmidas.api.integrate(mdata: MuData, *, batch_key: str = 'batch', max_epochs: int | None = None, batch_size: int | None = None, accelerator: str = 'auto', devices: Any = 1, strategy: str = 'auto', save_model_path: str = './saved_models/scmidas', seed: int | None = 42, key_added: str = 'X_midas', **kwargs: Any) MIDAS[source]#

One-call MIDAS pipeline for users who want a sensible default.

Equivalent to:

scmidas.MIDAS.setup_mudata(mdata, batch_key=batch_key)
model = scmidas.MIDAS(mdata, configs=..., batch_size=..., ...)
model.train(max_epochs=..., accelerator=..., ...)
mdata.obsm[key_added] = model.get_latent_representation()

Warning

The default training hyperparameters (batch_size=128, max_epochs=65, lr=3e-4) are tuned for the toy quickstart dataset (1600 cells). They are not appropriate for real analyses — for full datasets pass your own max_epochs (typically 1000-2000) and consider letting batch_size default back to 256.

Parameters:
  • mdata – MuData Multi-modal single-cell data.

  • batch_key – str Column in each modality’s .obs that identifies the source batch.

  • max_epochs – int, optional Training epochs. Default 65 (quickstart-tuned). For real data, override with 1000-2000.

  • batch_size – int, optional Mini-batch size. Default 128 (quickstart-tuned). For real data, 256 is a more typical choice.

  • accelerator – Forwarded to lightning.Trainer. Default 'auto' picks GPU if available.

  • devices – Forwarded to lightning.Trainer. Default 'auto' picks GPU if available.

  • strategy – Forwarded to lightning.Trainer. Default 'auto' picks GPU if available.

  • save_model_path – str Where to write checkpoints during training.

  • seed – int, optional If not None, calls lightning.seed_everything(seed) before setup, so the run is reproducible.

  • key_added – str Key under which the biological latent z_c is written to mdata.obsm. Defaults to 'X_midas' so that sc.pp.neighbors(mdata, use_rep='X_midas') works without further arguments.

  • **kwargs – Additional keyword arguments forwarded to MIDAS(...).

Returns:

A trained MIDAS model. The biological latent has already been written to mdata.obsm[key_added].

Return type:

MIDAS