spateo.segmentation.simulation
==============================
.. py:module:: spateo.segmentation.simulation
.. autoapi-nested-parse::
Functions to generate simulated RNA data.
Adapted from code written by @HailinPan.
Functions
---------
.. autoapisummary::
spateo.segmentation.simulation._create_labels
spateo.segmentation.simulation.simulate_cells
Module Contents
---------------
.. py:function:: _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
Given simulated cell variables, generate a label array.
:param shape: The size of the X and Y axes, in pixels.
:param xs: Center X and Y coordinates for each cell.
:param ys: Center X and Y coordinates for each cell.
:param axes1: Axes lengths for each cell.
:param axes2: Axes lengths for each cell.
:param angles: Angle for each cell.
:param 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.
.. py:function:: 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: Optional[int] = None) -> anndata.AnnData
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.
:param shape: The size of the X and Y axes, in pixels.
:param n: Number of cells to simulate.
:param axis1_range: Range of the first axes.
:param axis2_range: Range of the second axes.
:param 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.
:param foreground_params: Parameters for foreground expression, as a 3-element
tuple of (dropout rate, mean, variance).
:param background_params: Parameters for background expression, as a 3-element
tuple of (dropout rate, mean, variance).
:param seed: Random seed
:returns:
An Anndata object where X contains the simulated UMI counts and
`.layers['labels']` contains the simulated labels.