API

Import SpaRED:

import spared

Datasets

datasets.get_dataset(dataset_name[, visualize])

Get a dataset from name.

Filtering

filtering.filter_by_moran(adata, n_keep, ...)

Filter prediction genes by Moran's I.

filtering.filter_dataset(adata, param_dict)

Perform complete filtering pipeline of a slide collection.

filtering.get_slide_from_collection(...)

Retrieve a slide from a collection of slides.

filtering.get_slides_adata(collection, ...)

Get list of slides from collection

Gene Features

gene_features.get_exp_frac(adata)

Compute the expression fraction for all genes.

gene_features.get_glob_exp_frac(adata)

Compute the global expression fraction for all genes.

gene_features.compute_moran(adata, ...)

Compute Moran's I statistic for each gene.

Spot Features

spot_features.compute_patches_embeddings(adata)

Compute embeddings for patches.

spot_features.compute_patches_predictions(adata)

Compute predictions for patches.

spot_features.compute_dim_red(adata, from_layer)

Compute dimensionality reductions and clusters

spot_features.get_spatial_neighbors(adata, ...)

Compute neighbors dictionary for an AnnData object.

Layer Operations

layer_operations.tpm_normalization(organism, ...)

Normalize expression using TPM normalization.

layer_operations.log1p_transformation(adata, ...)

Perform \(\log_2(x+1)\) transformation

layer_operations.combat_transformation(...)

Perform batch correction with ComBat

layer_operations.get_deltas(adata, ...)

Get expression deltas from the mean.

layer_operations.add_noisy_layer(adata, ...)

Add an artificial noisy layer.

layer_operations.process_dataset(adata, ...)

Perform complete processing pipeline.

Denoising

denoising.median_cleaner(collection, ...)

Remove noise with adaptive median filter.

denoising.spackle_cleaner(adata, dataset, ...)

Graph Operations

graph_operations.get_graphs_one_slide(adata, ...)

Get neighbor graphs for a single slide.

graph_operations.get_sin_cos_positional_embeddings(...)

Get positional encodings for a neighbor graph.

graph_operations.get_graphs(adata, n_hops, layer)

Get graphs for all the slides in a dataset.

Plotting

plotting.plot_all_slides(dataset, ...)

Plot all the whole slide images

plotting.plot_exp_frac(param_dict, dataset, ...)

Plot heatmap of expression fraction

plotting.plot_histograms(processed_adata, ...)

Plot filtering histograms

plotting.plot_random_patches(dataset, ...[, ...])

Plot random set of patches

plotting.visualize_moran_filtering(...[, top])

Plot the most or least auto-correlated genes

plotting.visualize_gene_expression(...)

Plot specific gene expression

plotting.plot_clusters(dataset, param_dict, ...)

Plot clusters spatially

plotting.plot_mean_std(dataset, ...)

Plot mean and std of all genes

plotting.plot_data_distribution_stats(...)

Plot dataset's general stats

plotting.plot_mean_std_partitions(dataset, ...)

Plot mean and std of genes by data split

plotting.plot_tests(patch_size, dataset, ...)

Plot all quality control plots

Dataloaders

dataloaders.get_pretrain_dataloaders(adata)

Get dataloaders for pretraining an image encoder.

dataloaders.get_graph_dataloaders(adata[, ...])

Get dataloaders for the graphs of a dataset.

Models

models.ImageEncoder(backbone, ...)

Metrics

metrics.get_pearsonr(gt_mat, pred_mat, mask, ...)

This function receives 2 matrices of shapes (n_observations, n_variables) and computes the average Pearson correlation.

metrics.get_r2_score(gt_mat, pred_mat, mask)

This function receives 2 matrices of shapes (n_observations, n_variables) and computes the average R2 score.

metrics.get_metrics(gt_mat, pred_mat, mask)

Get general regression metrics