tangram.utils

Description

Utility functions to pre- and post-process data for Tangram.

Functions

annotate_gene_sparsity(adata)

Annotates gene sparsity in given Anndatas.

compare_spatial_geneexp(adata_ge, adata_sp)

Compares generated spatial data with the true spatial data

count_cell_annotations(adata_map, adata_sc, …)

Count cells in a voxel for each annotation.

create_segment_cell_df(adata_sp)

Produces a Pandas dataframe where each row is a segmentation object, columns reveals its position information.

cross_val(adata_sc, adata_sp[, …])

Executes cross validation

cv_data_gen(adata_sc, adata_sp[, cv_mode])

Generates pair of training/test gene indexes cross validation datasets

deconvolve_cell_annotations(adata_sp[, …])

Assigns cell annotation to each segmented cell.

df_to_cell_types(df, cell_types)

Utility function that “randomly” assigns cell coordinates in a voxel to known numbers of cell types in that voxel.

eval_metric(df_all_genes[, test_genes])

Compute metrics on given test_genes set for evaluation

get_matched_genes(prior_genes_names, …[, …])

Given the list of genes in the spatial data and the list of genes in the single nuclei, identifies the subset of genes included in both lists and returns the corresponding matching indices.

one_hot_encoding(l[, keep_aggregate])

Given a sequence, returns a DataFrame with a column for each unique value in the sequence and a one-hot-encoding.

project_cell_annotations(adata_map, adata_sp)

Transfer annotation from single cell data onto space.

project_genes(adata_map, adata_sc[, …])

Transfer gene expression from the single cell onto space.

read_pickle(filename)

Helper to read pickle file which may be zipped or not.

transfer_annotations_prob(mapping_matrix, …)

Transfer cell annotations onto space through a mapping matrix.

transfer_annotations_prob_filter(…)

Transfer cell annotations onto space through a mapping matrix and a filter.