SC2Spa.tl.NRD_weight

SC2Spa.tl.NRD_weight(neighbors, dis, adata_ref, adata_query, ct_name=None, weight_constant=1)

Calculate the weights of nearby single cells for ST beads based on the fine mapping result

Parameters

neighbors

Matrix of single cell neighbors of ST beads with the shape of (n_beads, n_neighbors)

dis

corresponding distance matrix of the neighbor matrix

adata_ref

Reference anndata object. Gene expression matrix should be the shape of (cell, gene). Predicted locations should be stored in adata_ref.obs[[‘x_transfer’, ‘y_transfer’]]

adata_query

Query anndata object. Gene expression matrix should be the shape of (cell, gene). Cell type annotation should be stored in adata_query.obs[ct_name] Predicted locations should be stored in adata_query.obs[[‘x_transfer’, ‘y_transfer’]]

weight_constant

A constant added up to the distance between a cell and a ST voxel when calculating the weight of the cell to the ST voxel.

Returns

df_neighbor
A dataframe that contains the cell type information and normalized reciprocal distance

of mapped ST beads and single cells