sainsc.GridCounts

class sainsc.GridCounts(counts, *, resolution=None, n_threads=None)

Object holding each gene as count data in a sparse 2D-grid.

Parameters:
  • counts (dict[str, csr_array | csr_matrix | csc_array | csc_matrix]) – Gene counts.

  • resolution (float, optional) – Resolution as nm / pixel.

  • n_threads (int, optional) – Number of threads used for processing. If None or 0 this will default to the number of logical CPUs.

Raises:

ValueError – If genes in counts do not all have the same shape.

Attributes

shape

Shape of the count arrays.

Properties

n_threads

Number of threads used for processing.

resolution

Resolution in nm / pixel.

Methods

as_dataframe()

Convert to a dataframe with 'gene', 'x', 'y', and 'count' column.

crop(x, y)

Crop the field of view for all genes.

filter_genes_by_count([min, max])

Filter genes by minimum and maximum count thresholds.

filter_mask(mask)

Filter all genes with a binary mask.

from_dataframe(df, *[, resolution, binsize, n_threads])

Initialize from dataframe.

gene_counts()

Number of counts per gene.

genes()

Get all available genes.

get(key[, default])

Get the counts for a gene.

grid_counts()

Counts per pixel.

select_genes(genes)

Keep selected genes.