scembed.methods.HVGMethod#
- class scembed.methods.HVGMethod(adata, layer=None, n_top_genes=None, min_mean=None, max_mean=None, min_disp=None, max_disp=None, span=None, n_bins=None, flavor=None, check_values=None, scale=False, provide_batch=True, **kwargs)#
Highly Variable Genes method using scanpy.
Uses scanpy [WAT18] for highly variable gene selection.
Methods table#
|
Fit HVG method - no explicit fitting needed. |
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 the trained model (for deep learning methods). |
|
Setup data preprocessing for the integration method. |
Apply HVG selection and use HVG expression as embedding. |
|
|
Validate the AnnData object has required keys and structure. |
|
Validate spatial-specific data requirements. |
Methods#
- HVGMethod.fit()#
Fit HVG method - no explicit fitting needed.
- HVGMethod.fit_transform()#
Fit the method and transform the data.
Modifies self.adata in place.
- Return type:
- HVGMethod.get_model_info()#
Get information about the fitted model.
- HVGMethod.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:
- HVGMethod.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.
- HVGMethod.save_model(path)#
Save the trained model (for deep learning methods).
- HVGMethod.setup(force_recompute=False)#
Setup data preprocessing for the integration method.
Prepares the data for method-specific training/inference and stores the result in self.setup_state[“adata_prepared”].
- HVGMethod.transform()#
Apply HVG selection and use HVG expression as embedding.
- HVGMethod.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:
- HVGMethod.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: