COSIE.data_preprocessing.construct_metacell_data_dict

construct_metacell_data_dict(data_dict)[source]

Apply metacell construction to all available AnnData objects in a multimodal dataset dictionary.

Parameters

data_dictdict

A dictionary where each key is a modality name (e.g., ‘RNA’, ‘Protein’) and each value is a list of AnnData objects, one per tissue section. Each AnnData should contain:

  • .X: Expression or feature matrix (dense or sparse)

  • .obs, .var: Standard metadata

  • .obsm[‘spatial’]: 2D spatial coordinates

If a modality is missing in a section, use None to indicate it.

Returns

metacell_dictdict

A new dictionary with the same structure as data_dict, where each AnnData object has been replaced by its metacell-aggregated version, created using metacell_construction_optimized(). The modality and section alignment are preserved.