Plots-checkpoint
Module Contents
Functions
|
Plots the archetypes inferred by the model on a simplex represented in polar coordinates, optionally coloring |
|
Plots the ELBO loss over SVI steps from the results of model fitting. |
|
Plots a comparison of ELBO losses across different model runs, post-warmup phase. |
|
- Plots-checkpoint.plot_archetypes_simplex(res, distance_type='euclidean', cmap='nipy_spectral', color_by=None, subsample=None, s=None, l_size=30, l_title='Group')
Plots the archetypes inferred by the model on a simplex represented in polar coordinates, optionally coloring points by a given attribute.
Parameters: - res (dict): A dictionary containing model results, specifically ‘inferred_quantities’ with archetype coefficients ‘A’. - distance_type (str, optional): The type of distance metric to use for determining the order of archetypes. Defaults to “euclidean”. - cmap (str, optional): Colormap for plotting. Defaults to “nipy_spectral”. - color_by (Series, optional): Pandas series or similar containing labels to color data points by. Defaults to None. - subsample (array-like, optional): Indices to subsample the archetype coefficients ‘A’ for plotting. Defaults to None. - s (float, optional): Size of points in the plot. Defaults to None. - l_size (int, optional): Size of labels in the legend. Defaults to 30. - l_title (str, optional): Title of the legend. Defaults to “Group”.
Returns: tuple: (fig, ax) where ‘fig’ is the figure object and ‘ax’ is the axes object of the plot.
The function computes distances between archetypes to determine their order, maps these onto a circle, and plots them in polar coordinates. Points can be colored by a categorical variable if provided. The function aims to provide an intuitive visualization of the relationship between archetypes, highlighting their relative distances and potential clustering.
- Plots-checkpoint.plot_ELBO(res)
Plots the ELBO loss over SVI steps from the results of model fitting.
Parameters: - res (dict): A dictionary containing the ELBO loss values in the key ‘ELBO’.
This function creates a line plot showing how the ELBO loss evolved during the optimization process. It’s useful for assessing the convergence of the model fitting process. The x-axis represents the SVI step, and the y-axis represents the ELBO loss value at that step.
- Plots-checkpoint.plot_ELBO_across_runs(res_dictionary, warmup=500)
Plots a comparison of ELBO losses across different model runs, post-warmup phase.
Parameters: - res_dictionary (dict): A dictionary where keys are descriptive names of model runs (e.g., number of archetypes)
and values are dictionaries containing the ‘ELBO’ loss values for those runs.
warmup (int, optional): Number of initial steps to exclude from the plot to focus on the post-warmup phase. Defaults to 500.
The function creates a boxplot for each key in the res_dictionary, showing the distribution of ELBO values across steps after the specified warmup phase. This visualization is helpful for comparing the model fitting performance across different configurations or hyperparameter settings, especially to identify which setups lead to better convergence based on the ELBO loss metric.
- Plots-checkpoint.plot_archetypes_proportion(adata, by='cluster')