Top-level package for stLearn.

API

Import stLearn as:

import stlearn as st

Wrapper functions: wrapper

Read10X(path[, genome, count_file, …])

Read Visium data from 10X (wrap read_visium from scanpy)

ReadOldST([count_matrix_file, spatial_file, …])

Read Old Spatial Transcriptomics data

ReadSlideSeq(count_matrix_file, spatial_file)

Read Slide-seq data

ReadMERFISH(count_matrix_file, spatial_file)

Read MERFISH data

ReadSeqFish(count_matrix_file, spatial_file)

Read SeqFish data

convert_scanpy

create_stlearn

Add: add

add.image(adata, imgpath, library_id[, …])

Adding image data to the Anndata object

add.positions(adata[, position_filepath, …])

Adding spatial information into the Anndata object

add.parsing(adata, coordinates_file[, copy])

Parsing the old spaital transcriptomics data

add.lr(adata[, db_filepath, sep, source, copy])

Add significant Ligand-Receptor pairs into AnnData object

add.labels(adata[, label_filepath, …])

Add label transfer results into AnnData object

add.annotation(adata, label_list[, …])

Adding annotation for cluster

add.add_loupe_clusters(adata, loupe_path[, …])

Adding label transfered from Seurat

add.add_mask(adata, imgpath[, key, copy])

Adding binary mask image to the Anndata object

add.apply_mask(adata[, masks, select, cmap, …])

Parsing the old spaital transcriptomics data

add.add_deconvolution(adata, annotation_path)

Adding label transfered from Seurat

Preprocessing: pp

pp.filter_genes(adata[, min_counts, …])

Wrap function scanpy.pp.filter_genes

pp.log1p(adata[, copy, chunked, chunk_size, …])

Wrap function of scanpy.pp.log1p Copyright (c) 2017 F.

pp.normalize_total(adata[, target_sum, …])

Wrap function from scanpy.pp.log1p Normalize counts per cell.

pp.scale(adata[, zero_center, max_value, copy])

Wrap function of scanpy.pp.scale

pp.neighbors(adata[, n_neighbors, n_pcs, …])

Compute a neighborhood graph of observations [McInnes18].

pp.tiling(adata[, out_path, library_id, …])

Tiling H&E images to small tiles based on spot spatial location

pp.extract_feature(adata[, cnn_base, …])

Extract latent morphological features from H&E images using pre-trained convolutional neural network base

Embedding: em

em.run_pca(data[, n_comps, zero_center, …])

Wrap function scanpy.pp.pca Principal component analysis [Pedregosa11].

em.run_umap(adata[, min_dist, spread, …])

Wrap function scanpy.pp.umap Embed the neighborhood graph using UMAP [McInnes18].

em.run_ica(adata[, n_factors, fun, tol, …])

FastICA: a fast algorithm for Independent Component Analysis.

em.run_fa(adata[, n_factors, tol, max_iter, …])

Factor Analysis (FA) A simple linear generative model with Gaussian latent variables.

em.run_diffmap(adata[, n_comps, copy])

Diffusion Maps [Coifman05] [Haghverdi15] [Wolf18].

Spatial: spatial

spatial.clustering.localization(adata[, …])

Perform local clustering by using DBSCAN.

spatial.trajectory.pseudotime(adata[, …])

Perform pseudotime analysis.

spatial.trajectory.pseudotimespace_global(adata)

Perform pseudo-time-space analysis with global level.

spatial.trajectory.pseudotimespace_local(adata)

Perform pseudo-time-space analysis with local level.

spatial.trajectory.compare_transitions(…)

Compare transition markers between two clades

spatial.trajectory.detect_transition_markers_clades(…)

Transition markers detection of a clade.

spatial.trajectory.detect_transition_markers_branches(…)

Transition markers detection of a branch.

spatial.morphology.adjust(adata[, use_data, …])

SME normalisation: Using spot location information and tissue morphological features to correct spot gene expression

spatial.SME.SME_impute0(adata[, use_data, …])

using spatial location (S), tissue morphological feature (M) and gene expression (E) information to impute missing values

spatial.SME.pseudo_spot(adata[, tile_path, …])

using spatial location (S), tissue morphological feature (M) and gene expression (E) information to impute gap between spots and increase resolution for gene detection

spatial.SME.SME_normalize(adata[, use_data, …])

