spateo.tdr.models.models_migration

Submodules

Functions

_construct_arrow(, direction, tuple, numpy.ndarray] =, ...)

Create a 3D arrow model.

construct_arrow(→ Tuple[pyvista.PolyData, Optional[str]])

Create a 3D arrow model.

construct_arrows(→ Tuple[pyvista.PolyData, Optional[str]])

Create multiple 3D arrows model.

_construct_line(, end_point, tuple, ...)

Create a 3D line model.

construct_align_lines(→ Tuple[pyvista.PolyData, ...)

Construct alignment lines between models after model alignment.

construct_axis_line(→ Tuple[pyvista.PolyData, ...)

Construct axis line.

construct_line(→ Tuple[pyvista.PolyData, Optional[str]])

Create a 3D line model.

construct_lines(→ Tuple[pyvista.PolyData, Optional[str]])

Create 3D lines model.

generate_edges(→ Tuple[numpy.ndarray, numpy.ndarray])

construct_field(→ Tuple[pyvista.PolyData, Optional[str]])

Create a 3D vector field arrows model.

construct_field_streams(model[, vf_key, ...])

Integrate a vector field to generate streamlines.

construct_genesis(→ Tuple[pyvista.MultiBlock, ...)

Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only

construct_genesis_X(→ Tuple[pyvista.MultiBlock, ...)

Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only

construct_trajectory(→ Tuple[Any, Optional[str]])

Reconstruction of cell developmental trajectory model based on cell fate prediction.

construct_trajectory_X(→ Tuple[Any, Optional[str]])

Reconstruction of cell developmental trajectory model.

Package Contents

spateo.tdr.models.models_migration._construct_arrow(start_point: list | tuple | numpy.ndarray = (0.0, 0.0, 0.0), direction: list | tuple | numpy.ndarray = (1.0, 0.0, 0.0), tip_length: float = 0.25, tip_radius: float = 0.1, tip_resolution: int = 20, shaft_radius: float = 0.05, shaft_resolution: int = 20, scale: str | float | None = 'auto') pyvista.PolyData[source]

Create a 3D arrow model.

Parameters:
start_point

Start location in [x, y, z] of the arrow.

direction

Direction the arrow points to in [x, y, z].

tip_length

Length of the tip.

tip_radius

Radius of the tip.

tip_resolution

Number of faces around the tip.

shaft_radius

Radius of the shaft.

shaft_resolution

Number of faces around the shaft.

scale

Scale factor of the entire object. 'auto' scales to length of direction array.

Returns:

Arrow model.

spateo.tdr.models.models_migration.construct_arrow(start_point: list | tuple | numpy.ndarray, direction: list | tuple | numpy.ndarray, arrow_scale: int | float | None = None, key_added: str | None = 'arrow', label: str = 'arrow', color: str = 'gainsboro', alpha: float = 1.0, **kwargs) Tuple[pyvista.PolyData, str | None][source]

Create a 3D arrow model.

Parameters:
start_point

Start location in [x, y, z] of the arrow.

direction

Direction the arrow points to in [x, y, z].

arrow_scale

Scale factor of the entire object. ‘auto’ scales to length of direction array.

key_added

The key under which to add the labels.

label

The label of arrow model.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

**kwargs

Additional parameters that will be passed to _construct_arrow function.

Returns:

Arrow model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

model

spateo.tdr.models.models_migration.construct_arrows(start_points: numpy.ndarray, direction: numpy.ndarray = None, arrows_scale: numpy.ndarray | None = None, n_sampling: int | None = None, sampling_method: str = 'trn', factor: float = 1.0, key_added: str | None = 'arrow', label: str | list | numpy.ndarray = 'arrows', color: str | list | dict | numpy.ndarray = 'gainsboro', alpha: float | int | list | dict | numpy.ndarray = 1.0, **kwargs) Tuple[pyvista.PolyData, str | None][source]

Create multiple 3D arrows model.

Parameters:
start_points

List of Start location in [x, y, z] of the arrows.

direction

Direction the arrows points to in [x, y, z].

arrows_scale

Scale factor of the entire object.

n_sampling

n_sampling is the number of coordinates to keep after sampling. If there are too many coordinates in start_points, the generated arrows model will be too complex and unsightly, so sampling is used to reduce the number of coordinates.

sampling_method

The method to sample data points, can be one of ['trn', 'kmeans', 'random'].

factor

Scale factor applied to scaling array.

key_added

The key under which to add the labels.

label

The label of arrows models.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

**kwargs

Additional parameters that will be passed to _construct_arrow function.

Returns:

Arrows model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

model

spateo.tdr.models.models_migration._construct_line(start_point: list | tuple | numpy.ndarray = (-0.5, 0.0, 0.0), end_point: list | tuple | numpy.ndarray = (0.5, 0.0, 0.0)) pyvista.PolyData[source]

Create a 3D line model.

Parameters:
start_point

Start location in [x, y, z] of the line.

end_point

End location in [x, y, z] of the line.

Returns:

Line model.

spateo.tdr.models.models_migration.construct_align_lines(model1_points: numpy.ndarray, model2_points: numpy.ndarray, key_added: str = 'check_alignment', label: str | list | numpy.ndarray = 'align_mapping', color: str | list | dict | numpy.ndarray = 'gainsboro', alpha: float | int | list | dict | numpy.ndarray = 1.0) Tuple[pyvista.PolyData, str | None][source]

Construct alignment lines between models after model alignment.

Parameters:
model1_points

Start location in model1 of the line.

model2_points

End location in model2 of the line.

key_added

The key under which to add the labels.

label

The label of alignment lines model.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

Alignment lines model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

model

spateo.tdr.models.models_migration.construct_axis_line(axis_points: numpy.ndarray, key_added: str = 'axis', label: str = 'axis_line', color: str = 'gainsboro', alpha: float | int | list | dict | numpy.ndarray = 1.0) Tuple[pyvista.PolyData, str | None][source]

Construct axis line.

Parameters:
axis_points

List of points defining an axis.

key_added

The key under which to add the labels.

label

The label of axis line model.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

Axis line model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

axis_line

spateo.tdr.models.models_migration.construct_line(start_point: list | tuple | numpy.ndarray, end_point: list | tuple | numpy.ndarray, key_added: str | None = 'line', label: str = 'line', color: str = 'gainsboro', alpha: float = 1.0) Tuple[pyvista.PolyData, str | None][source]

Create a 3D line model.

Parameters:
start_point

Start location in [x, y, z] of the line.

end_point

End location in [x, y, z] of the line.

key_added

The key under which to add the labels.

label

The label of line model.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

Line model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

model

spateo.tdr.models.models_migration.construct_lines(points: numpy.ndarray, edges: numpy.ndarray, key_added: str | None = 'line', label: str | list | numpy.ndarray = 'lines', color: str | list | dict = 'gainsboro', alpha: float | int | list | dict = 1.0) Tuple[pyvista.PolyData, str | None][source]

Create 3D lines model.

Parameters:
points

List of points.

edges

The edges between points.

key_added

The key under which to add the labels.

label

The label of lines model.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

Lines model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

model

spateo.tdr.models.models_migration.generate_edges(points1: numpy.ndarray, points2: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray][source]
spateo.tdr.models.models_migration.construct_field(model: pyvista.PolyData, vf_key: str = 'VecFld_morpho', arrows_scale_key: str | None = None, n_sampling: int | None = None, sampling_method: str = 'trn', factor: float = 1.0, key_added: str = 'v_arrows', label: str | list | numpy.ndarray = 'vector field', color: str | list | dict | numpy.ndarray = 'gainsboro', alpha: float = 1.0, **kwargs) Tuple[pyvista.PolyData, str | None][source]

Create a 3D vector field arrows model.

Parameters:
model

A model that provides coordinate information and vector information for constructing vector field models.

vf_key

The key under which are the vector information.

arrows_scale_key

The key under which are scale factor of the entire object.

n_sampling

n_sampling is the number of coordinates to keep after sampling. If there are too many coordinates in start_points, the generated arrows model will be too complex and unsightly, so sampling is used to reduce the number of coordinates.

sampling_method

The method to sample data points, can be one of ['trn', 'kmeans', 'random'].

factor

Scale factor applied to scaling array.

key_added

The key under which to add the labels.

label

The label of arrows models.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

**kwargs

Additional parameters that will be passed to construct_arrows function.

Returns:

A 3D vector field arrows model. plot_cmap: Recommended colormap parameter values for plotting.

spateo.tdr.models.models_migration.construct_field_streams(model: pyvista.PolyData, vf_key: str = 'VecFld_morpho', source_center: Tuple[float] | None = None, source_radius: float | None = None, tip_factor: int | float = 10, tip_radius: float = 0.2, key_added: str = 'v_streams', label: str | list | numpy.ndarray = 'vector field', stream_color: str = 'gainsboro', tip_color: str = 'orangered', alpha: float = 1.0, **kwargs)[source]

Integrate a vector field to generate streamlines.

Parameters:
model

A model that provides coordinate information and vector information for constructing vector field models.

vf_key

The key under which are the active vector field information.

source_center

Length 3 tuple of floats defining the center of the source particles. Defaults to the center of the dataset.

source_radius

Float radius of the source particle cloud. Defaults to one-tenth of the diagonal of the dataset’s spatial extent.

tip_factor

Scale factor applied to scaling the tips.

tip_radius

Radius of the tips.

key_added

The key under which to add the labels.

label

The label of arrows models.

stream_color

Color to use for plotting streamlines.

tip_color

Color to use for plotting tips.

alpha

The opacity of the color to use for plotting model.

**kwargs

Additional parameters that will be passed to streamlines function.

Returns:

3D vector field streamlines model. src: The source particles as pyvista.PolyData as well as the streamlines. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

streams_model

spateo.tdr.models.models_migration.construct_genesis(adata: anndata.AnnData, fate_key: str = 'fate_morpho', n_steps: int = 100, logspace: bool = False, t_end: int | float | None = None, key_added: str = 'genesis', label: str | list | numpy.ndarray | None = None, color: str | list | dict = 'skyblue', alpha: float | list | dict = 1.0) Tuple[pyvista.MultiBlock, str | None][source]

Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only need to enter the three-dimensional coordinates of the cells at different developmental stages.

Parameters:
adata

AnnData object that contains the fate prediction in the .uns attribute.

fate_key

The key under which are the active fate information.

n_steps

The number of times steps fate prediction will take.

logspace

Whether or to sample time points linearly on log space. If not, the sorted unique set of all times points from all cell states’ fate prediction will be used and then evenly sampled up to n_steps time points.

t_end

The length of the time period from which to predict cell state forward or backward over time.

key_added

The key under which to add the labels.

label

The label of cell developmental change model. If label == None, the label will be automatically generated.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

A MultiBlock contains cell models for all stages. plot_cmap: Recommended colormap parameter values for plotting.

spateo.tdr.models.models_migration.construct_genesis_X(stages_X: List[numpy.ndarray], n_spacing: int | None = None, key_added: str = 'genesis', label: str | list | numpy.ndarray | None = None, color: str | list | dict = 'skyblue', alpha: float | list | dict = 1.0) Tuple[pyvista.MultiBlock, str | None][source]

Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only need to enter the three-dimensional coordinates of the cells at different developmental stages.

Parameters:
stages_X

The three-dimensional coordinates of the cells at different developmental stages.

n_spacing

Subdivided into n_spacing time points between two periods.

key_added

The key under which to add the labels.

label

The label of cell developmental change model. If label == None, the label will be automatically generated.

color

Color to use for plotting model.

alpha

The opacity of the color to use for plotting model.

Returns:

A MultiBlock contains cell models for all stages. plot_cmap: Recommended colormap parameter values for plotting.

spateo.tdr.models.models_migration.construct_trajectory(adata: anndata.AnnData, fate_key: str = 'fate_develop', n_sampling: int | numpy.ndarray | None = None, sampling_method: str = 'trn', key_added: str = 'trajectory', label: str | list | numpy.ndarray | None = None, tip_factor: int | float = 5, tip_radius: float = 0.2, trajectory_color: str | list | dict = 'gainsboro', tip_color: str | list | dict = 'orangered', alpha: float = 1.0) Tuple[Any, str | None][source]

Reconstruction of cell developmental trajectory model based on cell fate prediction.

Parameters:
adata

AnnData object that contains the fate prediction in the .uns attribute.

fate_key

The key under which are the active fate information.

n_sampling

n_sampling is the number of coordinates to keep after sampling. If there are too many coordinates in start_points, the generated arrows model will be too complex and unsightly, so sampling is used to reduce the number of coordinates.

sampling_method

The method to sample data points, can be one of ['trn', 'kmeans', 'random'].

key_added

The key under which to add the labels.

label

The label of trajectory model.

tip_factor

Scale factor applied to scaling the tips.

tip_radius

Radius of the tips.

trajectory_color

Color to use for plotting trajectory model.

tip_color

Color to use for plotting tips.

alpha

The opacity of the color to use for plotting model.

Returns:

3D cell developmental trajectory model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

trajectory_model

spateo.tdr.models.models_migration.construct_trajectory_X(cells_states: numpy.ndarray | List[numpy.ndarray], init_states: numpy.ndarray | None = None, n_sampling: int | numpy.ndarray | None = None, sampling_method: str = 'trn', key_added: str = 'trajectory', label: str | list | numpy.ndarray | None = None, tip_factor: int | float = 5, tip_radius: float = 0.2, trajectory_color: str | list | dict = 'gainsboro', tip_color: str | list | dict = 'orangered', alpha: float | list | dict = 1.0) Tuple[Any, str | None][source]

Reconstruction of cell developmental trajectory model.

Parameters:
cells_states

Three-dimensional coordinates of all cells at all times points.

init_states

Three-dimensional coordinates of all cells at the starting time point.

n_sampling

n_sampling is the number of coordinates to keep after sampling. If there are too many coordinates in start_points, the generated arrows model will be too complex and unsightly, so sampling is used to reduce the number of coordinates.

sampling_method

The method to sample data points, can be one of ['trn', 'kmeans', 'random'].

key_added

The key under which to add the labels.

label

The label of trajectory model.

tip_factor

Scale factor applied to scaling the tips.

tip_radius

Radius of the tips.

trajectory_color

Color to use for plotting trajectory model.

tip_color

Color to use for plotting tips.

alpha

The opacity of the color to use for plotting model.

Returns:

3D cell developmental trajectory model. plot_cmap: Recommended colormap parameter values for plotting.

Return type:

trajectory_model