spateo.tdr.widgets.changes
#
Module Contents#
Functions#
|
|
|
|
|
Generate a principal elastic tree. |
|
Generate a simple principal tree. |
|
This is the global module that contains principal curve and nonlinear principal component analysis algorithms that |
|
Find the closest principal tree node to any point in the model through KDTree. |
|
Find the closest principal tree node to any point in the model through KDTree. |
|
Calculate the length of a tree model. |
|
Find the closest tree node to any point in the model. |
- spateo.tdr.widgets.changes.changes_along_line(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], key: Union[str, list] = None, n_points: int = 100, vec: Union[tuple, list] = (1, 0, 0), center: Union[tuple, list] = None) Tuple[numpy.ndarray, numpy.ndarray, pyvista.MultiBlock, pyvista.MultiBlock] [source]#
- spateo.tdr.widgets.changes.changes_along_shape(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], spatial_key: Optional[str] = None, key_added: Optional[str] = 'rd_spatial', dim: int = 2, inplace: bool = False, **kwargs)[source]#
- spateo.tdr.widgets.changes.ElPiGraph_tree(X: numpy.ndarray, NumNodes: int = 50, **kwargs) Tuple[numpy.ndarray, numpy.ndarray] [source]#
Generate a principal elastic tree. Reference: Albergante et al. (2020), Robust and Scalable Learning of Complex Intrinsic Dataset Geometry via ElPiGraph.
- Parameters
- X
DxN, data matrix list.
- NumNodes
The number of nodes of the principal graph. Use a range of 10 to 100 for ElPiGraph approach.
- **kwargs
Other parameters used in elpigraph.computeElasticPrincipalTree. For details, please see: https://github.com/j-bac/elpigraph-python/blob/master/elpigraph/_topologies.py
- Returns
The nodes in the principal tree. edges: The edges between nodes in the principal tree.
- Return type
nodes
- spateo.tdr.widgets.changes.SimplePPT_tree(X: numpy.ndarray, NumNodes: int = 50, **kwargs) Tuple[numpy.ndarray, numpy.ndarray] [source]#
Generate a simple principal tree. Reference: Mao et al. (2015), SimplePPT: A simple principal tree algorithm, SIAM International Conference on Data Mining.
- Parameters
- X
DxN, data matrix list.
- NumNodes
The number of nodes of the principal graph. Use a range of 100 to 2000 for PPT approach.
- **kwargs
Other parameters used in simpleppt.ppt. For details, please see: https://github.com/LouisFaure/simpleppt/blob/main/simpleppt/ppt.py
- Returns
The nodes in the principal tree. edges: The edges between nodes in the principal tree.
- Return type
nodes
- spateo.tdr.widgets.changes.Principal_Curve(X: numpy.ndarray, NumNodes: int = 50, scale_factor: Union[int, float] = 1, **kwargs) Tuple[numpy.ndarray, numpy.ndarray] [source]#
This is the global module that contains principal curve and nonlinear principal component analysis algorithms that work to optimize a line over an entire dataset. Reference: Chen et al. (2016), Constraint local principal curve: Concept, algorithms and applications.
- Parameters
- X
DxN, data matrix list.
- NumNodes
Number of nodes for the construction layers. Defaults to 25. The more complex the curve, the higher this number should be.
- scale_factor
- **kwargs
Other parameters used in global algorithms. For details, please see: https://github.com/artusoma/prinPy/blob/master/prinpy/glob.py
- Returns
The nodes in the principal tree. edges: The edges between nodes in the principal tree.
- Return type
nodes
- spateo.tdr.widgets.changes.map_points_to_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], nodes: numpy.ndarray, spatial_key: Optional[str] = None, key_added: Optional[str] = 'nodes', inplace: bool = False, **kwargs)[source]#
Find the closest principal tree node to any point in the model through KDTree.
- Parameters
- model
A reconstructed model.
- nodes
The nodes in the principal tree.
- spatial_key
The key that corresponds to the coordinates of the point in the model. If spatial_key is None, the coordinates are model.points.
- key_added
The key under which to add the nodes labels.
- inplace
Updates model in-place.
- kwargs
Other parameters used in scipy.spatial.KDTree.
- Returns
model.point_data[key_added], the nodes labels array.
- Return type
A model, which contains the following properties
- spateo.tdr.widgets.changes.map_gene_to_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], tree: pyvista.PolyData, key: Union[str, list], nodes_key: Optional[str] = 'nodes', inplace: bool = False)[source]#
Find the closest principal tree node to any point in the model through KDTree.
- Parameters
- model
A reconstructed model contains the gene expression label.
- tree
A three-dims principal tree model contains the nodes label.
- key
The key that corresponds to the gene expression.
- nodes_key
The key that corresponds to the coordinates of the nodes in the tree.
- inplace
Updates tree model in-place.
- Returns
tree.point_data[key], the gene expression array.
- Return type
A tree, which contains the following properties
- spateo.tdr.widgets.changes.calc_tree_length(tree_model: Union[pyvista.UnstructuredGrid, pyvista.PolyData]) float [source]#
Calculate the length of a tree model.
- Parameters
- tree_model
A three-dims principal tree model.
- Returns
The length of the tree model.
- spateo.tdr.widgets.changes.changes_along_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], spatial_key: Optional[str] = None, map_key: Union[str, list] = None, nodes_key: str = 'nodes', key_added: str = 'tree', label: str = 'tree', rd_method: Literal[ElPiGraph, SimplePPT, PrinCurve] = 'ElPiGraph', NumNodes: int = 50, color: str = 'gainsboro', inplace: bool = False, **kwargs) Tuple[Union[pyvista.DataSet, pyvista.PolyData, pyvista.UnstructuredGrid], pyvista.PolyData, float] [source]#
Find the closest tree node to any point in the model.
- Parameters
- model
A reconstructed model.
- spatial_key
If spatial_key is None, the spatial coordinates are in model.points, otherwise in model[spatial_key].
- map_key
The key in model that corresponds to the gene expression.
- nodes_key
The key that corresponds to the coordinates of the nodes in the tree.
- key_added
The key that corresponds to tree label.
- label
The label of tree model.
- rd_method
The method of constructing a tree.
- NumNodes
Number of nodes for the tree model.
- color
Color to use for plotting tree model.
- inplace
Updates model in-place.
- Returns
Updated model if inplace is True. tree_model: A three-dims principal tree model. tree_length: The length of the tree model.
- Return type
model