spateo.segmentation.simulation¶
Functions to generate simulated RNA data.
Adapted from code written by @HailinPan.
Functions¶
|
Given simulated cell variables, generate a label array. |
|
Create a new AnnData object containing simulated cell labels and UMI |
Module Contents¶
- spateo.segmentation.simulation._create_labels(shape: Tuple[int, int], xs: numpy.ndarray, ys: numpy.ndarray, axes1: numpy.ndarray, axes2: numpy.ndarray, angles: numpy.ndarray, shift: int = 3) numpy.ndarray [source]¶
Given simulated cell variables, generate a label array.
- Parameters:
- shape
The size of the X and Y axes, in pixels.
- xs
Center X and Y coordinates for each cell.
- ys
Center X and Y coordinates for each cell.
- axes1
Axes lengths for each cell.
- axes2
Axes lengths for each cell.
- angles
Angle for each cell.
- shift
Attempt to minimize overlaps between cells by shifting overlapping cells by this amount (in reality, this is just a scaling factor, so larger values mean to shift overlapping cells by more). Set to zero or negative to disable.
- Returns:
New Numpy array containing cell labels.
- spateo.segmentation.simulation.simulate_cells(shape: Tuple[int, int], n: int, axis1_range: Tuple[int, int] = (7, 15), axis2_range: Tuple[int, int] = (5, 14), shift: int = 3, foreground_params: Tuple[int, int, int] = (0.512, 1.96, 11.4), background_params: Tuple[int, int, int] = (0.921, 1.08, 1.74), seed: int | None = None) anndata.AnnData [source]¶
Create a new AnnData object containing simulated cell labels and UMI counts.
Cells are simulated as ellipses with the two axes lengths sampled from a log-uniform distribution. The angle at which the cell is placed is sampled uniformly at random.
- Parameters:
- shape
The size of the X and Y axes, in pixels.
- n
Number of cells to simulate.
- axis1_range
Range of the first axes.
- axis2_range
Range of the second axes.
- shift
Attempt to minimize overlaps between cells by shifting overlapping cells by this amount (in reality, this is just a scaling factor, so larger values mean to shift overlapping cells by more). Set to zero or negative to disable.
- foreground_params
Parameters for foreground expression, as a 3-element tuple of (dropout rate, mean, variance).
- background_params
Parameters for background expression, as a 3-element tuple of (dropout rate, mean, variance).
- seed
Random seed
- Returns:
- An Anndata object where X contains the simulated UMI counts and
.layers[‘labels’] contains the simulated labels.