spateo.tdr.models.morpho_models
#
Submodules#
Package Contents#
Functions#
|
Create a 3D arrow model. |
|
Create a 3D arrow model. |
|
Create multiple 3D arrows model. |
|
Create a 3D line model. |
|
Construct alignment lines between models after model alignment. |
|
Construct axis line. |
|
Create a 3D line model. |
|
Create 3D lines model. |
|
|
|
Create a 3D vector field arrows model. |
|
Integrate a vector field to generate streamlines. |
|
Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only |
|
Reconstruction of cell-level cell developmental change model based on the cell fate prediction results. Here we only |
|
Reconstruction of cell developmental trajectory model based on cell fate prediction. |
|
Reconstruction of cell developmental trajectory model. |
|
Construct a bounding box model of the model. |
|
Construct a model(space-model) with uniform spacing in the three coordinate directions. |
- spateo.tdr.models.morpho_models._construct_arrow(start_point: Union[list, tuple, numpy.ndarray] = (0.0, 0.0, 0.0), direction: Union[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: Optional[Union[str, float]] = '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.morpho_models.construct_arrow(start_point: Union[list, tuple, numpy.ndarray], direction: Union[list, tuple, numpy.ndarray], arrow_scale: Optional[Union[int, float]] = None, key_added: Optional[str] = 'arrow', label: str = 'arrow', color: str = 'gainsboro', alpha: float = 1.0, **kwargs) 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].
- 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.
- spateo.tdr.models.morpho_models.construct_arrows(start_points: numpy.ndarray, direction: numpy.ndarray = None, arrows_scale: Optional[numpy.ndarray] = None, n_sampling: Optional[int] = None, sampling_method: str = 'trn', factor: float = 1.0, key_added: Optional[str] = 'arrow', label: Union[str, list, numpy.ndarray] = 'arrows', color: Union[str, list, dict, numpy.ndarray] = 'gainsboro', alpha: Union[float, int, list, dict, numpy.ndarray] = 1.0, **kwargs) pyvista.PolyData [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.
- spateo.tdr.models.morpho_models._construct_line(start_point: Union[list, tuple, numpy.ndarray] = (-0.5, 0.0, 0.0), end_point: Union[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.morpho_models.construct_align_lines(model1_points: numpy.ndarray, model2_points: numpy.ndarray, key_added: str = 'check_alignment', label: Union[str, list, numpy.ndarray] = 'align_mapping', color: Union[str, list, dict, numpy.ndarray] = 'gainsboro', alpha: Union[float, int, list, dict, numpy.ndarray] = 1.0) pyvista.PolyData [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.
- spateo.tdr.models.morpho_models.construct_axis_line(axis_points: numpy.ndarray, key_added: str = 'axis', label: str = 'axis_line', color: str = 'gainsboro', alpha: Union[float, int, list, dict, numpy.ndarray] = 1.0) pyvista.PolyData [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.
- spateo.tdr.models.morpho_models.construct_line(start_point: Union[list, tuple, numpy.ndarray], end_point: Union[list, tuple, numpy.ndarray], key_added: Optional[str] = 'line', label: str = 'line', color: str = 'gainsboro', alpha: float = 1.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.
- 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.
- spateo.tdr.models.morpho_models.construct_lines(points: numpy.ndarray, edges: numpy.ndarray, key_added: Optional[str] = 'line', label: Union[str, list, numpy.ndarray] = 'lines', color: Union[str, list, dict] = 'gainsboro', alpha: Union[float, int, list, dict] = 1.0) pyvista.PolyData [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.
- spateo.tdr.models.morpho_models.generate_edges(points1: numpy.ndarray, points2: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] [source]#
- spateo.tdr.models.morpho_models.construct_field(model: pyvista.PolyData, vf_key: str = 'VecFld_morpho', arrows_scale_key: Optional[str] = None, n_sampling: Optional[int] = None, sampling_method: str = 'trn', factor: float = 1.0, key_added: str = 'v_arrows', label: Union[str, list, numpy.ndarray] = 'vector field', color: Union[str, list, dict, numpy.ndarray] = 'gainsboro', alpha: float = 1.0, **kwargs) pyvista.PolyData [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.
- spateo.tdr.models.morpho_models.construct_field_streams(model: pyvista.PolyData, vf_key: str = 'VecFld_morpho', source_center: Optional[Tuple[float]] = None, source_radius: Optional[float] = None, tip_factor: Union[int, float] = 10, tip_radius: float = 0.2, key_added: str = 'v_streams', label: Union[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.
- Return type
streams_model
- spateo.tdr.models.morpho_models.construct_genesis(adata: anndata.AnnData, fate_key: str = 'fate_morpho', n_steps: int = 100, logspace: bool = False, t_end: Optional[Union[int, float]] = None, key_added: str = 'genesis', label: Optional[Union[str, list, numpy.ndarray]] = None, color: Union[str, list, dict] = 'skyblue', alpha: Union[float, list, dict] = 1.0) pyvista.MultiBlock [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.
- spateo.tdr.models.morpho_models.construct_genesis_X(stages_X: List[numpy.ndarray], n_spacing: Optional[int] = None, key_added: str = 'genesis', label: Optional[Union[str, list, numpy.ndarray]] = None, color: Union[str, list, dict] = 'skyblue', alpha: Union[float, list, dict] = 1.0) pyvista.MultiBlock [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.
- spateo.tdr.models.morpho_models.construct_trajectory(adata: anndata.AnnData, fate_key: str = 'fate_develop', n_sampling: Optional[int] = None, sampling_method: str = 'trn', key_added: str = 'trajectory', label: Optional[Union[str, list, numpy.ndarray]] = None, tip_factor: Union[int, float] = 5, tip_radius: float = 0.2, trajectory_color: Union[str, list, dict] = 'gainsboro', tip_color: Union[str, list, dict] = 'orangered', alpha: float = 1.0) pyvista.PolyData [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.
- Return type
trajectory_model
- spateo.tdr.models.morpho_models.construct_trajectory_X(cells_states: Union[numpy.ndarray, List[numpy.ndarray]], init_states: Optional[numpy.ndarray] = None, n_sampling: Optional[int] = None, sampling_method: str = 'trn', key_added: str = 'trajectory', label: Optional[Union[str, list, numpy.ndarray]] = None, tip_factor: Union[int, float] = 5, tip_radius: float = 0.2, trajectory_color: Union[str, list, dict] = 'gainsboro', tip_color: Union[str, list, dict] = 'orangered', alpha: Union[float, list, dict] = 1.0) pyvista.PolyData [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.
- Return type
trajectory_model
- spateo.tdr.models.morpho_models.construct_bounding_box(model: Union[pyvista.DataSet, pyvista.MultiBlock], expand_dist: Union[int, float, list, tuple] = (0, 0, 0), grid_num: Optional[Union[List[int], Tuple[int]]] = None, key_added: str = 'bounding_box', label: str = 'bounding_box', color: str = 'gainsboro', alpha: float = 0.5) pyvista.PolyData [source]#
Construct a bounding box model of the model.
- Parameters
- model
A three dims model.
- expand_dist
The length of space-model to be extended in all directions.
- grid_num
Number of grid to generate.
- key_added
The key under which to add the labels.
- label
The label of space-model.
- color
Color to use for plotting space-model.
- alpha
The opacity of the color to use for plotting space-model.
- Returns
A bounding box model.
- spateo.tdr.models.morpho_models.construct_space(model: Union[pyvista.DataSet, pyvista.MultiBlock], expand_dist: Union[int, float, list, tuple] = (0, 0, 0), grid_num: Optional[Union[List[int], Tuple[int]]] = None, key_added: Optional[str] = 'space', label: str = 'space', color: str = 'gainsboro', alpha: float = 0.5) pyvista.UniformGrid [source]#
Construct a model(space-model) with uniform spacing in the three coordinate directions. The six surfaces of the commonly generated space-model are exactly the boundaries of the model, but the space-model can also be expanded by expand_dist.
- Parameters
- model
A three dims model.
- expand_dist
The length of space-model to be extended in all directions.
- grid_num
Number of grid to generate.
- key_added
The key under which to add the labels.
- label
The label of space-model.
- color
Color to use for plotting space-model.
- alpha
The opacity of the color to use for plotting space-model.
- Returns
A space-model with uniform spacing in the three coordinate directions.