smurf.get_finaldata

smurf.get_finaldata(adata, adatas_final, spot_cell_dic, weight_to_celltype, cells_before_ml, groups_combined, pct_toml_dic, nonzero_indices_dic, spots_X_dic=None, nonzero_indices_toml=None, cells_before_ml_x=None, so=None)

Combines cell and spot data after optimization to generate the final single-cell dataset.

This function aggregates gene expression data from spots and assigns counts to individual cells based on the results of optimization algorithms. It generates a final AnnData object containing single-cell gene expression data, along with cell metadata such as cluster assignments and spatial coordinates.

Parameters:
  • adata (anndata.AnnData) – An AnnData object containing spatial gene expression data.

  • adatas_final (anndata.AnnData) – An AnnData object containing the final single-cell gene expression data after processing.

  • spot_cell_dic (dict) – A dictionary containing the proportion of each cell in each spot after optimization.

  • weight_to_celltype (numpy.ndarray) – A NumPy array where each row corresponds to a cell type and contains weight vectors used in the scoring function.

  • cells_before_ml (dict) – A dictionary of cells and their assigned spots before machine learning adjustments.

  • groups_combined (dict) – A dictionary of cell groups formed to limit computational load.

  • pct_toml_dic (dict) – Dictionary containing spot IDs and their associated proportions and cell types.

  • nonzero_indices_dic (dict) – Dictionary of non-zero indices indicating cell presence in spots for each group.

  • spots_X_dic (dict, optional) – (Optional) Dictionary of spot expression matrices for each group. If not provided, it will be computed.

  • nonzero_indices_toml (dict, optional) – (Optional) Dictionary of updated non-zero indices with new IDs for optimization.

  • cells_before_ml_x (dict, optional) – (Optional) Dictionary of cell expression data aggregated before machine learning.

  • so (spatial_object, optional) – (Optional) A spatial object containing spatial mappings and data. If provided, spatial coordinates will be added to the final dataset.

Returns:

An AnnData object containing the final single-cell gene expression data, along with cell metadata.

Return type:

anndata.AnnData