smurf.make_pixels_cells

smurf.make_pixels_cells(so, adata, cells_before_ml, spot_cell_dic, spots_id_dic, spots_id_dic_prop, nonzero_indices_dic, seed=42)

Assigns cells to pixels in the spatial data based on spot compositions.

This function creates a new pixel-level cell assignment matrix by combining initial cell assignments with additional cell composition information. It normalizes the proportions and updates the spatial object with the new cell assignments.

Parameters:
  • so (spatial_object) – A spatial object containing spatial mappings, spot data, and other necessary attributes.

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

  • cells_before_ml (dict) – A dictionary containing initial cell assignments before machine learning adjustments.

  • spot_cell_dic (dict) – A dictionary mapping spots to cell composition data after machine learning adjustments.

  • spots_id_dic (dict) – A dictionary mapping spot IDs to their corresponding indices.

  • spots_id_dic_prop (dict) – A dictionary containing the proportions of spots after adjustments.

  • nonzero_indices_dic (dict) – A dictionary of non-zero indices for each spot, indicating cell presence.

  • seed (int, optional) – The random seed for reproducibility when assigning cells to pixels. Defaults to 42.

Returns:

The updated spatial object so with the new pixel-level cell assignments stored in so.pixels_cells.

Return type:

spatial_object