COSIE.linkage_construction.split_raw_data

split_raw_data(data_dict, spatial_loc_dict, n_x, n_y)[source]

Divide spatial omics data from each section into spatially partitioned subgraphs.

Each tissue section is split into a grid of n_x × n_y rectangular regions of equal size. This function is primarily used for scaling to large spatial datasets by enabling subgraph-level analysis.

Parameters

data_dictdict

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

  • .X: Feature matrix

  • .obs, .var: Metadata

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

Use None if a modality is missing in a section.

spatial_loc_dictdict

A dictionary mapping each section name (e.g., ‘s1’, ‘s2’, …) to a 2D NumPy array of shape (n_cells, 2), representing the spatial coordinates of each cell in the section.

n_xint

Number of spatial partitions along the x-axis.

n_yint

Number of spatial partitions along the y-axis.

Returns

sub_data_dictdict

A nested dictionary organizing modality-specific AnnData subgraphs by section and region.

Format:

{
‘s1’: {

0: {‘RNA’: AnnData, ‘Protein’: AnnData, …}, # First spatial region of section s1

1: {…}, …

},

‘s2’: {

}

}