using spatial location (S), tissue morphological feature (M) and gene expression (E) information to normalize data.

Tools: tl

tl.clustering.kmeans(adata[, n_clusters, …])

Perform kmeans clustering for spatial transcriptomics data

tl.clustering.louvain(adata[, resolution, …])

Wrap function scanpy.tl.louvain Cluster cells into subgroups [Blondel08] [Levine15] [Traag17].

tl.cci.lr(adata[, use_lr, distance, verbose])

Calculate the proportion of known ligand-receptor co-expression among the neighbouring spots or within spots :param adata: :type adata: AnnData The data object to scan :param use_lr: :type use_lr: str object to keep the result (default: adata.uns[‘cci_lr’]) :param distance: :type distance: float Distance to determine the neighbours (default: closest), distance=0 means within spot

tl.cci.het.count(adata[, use_clustering, …])

Count the cell type densities :param adata: :type adata: AnnData The data object including the cell types to count :param use_clustering: :type use_clustering: The cell type results to use in counting :param use_het: :type use_het: The stoarge place for result :param distance: :type distance: int Distance to determine the neighbours (default is the nearest neighbour), distance=0 means within spot

tl.cci.het.create_grids(adata, num_row, num_col)

Generate screening grids across the tissue sample :param adata: :type adata: AnnData The data object to generate grids on :param num_row: :type num_row: int Number of rows :param num_col: :type num_col: int Number of columns :param radius: :type radius: int Radius to determine neighbours (default: 1, nearest)

tl.cci.het.count_grid(adata[, num_row, …])

Count the cell type densities :param adata: :type adata: AnnData The data object including the cell types to count :param num_row: :type num_row: int Number of grids on height :param num_col: :type num_col: int Number of grids on width :param use_clustering: :type use_clustering: The cell type results to use in counting :param use_het: :type use_het: The stoarge place for result :param radius: :type radius: int Distance to determine the neighbour grids (default: 1=nearest), radius=0 means within grid

tl.cci.merge(adata[, use_lr, use_het, verbose])

Merge results from cell type heterogeneity and L-R clustering :param adata: :type adata: AnnData The data object including the cell types to count :param use_lr: :type use_lr: str CCI LR scores :param use_het: :type use_het: str CCI HET scores

tl.cci.permutation(adata[, n_pairs, …])

Permutation test for merged result :param adata: :type adata: AnnData The data object including the cell types to count :param n_pairs: :type n_pairs: int Number of gene pairs to run permutation test (default: 1000) :param distance: :type distance: int Distance between spots (default: 30) :param use_lr: :type use_lr: str LR cluster used for permutation test (default: ‘lr_neighbours_louvain_max’) :param use_het: :type use_het: str cell type diversity counts used for permutation test (default ‘het’)

Plot: pl

pl.gene_plot(adata[, gene_symbols, …])

pl.gene_plot_interactive(adata)

pl.cluster_plot(adata[, title, figsize, …])

pl.cluster_plot_interactive(adata[, use_label])

pl.subcluster_plot(adata[, title, figsize, …])

pl.subcluster_plot(adata[, title, figsize, …])

pl.non_spatial_plot(adata[, use_label])

A wrap function to plot all the non-spatial plot from scanpy.

pl.deconvolution_plot(adata[, library_id, …])

Clustering plot for sptial transcriptomics data.

pl.QC_plot(adata[, library_id, name, …])

QC plot for sptial transcriptomics data.

pl.het_plot(adata[, title, figsize, cmap, …])

pl.het_plot_interactive(adata)

pl.grid_plot(adata[, use_het, num_row, …])

Cell diversity plot for sptial transcriptomics data.

pl.plot_mask(adata[, library_id, show_spot, …])

mask plot for sptial transcriptomics data.

pl.trajectory.pseudotime_plot(adata[, …])

Global trajectory inference plot (Only DPT).

pl.trajectory.local_plot(adata[, use_label, …])

Local spatial trajectory inference plot.

pl.trajectory.tree_plot(adata[, library_id, …])

Hierarchical tree plot represent for the global spatial trajectory inference.

pl.trajectory.transition_markers_plot(adata)

Plot transition marker.

pl.trajectory.DE_transition_plot(adata[, …])

Differential expression between transition markers.

Tools: datasets

datasets.example_bcba()