spateo.tdr.models.models_backbone.backbone ========================================== .. py:module:: spateo.tdr.models.models_backbone.backbone Functions --------- .. autoapisummary:: spateo.tdr.models.models_backbone.backbone.construct_backbone spateo.tdr.models.models_backbone.backbone.update_backbone spateo.tdr.models.models_backbone.backbone.backbone_scc Module Contents --------------- .. py:function:: construct_backbone(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], spatial_key: Optional[str] = None, nodes_key: str = 'nodes', rd_method: Literal['ElPiGraph', 'SimplePPT', 'PrinCurve'] = 'ElPiGraph', num_nodes: int = 50, color: str = 'gainsboro', **kwargs) -> Tuple[pyvista.PolyData, float, Optional[str]] Organ's backbone construction based on 3D point cloud model. :param model: A point cloud model. :param spatial_key: If spatial_key is None, the spatial coordinates are in model.points, otherwise in model[spatial_key]. :param nodes_key: The key that corresponds to the coordinates of the nodes in the backbone. :param rd_method: The method of constructing a backbone model. Available ``rd_method`` are: * ``'ElPiGraph'``: Generate a principal elastic tree. * ``'SimplePPT'``: Generate a simple principal tree. * ``'PrinCurve'``: 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. :param num_nodes: Number of nodes for the backbone model. :param color: Color to use for plotting backbone model. :param \*\*kwargs: Additional parameters that will be passed to ``ElPiGraph_method``, ``SimplePPT_method`` or ``PrinCurve_method`` function. :returns: A three-dims backbone model. backbone_length: The length of the backbone model. plot_cmap: Recommended colormap parameter values for plotting. :rtype: backbone_model .. py:function:: update_backbone(backbone: pyvista.PolyData, nodes_key: str = 'nodes', key_added: str = 'updated_nodes', select_nodes: Optional[Union[list, numpy.ndarray]] = None, interactive: Optional[bool] = True, model_size: Union[float, list] = 8.0, colormap: str = 'Spectral') -> Union[pyvista.PolyData, pyvista.UnstructuredGrid] Update the bakcbone through interaction or input of selected nodes. :param backbone: The backbone model. :param nodes_key: The key that corresponds to the coordinates of the nodes in the backbone. :param key_added: The key under which to add the labels of new nodes. :param select_nodes: Nodes that need to be retained. :param interactive: Whether to delete useless nodes interactively. When ``interactive`` is True, ``select_nodes`` is invalid. :param model_size: Thickness of backbone. When ``interactive`` is False, ``model_size`` is invalid. :param colormap: Colormap of backbone. When ``interactive`` is False, ``colormap`` is invalid. :returns: The updated backbone model. :rtype: updated_backbone .. py:function:: backbone_scc(adata: anndata.AnnData, backbone: pyvista.PolyData, genes: Optional[list] = None, adata_nodes_key: str = 'backbone_nodes', backbone_nodes_key: str = 'updated_nodes', key_added: Optional[str] = 'backbone_scc', layer: Optional[str] = None, e_neigh: int = 10, s_neigh: int = 6, cluster_method: Literal['leiden', 'louvain'] = 'leiden', resolution: Optional[float] = None, inplace: bool = True) -> Optional[anndata.AnnData] Spatially constrained clustering (scc) along the backbone. :param adata: The anndata object. :param backbone: The backbone model. :param genes: The list of genes that will be used to subset the data for clustering. If ``genes = None``, all genes will be used. :param adata_nodes_key: The key that corresponds to the nodes in the adata. :param backbone_nodes_key: The key that corresponds to the nodes in the backbone. :param key_added: adata.obs key under which to add the cluster labels. :param layer: The layer that will be used to retrieve data for dimension reduction and clustering. If ``layer = None``, ``.X`` is used. :param e_neigh: the number of nearest neighbor in gene expression space. :param s_neigh: the number of nearest neighbor in physical space. :param cluster_method: the method that will be used to cluster the cells. :param resolution: the resolution parameter of the louvain clustering algorithm. :param inplace: Whether to copy adata or modify it inplace. :returns: An ``AnnData`` object is updated/copied with the ``key_added`` in the ``.obs`` attribute, storing the clustering results.