spateo.tools.spatial_impute.run_impute
#
Wrapper function to run generative modeling for count denoising and imputation.
Module Contents#
Functions#
|
Smooth gene expression distributions and downsample a spatial sample by selecting representative points from |
- spateo.tools.spatial_impute.run_impute.impute_and_downsample(adata: anndata.AnnData, filter_by_moran: bool = False, spatial_key: str = 'spatial', positive_ratio_cutoff: float = 0.1, imputation: bool = True, n_ds: Optional[int] = None, to_visualize: Union[None, str, List[str]] = None, cmap: str = 'magma', device: str = 'cpu', **kwargs) Tuple[anndata.AnnData, anndata.AnnData] [source]#
Smooth gene expression distributions and downsample a spatial sample by selecting representative points from this smoothed slice.
- Parameters
- adata
AnnData object to model
- filter_by_moran
Set True to split - for samples with highly uniform expression patterns, simple spatial smoothing will be used. For samples with localized patterns, graph neural network will be used for smoothing. If False, graph neural network will be applied to all genes.
- spatial_key
Only used if ‘filter_by_moran’ is True; key in .obsm where x- and y-coordinates are stored.
- positive_ratio_cutoff
Filter condition for genes- each gene must be present in higher than this proportion of the total number of cells to be retained
- imputation
Set True to perform imputation. If False, will only downsample.
- n_ds
Optional number of cells to downsample to- if not given, will not perform downsampling
- kwargs
Additional arguments that can be provided to :func STGNN.train_STGNN. Options for kwargs: - learn_rate: Float, controls magnitude of gradient for network learning - dropout: Float between 0 and 1, proportion of weights in each layer to set to 0 - act: String specifying activation function for each encoder layer. Options: “sigmoid”, “tanh”, “relu”,
”elu”
- clip: Float between 0 and 1, threshold below which imputed feature values will be set to 0,
as a percentile. Recommended between 0 and 0.1.
weight_decay: Float, controls degradation rate of parameters
epochs: Int, number of iterations of training loop to perform
dim_output: Int, dimensionality of the output representation
alpha: Float, controls influence of reconstruction loss in representation learning
beta: Float, weight factor to control the influence of contrastive loss in representation learning
theta: Float, weight factor to control the influence of the regularization term in representation learning
add_regularization: Bool, adds penalty term to representation learning
- Returns
Input AnnData object (optional) adata_rex: (optional) adata: AnnData subsetted down to downsampled buckets.
- Return type
adata_orig