featuremap.core_transition_states ================================= .. py:module:: featuremap.core_transition_states .. autoapi-nested-parse:: Created on Wed Nov 1 13:52:14 2023 Functions --------- .. autoapisummary:: featuremap.core_transition_states.kernel_density_estimate featuremap.core_transition_states.plot_density featuremap.core_transition_states.compute_density featuremap.core_transition_states.compute_density_0 featuremap.core_transition_states.nodes_of_transition_states featuremap.core_transition_states.mst_subgraph featuremap.core_transition_states.ridge_pseudotime featuremap.core_transition_states.bifurcation_plot featuremap.core_transition_states.bifurcation_plot_1 featuremap.core_transition_states.path_plot featuremap.core_transition_states.plot_density_pseudotime featuremap.core_transition_states.compute_betweenness_centrality featuremap.core_transition_states.compute_curvature featuremap.core_transition_states.plot_core_transition_states featuremap.core_transition_states.compute_cluster_state_labels featuremap.core_transition_states.weighted_clustering_coefficient featuremap.core_transition_states.clustering_coefficient featuremap.core_transition_states.clustering_coefficient_by_cluster featuremap.core_transition_states.silhouette_score_one_point featuremap.core_transition_states.compute_and_plot_clustering_coefficients featuremap.core_transition_states.compute_and_plot_silhouette_scores Module Contents --------------- .. py:function:: kernel_density_estimate(data, X, bw=0.5, min_radius=5, output_onlylogp=False) Density estimation for data points specified by X with kernel density estimation. :param data: 2D array including data points. Input to density estimation. :type data: array of shape (n_samples, n_features) :param X: 2D array including multiple data points. Input to density estimation. :type X: array :param output_onlylogp: If true, returns logp, else returns p, g, h, msu. :type output_onlylogp: bool :returns: **p** -- 1D array. Unnormalized probability density. The probability density is not normalized due to numerical stability. Exact log probability :rtype: array .. py:function:: plot_density(adata: anndata.AnnData, emb='featmap') Plot the density of the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param emb: The embedding space to plot the density. :type emb: str .. py:function:: compute_density(adata: anndata.AnnData, emb='featmap', cluster_key='leiden', density_key='density', quantile_core=0.5, quantile_trans=0.2) Identify the core state and transition state in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param emb: The embedding space to plot the density. :type emb: str :param cluster_key: The key of clusters in adata.obs. :type cluster_key: str :param top_quantile: The top quantile of the density. :type top_quantile: float .. py:function:: compute_density_0(adata: anndata.AnnData, emb='featmap', cluster_key='leiden', density_key='density', quantile_core=0.5, quantile_trans=0.2) Identify the core state and transition state in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param emb: The embedding space to plot the density. :type emb: str :param cluster_key: The key of clusters in adata.obs. :type cluster_key: str :param top_quantile: The top quantile of the density. :type top_quantile: float .. py:function:: nodes_of_transition_states(adata, start_state, end_state, clusters) Collect the nodes of transition states given the start and end state. :param adata: Annotated data matrix. :type adata: AnnData :param start_state: The start state of the transition. :type start_state: str :param end_state: The end state of the transition. :type end_state: str :param clusters: The list of clusters in the data. :type clusters: list :returns: * **path_nodes** (*np.array*) -- The nodes of the path from start to end state. * **path_points_nn** (*np.array*) -- The points of the path from start to end state. * **end_bridge_points** (*np.array*) -- The points of the end bridge. * **core_points** (*np.array*) -- The points of the core states. * **transition_points** (*np.array*) -- The points of the transition states. .. py:function:: mst_subgraph(adata, tree_points, emb='X_featmap') Construct the minimum spanning tree over the tree points. :param adata: :param tree_points: Points included in the induced subgraph :type tree_points: np.array :returns: **mst_subg** -- minimum spanning_tree over tree_points (anchors). :rtype: igraph .. py:function:: ridge_pseudotime(adata, root, plot='featmap') Compute the pseudotime along the ridge path. :param adata: Annotated data matrix. :type adata: AnnData :param root: The root of the ridge path. :type root: str :param plot: The embedding space to plot the pseudotime. :type plot: str :returns: **adata.obs['ridge_pseudotime']** -- The pseudotime along the ridge path. :rtype: np.array .. py:function:: bifurcation_plot(adata, core_states, transition_states_1, transition_states_2) Plot the bifurcation states in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param core_states: The list of core states. :type core_states: list :param transition_states_1: The list of transition states 1. :type transition_states_1: list :param transition_states_2: The list of transition states 2. :type transition_states_2: list .. py:function:: bifurcation_plot_1(adata, core_states, transition_states_1, transition_states_2, transition_states_3) Plot the bifurcation states in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param core_states: The list of core states. :type core_states: list :param transition_states_1: The list of transition states 1. :type transition_states_1: list :param transition_states_2: The list of transition states 2. :type transition_states_2: list .. py:function:: path_plot(adata, core_states, transition_states) Plot the path states in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData :param core_states: The list of core states. :type core_states: list :param transition_states: The list of transition states. :type transition_states: list .. py:function:: plot_density_pseudotime(filtered_data, pseudotime='feat_pseudotime', clusters='clusters', density='density') Plot the density vs pseudotime. :param filtered_data: The dataframe including the data. :type filtered_data: pd.DataFrame :param pseudotime: The pseudotime in the data. :type pseudotime: str :param clusters: The clusters in the data. :type clusters: str :param density: The density in the data. :type density: str .. py:function:: compute_betweenness_centrality(adata, emb_featuremap, quantile_trans=0.8, quantile_core=0.2) Compute the betweenness centrality of the cell network. :param adata: Annotated data matrix. :type adata: AnnData :param emb_featuremap: The featuremap object. :type emb_featuremap: object :param top_quantile: The top quantile of the betweenness centrality. :type top_quantile: float .. py:function:: compute_curvature(adata, emb_featuremap, quantile_core=0.2, quantile_trans=0.8) Compute the curvature of the embedding space. k = ||d T / d s|| :param adata: Annotated data matrix. :type adata: AnnData :param emb_featuremap: The featuremap object. :type emb_featuremap: object :param top_quantile: The top quantile of the curvature. :type top_quantile: float .. py:function:: plot_core_transition_states(adata) Given the core and transition states defined by the density, curvature and betweenness centrality, union the core and transition states and plot the core and transition states in the embedding space. :param adata: Annotated data matrix. :type adata: AnnData .. py:function:: compute_cluster_state_labels(adata) Compute the cluster state labels based on the percentage of core_states and transition_states for each cluster. :param adata: Annotated data matrix. :type adata: AnnData .. py:function:: weighted_clustering_coefficient(G, node) .. py:function:: clustering_coefficient(G, node) .. py:function:: clustering_coefficient_by_cluster(G, clusters) .. py:function:: silhouette_score_one_point(distances, labels, point_index) Compute the silhouette score for one node using a shortest path distance matrix. Parameters: - distances: 2D list or ndarray of shape (n_nodes, n_nodes), shortest path distances between nodes - labels: list or ndarray of shape (n_nodes,) - point_index: int, index of the node for which to compute the silhouette score Returns: - silhouette score for the given node .. py:function:: compute_and_plot_clustering_coefficients(adata, emb_featuremap, emb_featuremap_v, phate_graph_nx, tsne_graph, densmap_graph) .. py:function:: compute_and_plot_silhouette_scores(adata, emb_featuremap, emb_featuremap_v, phate_graph_nx, tsne_graph, densmap_graph)