sainsc.lazykde.LazyKDE

class sainsc.lazykde.LazyKDE(counts, *, n_threads=None)

Class to analyze kernel density estimates (KDE) for large number of genes.

The KDE of the genes will be calculated when needed to avoid storing large volumes of data in memory.

Parameters:
  • counts (GridCounts) – Gene counts.

  • n_threads (int, optional) – Number of threads used for reading and processing file. If None this will default to the number of available CPUs.

Attributes

counts

Spatial gene counts.

Properties

assignment_score

Assignment score for each pixel.

background

Map of pixels that are assigned as background.

celltype_map

Cell-type map of cell-type indices.

celltypes

List of assigned celltypes.

cosine_similarity

Cosine similarity for each pixel.

genes

List of genes.

kernel

Map of the KDE of total mRNA.

local_maxima

Coordinates of local maxima.

n_threads

Number of threads that will be used for computations.

resolution

Resolution in nm / pixel.

shape

Shape of the sample.

total_mRNA

Map of the total mRNA.

total_mRNA_KDE

Map of the KDE of total mRNA.

Methods

assign_celltype(signatures, *[, log, chunk])

Calculate the cosine similarity with known cell-type signatures.

calculate_total_mRNA()

Calculate kernel density estimate (KDE) for the total mRNA.

calculate_total_mRNA_KDE()

Calculate kernel density estimate (KDE) for the total mRNA.

filter_background(min_norm[, min_cosine, min_assignment])

Define pixels as background.

find_local_maxima(min_dist[, min_area])

Find the local maxima of the kernel density estimates.

from_dataframe(df, *[, n_threads])

Construct a LazyKDE from a DataFrame.

gaussian_kernel(bw, *[, unit, truncate, circular])

Set the kernel used for kernel density estimation (KDE) to gaussian.

kde(gene, *[, threshold])

Calculate kernel density estimate (KDE).

load_local_maxima([genes, spatialdata])

Load the gene expression (KDE) of the local maxima.

plot_KDE(*[, gene, remove_background, crop, scalebar, ...])

Plot the kernel density estimate (KDE).

plot_KDE_histogram(*[, gene, remove_background, crop])

Plot a histogram of the kernel density estimates.

plot_assignment_score(*[, remove_background, crop, ...])

Plot the assignment score from cell-type assignment.

plot_celltype_map(*[, remove_background, crop, ...])

Plot the cell-type annotation.

plot_cosine_similarity(*[, remove_background, crop, ...])

Plot the cosine similarity from cell-type assignment.

plot_genecount(*[, gene, crop, scalebar, im_kwargs, ...])

Plot the gene expression counts.

plot_genecount_histogram(**kwargs)

Plot a histogram of the counts per gene.

plot_local_maxima(*[, crop, background_kwargs, ...])

Plot the local kernel density estimate maxima.