featuremap.core_transition_states

Created on Wed Nov 1 13:52:14 2023

Functions

kernel_density_estimate(data, X[, bw, min_radius, ...])

Density estimation for data points specified by X with kernel density estimation.

plot_density(adata[, emb])

Plot the density of the embedding space.

compute_density(adata[, emb, cluster_key, ...])

Identify the core state and transition state in the embedding space.

compute_density_0(adata[, emb, cluster_key, ...])

Identify the core state and transition state in the embedding space.

nodes_of_transition_states(adata, start_state, ...)

Collect the nodes of transition states given the start and end state.

mst_subgraph(adata, tree_points[, emb])

Construct the minimum spanning tree over the tree points.

ridge_pseudotime(adata, root[, plot])

Compute the pseudotime along the ridge path.

bifurcation_plot(adata, core_states, ...)

Plot the bifurcation states in the embedding space.

bifurcation_plot_1(adata, core_states, ...)

Plot the bifurcation states in the embedding space.

path_plot(adata, core_states, transition_states)

Plot the path states in the embedding space.

plot_density_pseudotime(filtered_data[, pseudotime, ...])

Plot the density vs pseudotime.

compute_betweenness_centrality(adata, emb_featuremap)

Compute the betweenness centrality of the cell network.

compute_curvature(adata, emb_featuremap[, ...])

Compute the curvature of the embedding space.

plot_core_transition_states(adata)

Given the core and transition states defined by the density, curvature and betweenness centrality,

compute_cluster_state_labels(adata)

Compute the cluster state labels based on the percentage of core_states and transition_states for each cluster.

weighted_clustering_coefficient(G, node)

clustering_coefficient(G, node)

clustering_coefficient_by_cluster(G, clusters)

silhouette_score_one_point(distances, labels, point_index)

Compute the silhouette score for one node using a shortest path distance matrix.

compute_and_plot_clustering_coefficients(adata, ...)

compute_and_plot_silhouette_scores(adata, ...)

Module Contents

featuremap.core_transition_states.kernel_density_estimate(data, X, bw=0.5, min_radius=5, output_onlylogp=False)[source]

Density estimation for data points specified by X with kernel density estimation.

Parameters:
  • data (array of shape (n_samples, n_features)) – 2D array including data points. Input to density estimation.

  • X (array) – 2D array including multiple data points. Input to density estimation.

  • output_onlylogp (bool) – If true, returns logp, else returns p, g, h, msu.

Returns:

p – 1D array. Unnormalized probability density. The probability density is not normalized due to numerical stability. Exact log probability

Return type:

array

featuremap.core_transition_states.plot_density(adata: anndata.AnnData, emb='featmap')[source]

Plot the density of the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • emb (str) – The embedding space to plot the density.

featuremap.core_transition_states.compute_density(adata: anndata.AnnData, emb='featmap', cluster_key='leiden', density_key='density', quantile_core=0.5, quantile_trans=0.2)[source]

Identify the core state and transition state in the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • emb (str) – The embedding space to plot the density.

  • cluster_key (str) – The key of clusters in adata.obs.

  • top_quantile (float) – The top quantile of the density.

featuremap.core_transition_states.compute_density_0(adata: anndata.AnnData, emb='featmap', cluster_key='leiden', density_key='density', quantile_core=0.5, quantile_trans=0.2)[source]

Identify the core state and transition state in the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • emb (str) – The embedding space to plot the density.

  • cluster_key (str) – The key of clusters in adata.obs.

  • top_quantile (float) – The top quantile of the density.

featuremap.core_transition_states.nodes_of_transition_states(adata, start_state, end_state, clusters)[source]

Collect the nodes of transition states given the start and end state.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • start_state (str) – The start state of the transition.

  • end_state (str) – The end state of the transition.

  • clusters (list) – The list of clusters in the data.

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.

featuremap.core_transition_states.mst_subgraph(adata, tree_points, emb='X_featmap')[source]

Construct the minimum spanning tree over the tree points.

Parameters:
  • adata

  • tree_points (np.array) – Points included in the induced subgraph

Returns:

mst_subg – minimum spanning_tree over tree_points (anchors).

Return type:

igraph

featuremap.core_transition_states.ridge_pseudotime(adata, root, plot='featmap')[source]

Compute the pseudotime along the ridge path.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • root (str) – The root of the ridge path.

  • plot (str) – The embedding space to plot the pseudotime.

Returns:

adata.obs[‘ridge_pseudotime’] – The pseudotime along the ridge path.

Return type:

np.array

featuremap.core_transition_states.bifurcation_plot(adata, core_states, transition_states_1, transition_states_2)[source]

Plot the bifurcation states in the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • core_states (list) – The list of core states.

  • transition_states_1 (list) – The list of transition states 1.

  • transition_states_2 (list) – The list of transition states 2.

featuremap.core_transition_states.bifurcation_plot_1(adata, core_states, transition_states_1, transition_states_2, transition_states_3)[source]

Plot the bifurcation states in the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • core_states (list) – The list of core states.

  • transition_states_1 (list) – The list of transition states 1.

  • transition_states_2 (list) – The list of transition states 2.

featuremap.core_transition_states.path_plot(adata, core_states, transition_states)[source]

Plot the path states in the embedding space.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • core_states (list) – The list of core states.

  • transition_states (list) – The list of transition states.

featuremap.core_transition_states.plot_density_pseudotime(filtered_data, pseudotime='feat_pseudotime', clusters='clusters', density='density')[source]

Plot the density vs pseudotime.

Parameters:
  • filtered_data (pd.DataFrame) – The dataframe including the data.

  • pseudotime (str) – The pseudotime in the data.

  • clusters (str) – The clusters in the data.

  • density (str) – The density in the data.

featuremap.core_transition_states.compute_betweenness_centrality(adata, emb_featuremap, quantile_trans=0.8, quantile_core=0.2)[source]

Compute the betweenness centrality of the cell network.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • emb_featuremap (object) – The featuremap object.

  • top_quantile (float) – The top quantile of the betweenness centrality.

featuremap.core_transition_states.compute_curvature(adata, emb_featuremap, quantile_core=0.2, quantile_trans=0.8)[source]

Compute the curvature of the embedding space.

k = ||d T / d s||

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • emb_featuremap (object) – The featuremap object.

  • top_quantile (float) – The top quantile of the curvature.

featuremap.core_transition_states.plot_core_transition_states(adata)[source]

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.

Parameters:

adata (AnnData) – Annotated data matrix.

featuremap.core_transition_states.compute_cluster_state_labels(adata)[source]

Compute the cluster state labels based on the percentage of core_states and transition_states for each cluster.

Parameters:

adata (AnnData) – Annotated data matrix.

featuremap.core_transition_states.weighted_clustering_coefficient(G, node)[source]
featuremap.core_transition_states.clustering_coefficient(G, node)[source]
featuremap.core_transition_states.clustering_coefficient_by_cluster(G, clusters)[source]
featuremap.core_transition_states.silhouette_score_one_point(distances, labels, point_index)[source]

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

featuremap.core_transition_states.compute_and_plot_clustering_coefficients(adata, emb_featuremap, emb_featuremap_v, phate_graph_nx, tsne_graph, densmap_graph)[source]
featuremap.core_transition_states.compute_and_plot_silhouette_scores(adata, emb_featuremap, emb_featuremap_v, phate_graph_nx, tsne_graph, densmap_graph)[source]