tacco.utilsΒΆ

General utility functions

Functions

AnnData_query

Query the columns of .obs of an AnnData with a boolean expression and use the result to subset the AnnData.

anndata2dataframe

Creates a long form DataFrame from an AnnData.

bin

Bins points in position space.

cdist

Calclulate a dense pairwise distance matrix of sparse and dense inputs.

col_scale

Rescales columns of dense or sparse matrix inplace.

complete_choice

Similar to numpy.random.choice() with replace=False, but with special behaviour for size>a.shape[0].

coo_tocsr_buffered

Converts a sparse matrix in coo format into a sparse matrix in csr format consuming less memory than working in-memory by using hard disc buffer.

coo_tocsr_inplace

Converts a sparse matrix in coo format into a sparse matrix in csr format without allocating huge temporaries by reusing the memory of the input coo matrix.

cpu_count

Return the number of available CPU cores.

dataframe2anndata

Creates an AnnData from a long form DataFrame.

dense_distance_matrix

Calclulate a dense pairwise euclidean distance matrix of dense inputs.

divide

Calculates division out = a / b.

find_unused_key

Finds an unused key.

fishers_exact

Perform Fisher's exact test.

flat_inverse_mapping

Given a condensed mapping construct a flat inverse mapping.

gemmT

Perform a matrix-matrix multiplication A @ B.T for arbitrary sparseness of A and B in parallel.

generate_mixture_profiles

Creates symmetric pairwise mixture profiles.

get_average_profiles

Get average profiles for a certain annotation from a reference Anndata.

get_balanced_separated_intervals

Find the approximations of intervals with equal number of points in each interval which keep a specified minimum separation between them.

get_first_principal_axis

Get the first principal axis of a set of points.

get_maximum_annotation

Turns a soft annotation into a categorical annotation by reporting the annotation categories with the maximum values per oberservation.

get_sum

Calculates the sum of a sparse matrix or array-like in a specified axis and returns a flattened result.

hash

Create collision-free hash of several categorical columns by lexicograhical indexing.

heapsort3

Sorts an array in-place while following the reordering of the elements in two other arrays.

log

Calculates log inplace and in parallel.

log1p

Calculates log1p inplace and in parallel.

mannwhitneyu

Perform Mann-Whitney-U test.

merge_annotation

Merges annotation into coarser groups, e.g. from subtypes to types.

merge_colors

Merges a dict-like of colors into coarser colors.

min_dtype

Gives the smallest signed integer dtype which is necessary to represent maximum.

mode

Calculates the most frequent value per row in a dataframe.

parallel_nnls

Runs multiple nnls in parallel.

preprocess_single_cell_data

Preprocess single cell data in a standardized way from bare counts as input.

projection

Calculate pairwise normalized projections of sparse and dense inputs.

row_scale

Rescales rows of dense or sparse matrix inplace.

scale_counts

Scales the count matrix in an AnnData in various locations inplace.

solve_OT

Solve optimal transport problem with entropy regularization and optionally Kullback-Leibler divergence penalty terms instead of exact marginal conservation.

sparse_distance_matrix

Calclulate a sparse pairwise distance matrix of dense inputs.

sparse_result_gemmT

Perform a dense matrix-matrix multiplication A @ B.T for the case when only a sparse subset of the result is needed.

spatial_split

Splits a dataset into spatial patches balancing the number of observations per split.

split_spatial_samples

Splits a dataset into separated spatial patches.

sqrt

Calculates sqrt inplace and in parallel.

studentttest

Perform Student's t test.

tsne_single_cell_data

Preprocess single cell data in a standardized way from bare counts as input and include the generation of a tsne embedding.

umap_single_cell_data

Preprocess single cell data in a standardized way from bare counts as input and include the generation of a umap embedding.

welchttest

Perform Welch's t test.

write_adata_x_var_obs

Write only .X, .obs, and .var to an .h5ad file.