featuremap.features
Created on Wed Nov 1 13:52:14 2023
Functions
|
Create an AnnData object for plotting |
|
Given a staring point, compute the pseudotime by distance to all other points on the MST |
|
Autoscale the arrow plot |
|
Plot the gauge embedding to visualize the eigengene (or frame for feature loadings) |
|
Plot the gauge embedding to visualize the eigengene (or frame for feature loadings) |
|
Compute the intrinsic dimensionality locally based on local SVD. |
|
Compute the feature variation and feature loadings based on local SVD. |
|
Compute the feature variation and feature loadings based on local SVD. |
|
Compute the feature variation and feature loadings based on local SVD. |
|
Compute the feature variation and feature loadings based on local SVD. |
|
|
|
Plot a given feature (e.g., gene) in two dimensional visualization |
|
Plot a given feature (e.g., gene) in two dimensional visualization |
|
Plot a given feature (e.g., gene) in two dimensional visualization |
|
Plot a given feature (e.g., gene) in two dimensional visualization |
|
Plot a given feature (e.g., gene) in two dimensional visualization |
Plot a given feature (e.g., gene) in two dimensional visualization |
|
|
Preprocess the variation feature for DGV analysis |
|
Compute the feature variation embedding based on all features based on local SVD. |
|
Plot the feature variation embedding in 3D. |
Module Contents
- featuremap.features.create_adata(X, emb_featuremap, obs=None, var=None)[source]
Create an AnnData object for plotting
- Parameters:
X (np.ndarray) – Data matrix.
emb_featuremap (object) – Featuremap object.
obs (pd.DataFrame)
var (pd.DataFrame)
- Returns:
adata – Annotated data matrix.
- Return type:
AnnData
- featuremap.features.pseudotime_mst(adata, random_state, start_point_index)[source]
Given a staring point, compute the pseudotime by distance to all other points on the MST
- featuremap.features.quiver_autoscale(X_emb, V_emb)[source]
Autoscale the arrow plot
- Parameters:
X_emb (np.ndarray) – Embedding matrix.
V_emb (np.ndarray) – Variation embedding matrix.
- Returns:
Scale factor for quiver plot.
- Return type:
Q.scale / scale_factor * 5
- featuremap.features.plot_gauge(adata: anndata.AnnData, embedding='X_featmap', vkey='gauge_v1_emb', density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True)[source]
Plot the gauge embedding to visualize the eigengene (or frame for feature loadings)
- Parameters:
adata (AnnData) – An annotated data matrix.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
vkey (string) – Variation key. The default is ‘gauge_v1_emb’.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.plot_gauge_both(adata: anndata.AnnData, embedding='X_featmap', vkey_1='gauge_v1_emb', vkey_2='gauge_v2_emb', density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, scale_quiver=1)[source]
Plot the gauge embedding to visualize the eigengene (or frame for feature loadings)
- Parameters:
adata (AnnData) – An annotated data matrix.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.local_intrinsic_dim(adata: anndata.AnnData, threshold=0.9, plot: bool = False)[source]
Compute the intrinsic dimensionality locally based on local SVD.
- Parameters:
- Returns:
intrinsic_dim – Intrinsic dimensionality.
- Return type:
np.ndarray
- featuremap.features.feature_variation(adata: anndata.AnnData, threshold=0.5)[source]
Compute the feature variation and feature loadings based on local SVD.
- Parameters:
adata (AnnData) – An annotated data matrix.
- featuremap.features.feature_variation_one_feature(adata: anndata.AnnData, feature='', threshold=0.9, feature_key='variation_feature')[source]
Compute the feature variation and feature loadings based on local SVD.
- Parameters:
adata (AnnData) – An annotated data matrix.
- featuremap.features.feature_projection(adata: anndata.AnnData, feature='', vkey='VH_embedding')[source]
Compute the feature variation and feature loadings based on local SVD.
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
- featuremap.features.feature_gradient(adata: anndata.AnnData, feature='')[source]
Compute the feature variation and feature loadings based on local SVD.
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
- featuremap.features.feature_gradient_projection(adata: anndata.AnnData, feature='', random_state=42)[source]
- featuremap.features.plot_feature(adata: anndata.AnnData, feature='', feature_loading_emb='feature_loading_embedding', embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=False, pseudotime='dpt_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.plot_one_feature(adata: anndata.AnnData, feature='', embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=False, pseudotime='dpt_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, scale_quiver=1.0, output_v_grid=False, scale_by_variation=False, ax=None)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
output_v_grid (bool) – Output the grid velocity. The default is False.
scale_by_variation (bool) – Scale the arrow plot by feature variation. The default is True.
ax (matplotlib axis) – The axis to plot the feature. The default is None.
- featuremap.features.plot_multiple_features(adata: anndata.AnnData, features=[], embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=False, pseudotime='dpt_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, scale_by_variation=True)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
output_v_grid (bool) – Output the grid velocity. The default is False.
scale_by_variation (bool) – Scale the arrow plot by feature variation. The default is True.
- featuremap.features.plot_one_feature_by_all_cells(adata: anndata.AnnData, feature='', embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=False, pseudotime='dpt_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, output_v_grid=False, scale_by_variation=True, scale_quiver=1.0)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.plot_multiple_features_by_all_cells(adata: anndata.AnnData, features=[], embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=False, pseudotime='dpt_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, output_v_grid=False, scale_by_variation=True)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.plot_multiple_features_by_all_cells_given_clusters(adata: anndata.AnnData, features=[], embedding='X_featmap', cluster_key='clusters', plot_within_cluster=[], pseudotime_adjusted=True, pseudotime='feat_pseudotime', trend='positive', ratio=0.2, density=1, smooth=0.5, n_neighbors=None, min_mass=1, autoscale=True, scale_by_variation=True, feature_key='', scale_quiver=1.0)[source]
Plot a given feature (e.g., gene) in two dimensional visualization
- Parameters:
adata (AnnData) – An annotated data matrix.
feature (string) – Feature name to be plotted.
embedding (string) – Embedding background for feature plot. The default is ‘X_featmap’.
cluster_key (string) – Cluster name indicator. The default is ‘clusters’.
plot_within_cluster (list) – A list of clusters in which the feaure is to plot. The default is [].
pseudotime_adjusted (bool) – Whether to adjust the feature direction by pseudotime. The default is False.
pseudotime (string) – Pseudotime indicator. The default is ‘dpt_pseudotime’.
trend (string of {'positive','negative'}) – The direction along pseudotime. The default is ‘positive’.
ratio (float) – Filtering ratio by expression to filter varition by low expression. The default is 0.5.
density (float) – Grid desity for plot. The default is 1.
smooth (float) – For kde estimation. The default is 0.5.
n_neighbors (int) – Number of neighbours for kde. The default is None.
min_mass (float) – Minumum denstiy to show the grid plot. The default is 1.
autoscale (bool) – Scale the arrow plot. The default is True.
- featuremap.features.variation_feature_pp(adata)[source]
Preprocess the variation feature for DGV analysis
- Parameters:
adata (AnnData) – An annotated data matrix.
- featuremap.features.feature_variation_embedding(adata, n_components=2, layer='variation_feature', variation_preprocess_flag=False, random_state=42)[source]
Compute the feature variation embedding based on all features based on local SVD.
- Parameters:
adata (AnnData) – An annotated data matrix.
n_components (int) – Number of components for embedding. The default is 2.
layer (string) – Layer for variation feature. The default is ‘variation_feature’.
variation_preprocess_flag (bool) – Whether to preprocess the variation feature. The default is False.
random_state (int) – Random state. The default is 42.
- Returns:
adata_var – Annotated data matrix with variation matrix and variation embedding.
- Return type:
AnnData
- featuremap.features.featuremap_var_3d(emb_var_3d, color=None, symbol=None, marker_size=3)[source]
Plot the feature variation embedding in 3D.
- Parameters:
emb_var_3d (np.ndarray) – 3D embedding of feature variation.
color (string) – Color indicator. The default is None.
symbol (string) – Symbol indicator. The default is None.
marker_size (int) – Marker size. The default is 3.