smurf.calculate_weight_to_celltype¶
- smurf.calculate_weight_to_celltype(adatas_final, adata, cells_final, so)¶
Calculates the weight matrix mapping cell types to gene expression profiles.
This function computes the average gene expression profiles for each cell type based on the provided single-cell data and spatial data. The resulting weight matrix is normalized and can be used in downstream analyses, such as cell type proportion estimation.
- Parameters:
adatas_final (anndata.AnnData) – An AnnData object containing the final single-cell gene expression data after processing.
adata (anndata.AnnData) – An AnnData object containing spatial gene expression data.
cells_final (dict) – A dictionary mapping cell IDs to their final set of spots after expansion.
so (spatial_object) – A spatial object containing spatial mappings, spot data, and other necessary attributes.
- Returns:
A NumPy array where each row corresponds to a cell type and contains the normalized average gene expression profile.
- Return type:
- Example:
>>> weight_to_celltype = calculate_weight_to_celltype(adatas_final, adata, cells_final, so)