scembed.methods.ResolVIMethod#
- class scembed.methods.ResolVIMethod(adata, n_hidden=None, n_hidden_encoder=None, n_latent=None, n_layers=None, dropout_rate=None, dispersion=None, gene_likelihood=None, background_ratio=None, median_distance=None, semisupervised=False, mixture_k=None, downsample_counts=None, max_epochs=None, lr=None, lr_extra=None, weight_decay=None, eps=None, n_steps_kl_warmup=None, n_epochs_kl_warmup=None, batch_size=None, accelerator=None, n_neighbors=10, **kwargs)#
ResolVI integration method for spatial transcriptomics.
Wrapper around the ResolVI method [EY25] for addressing noise and bias in spatial transcriptomics. Part of the scvi-tools framework [GLX+22].
Methods table#
|
Fit ResolVI model. |
Fit the method and transform the data. |
|
Get information about the fitted model. |
|
|
Load a pre-trained model or embedding from various sources. |
|
Save embedding to file with preserved cell names as index. |
|
Save ResolVI model. |
|
Setup ResolVI-specific preprocessing. |
Get ResolVI latent representation. |
|
|
Validate the AnnData object has required keys and structure. |
|
Validate spatial-specific data requirements. |
Methods#
- ResolVIMethod.fit()#
Fit ResolVI model.
Note: ResolVI will compute spatial neighbors internally in
_prepare_data, which is called fromsetup_anndata. To compute neighbors, it will attempt to use rapids_singlecell and fall back to scanpy if necessary. It simply computesn_neighbors+ 5 (by default, 15) neighbors in the given spatial representation, treating each batch separately.
- ResolVIMethod.fit_transform()#
Fit the method and transform the data.
Modifies self.adata in place.
- Return type:
- ResolVIMethod.get_model_info()#
Get information about the fitted model.
- ResolVIMethod.load_artifact(source, artifact_type='model', embedding_key=None, **kwargs)#
Load a pre-trained model or embedding from various sources.
- Parameters:
source (
str|Path|dict) – Source of the artifact. Can be: - str/Path: Local path to model directory or embedding file - dict: WandB parameters with keys ‘run_id’, ‘entity’, ‘project’artifact_type (
Literal['model','embedding'] (default:'model')) – Type of artifact to load: ‘model’ or ‘embedding’.embedding_key (
str|None(default:None)) – Key to store embedding in adata.obsm. If None, uses self.embedding_key. Only used when artifact_type=’embedding’.**kwargs – Additional arguments passed to loading functions.
- Return type:
- ResolVIMethod.save_embedding(format_type='parquet', filename=None, compression=True)#
Save embedding to file with preserved cell names as index.
- Parameters:
format_type (
Literal['parquet','pickle','h5'] (default:'parquet')) – Format to save embedding in. Options: ‘parquet’, ‘pickle’, or ‘h5’.filename (
str|None(default:None)) – Custom filename (without extension). If None, uses “embedding”.compression (
bool(default:True)) – Whether to use compression (gzip for all formats).
- Return type:
- Returns:
Path Path to the saved embedding file.
- Raises:
ValueError – If method is not fitted or embedding key not found in adata.obsm.
- ResolVIMethod.transform()#
Get ResolVI latent representation.
- ResolVIMethod.validate_adata(adata)#
Validate the AnnData object has required keys and structure.
- Parameters:
adata (
AnnData) – Annotated data object to validate.- Raises:
ValueError – If required keys are missing or data is malformed.
- Return type:
- ResolVIMethod.validate_spatial_adata(adata)#
Validate spatial-specific data requirements.
- Parameters:
adata (
AnnData) – Annotated data object to validate.- Raises:
ValueError – If required spatial keys are missing or data is malformed.
- Return type: