spamosaic.framework.SpaMosaic

class spamosaic.framework.SpaMosaic(modBatch_dict={}, input_key='dimred_bc', mnn_rep_key=None, batch_key='batch', radius_cutoff=2000, intra_knns=10, inter_knn_base=10, smooth_input=False, smooth_L=1, inter_auto_knn=False, inter_auto_thr=0.8, rmv_outlier=False, contamination='auto', w_g=0.8, log_dir=None, seed=1234, num_workers=6, device='cuda:0')[source]

SpaMosaic: a modular framework for multi-modal spatial omics integration.

This class orchestrates data pre-processing, intra- and inter-batch graph construction, optional feature smoothing, model initialization/training, cross-modality alignment, and downstream embedding/imputation.

Parameters:
  • modBatch_dict (dict) – Mapping modality name (e.g., 'rna', 'adt') to a list of AnnData batches. Example: {'rna': [batch1, None, ...], 'adt': [batch1, batch2, ...]}.

  • input_key (str) – Key in .obsm where input features are stored (e.g., 'dimred_bc').

  • mnn_rep_key (str, optional) – Representation key used for MNN search. If None, defaults to input_key.

  • batch_key (str) – Column name in .obs denoting batch identity.

  • radius_cutoff (int) – Radius threshold used to construct spatial neighbor graphs.

  • intra_knns (int or list of int) – Number of neighbors for intra-batch graphs (single int or per-batch list).

  • inter_knn_base (int) – Base KNN size for inter-batch MNN search.

  • smooth_input (bool) – If True, apply WLGCN-based input feature smoothing.

  • smooth_L (int) – Number of WLGCN layers used for smoothing.

  • inter_auto_knn (bool) – If True, adapt inter-batch KNN size based on batch-size ratio.

  • inter_auto_thr (float) – Size-ratio threshold for adaptive KNN.

  • rmv_outlier (bool) – If True, remove outlier MNN pairs via Isolation Forest.

  • contamination (str or float) – Contamination level for outlier detection (IsolationForest).

  • w_g (float) – Weight for inter-batch expression edges in the merged graph.

  • log_dir (str, optional) – Directory for saving logs or results.

  • seed (int) – Random seed.

  • num_workers (int) – Number of workers for computation.

  • device (str) – Device string, e.g., 'cuda:0' or 'cpu'.