pseudodynamics.plotting_fns.param_plot

Functions

contour_animation(s, continous_u, save_path)

animation of density contour change by time s: nparray, (ngrid**2, 2) , s from train_DS continous_u : nparray, (n_timepoints, ngrid**2) save_path : str

format_ay(array)

params_in_umap(adata, prediction[, ...])

Visaulize the fitted behavior params in umap and by time

plot_gene_trends(adata, gene_list, ...[, ...])

Plot gene trends for a list of genes along pseudotime.

truncated_clustermap(matrix, num_clusters[, ...])

Create a truncated clustermap with colored dendrogram and return cluster assignments and reordered indices.

pseudodynamics.plotting_fns.param_plot.contour_animation(s, continous_u, save_path, fill=False, fps=5)[source]

animation of density contour change by time s: nparray, (ngrid**2, 2) , s from train_DS continous_u : nparray, (n_timepoints, ngrid**2) save_path : str

pseudodynamics.plotting_fns.param_plot.params_in_umap(adata, prediction, timepoints=None, param='u', copy=True, cell_of_t=True, log=False, clipping=None, subplot_kws=None, umap_kws=None)[source]

Visaulize the fitted behavior params in umap and by time

Parameters:
  • adata (AnnData)

  • prediction ([tensor, ndarray] , the prediction of shape (n_timepoints, n_cells))

  • timepoints (list of real-time)

  • param (str, the param to visaulize, must be one of ['u', 'g', 'v', 'D'])

  • copy (bool, default to True, will save the params to adata.obs if copy is set to False)

  • cell_of_t (bool, default to True, only visualize cells of each timepoints.) – If set to False, all cells will be shown in each panels.

Returns:

fig, axs

Example

>>> param = 'g'
>>> u_pred = Model.predict_param(DataSet=train_DS_t5, param=param)
>>> adata = train_DS_t5.adata
>>> params_in_umap(adata, u_pred, param=param)

Plot gene trends for a list of genes along pseudotime. If the PINN_params and para_name are provided, it will also plot the PINN parameters on a secondary y-axis.

Parameters:
  • adata (AnnData object containing the data.)

  • gene_list (List of genes to plot.)

  • gene_trend_key (the varm key in adata that contains the gene trends.)

  • pseudotime_key (Key in adata.obs that contains pseudotime values.)

  • n_bins (Number of bins for pseudotime.)

  • PINN_params (Optional, a numpy array of PINN parameters to plot on a secondary y-axis.)

  • para_name (Optional, a string to label the secondary y-axis for PINN_params.)

Returns:

fig, ax, ax2

Example

>>> TFgroup1 = ["Cebpe", "Clec4a2", "Cst7", "Elane", "Fcgr3", "Prtn3", "S100a8", "Wfdc21"]
>>> pint_v_project = tl.aggregate_params_by_pseudotime(adata_neu, adata_neu.obsm['v_norm'].T,
                        param_names='v',  pseudotime_key='palantir_pseudotime', nbins=100, return_y=True)
>>> plot_gene_trends(adata_raw, TFgroup1, PINN_params=pint_v_project[3], para_name='PINN Day27 v')
pseudodynamics.plotting_fns.param_plot.truncated_clustermap(matrix, num_clusters, original_shape=None, truncate_mode='level', p=3, method='ward', cmap='viridis', context_kws={}, cbar_kws={}, show_log=False, cluster_colors=None, col_colorbar_size=(0.02, 0.15), col_colorbar_location_x=(0.0, 0.3), col_colorbar_location_y=(0.05, 0.3), col_colorbar_tick_labels_x=None, col_colorbar_tick_labels_y=None)[source]

Create a truncated clustermap with colored dendrogram and return cluster assignments and reordered indices.

Parameters:
  • matrix (numpy array, the input matrix where rows are to be clustered.)

  • num_clusters (int, the number of clusters to form.)

  • original_shape (tuple of int, original 2D dimensions (n_rows, n_cols) of the matrix before flattening.)

  • truncate_mode (str, the truncation mode for the dendrogram (default is "level").)

  • p (int, the truncation parameter (e.g., number of levels for "level" mode).)

  • method (str, the linkage method to use (default is 'ward').)

  • cmap (str, the colormap for the heatmap (default is 'viridis').)

  • context_kws (dict, additional keyword arguments for seaborn's plotting context.)

  • show_log (bool, whether to apply a log transform to the matrix (default is False).)

  • cluster_colors (list of colors, custom colors for clusters (default is None).)

  • row_colorbar_size (tuple of float, size of the row colorbar (width, height) in figure units.)

  • row_colorbar_location (tuple of float, location of the row colorbar (x, y) in figure units.)

  • row_colorbar_tick_labels (list of str, custom tick labels for the row colorbar (default is None).)

  • col_colorbar_size (tuple of float, size of the column colorbar (width, height) in figure units.)

  • col_colorbar_location (tuple of float, location of the column colorbar (x, y) in figure units.)

  • col_colorbar_tick_labels (list of str, custom tick labels for the column colorbar (default is None).)

  • Returns

  • ----------

  • clusters (numpy array, cluster assignments for each row.)

  • reordered_indices (numpy array, reordered row indices based on the dendrogram.)

  • g (clustermap object.)