COSIE.linkage_construction.split_into_subgraphs

split_into_subgraphs(data_tensor, spatial_coords, n_x, n_y)[source]

Split a feature tensor and its corresponding spatial coordinates into n_x × n_y rectangular subregions.

This function is commonly used in subgraph-based training or analysis pipelines for large-scale spatial omics datasets. It partitions both the data and the coordinate space into equal-sized grid regions, producing corresponding subsets.

Parameters

data_tensortorch.Tensor

A tensor of shape (n_cells, dim), representing the input features.

spatial_coordsnp.ndarray

A NumPy array of shape (n_cells, 2) containing 2D spatial coordinates.

n_xint

Number of partitions along the x-axis.

n_yint

Number of partitions along the y-axis.

Returns

sub_feature_dictList[torch.Tensor]

A list of tensors, each containing the features corresponding to one spatial subgraph.

sub_spatial_listList[np.ndarray]

A list of NumPy arrays of shape (n_sub_cells, 2), where each array contains the spatial coordinates of cells within the corresponding subgraph.