dynamo.pl.biplot

dynamo.pl.biplot(adata, pca_components=[0, 1], pca_key='X_pca', loading_key='PCs', figsize=(6, 4), scale_pca_embedding=False, draw_pca_embedding=False, show_text=False, save_show_or_return='show', save_kwargs={}, ax=None)[source]

A biplot overlays a score plot and a loadings plot in a single graph.

In such a plot, points are the projected observations; vectors are the projected variables. If the data are well- approximated by the first two principal components, a biplot enables you to visualize high-dimensional data by using a two-dimensional graph. See more at: https://blogs.sas.com/content/iml/2019/11/06/what-are-biplots.html

In general, the score plot and the loadings plot will have different scales. Consequently, you need to rescale the vectors or observations (or both) when you overlay the score and loadings plots. There are four common choices of scaling. Each scaling emphasizes certain geometric relationships between pairs of observations (such as distances), between pairs of variables (such as angles), or between observations and variables. This article discusses the geometry behind two-dimensional biplots and shows how biplots enable you to understand relationships in multivariate data.

Parameters:
  • adata (AnnData) – an AnnData object that has pca and loading information prepared.

  • pca_components (Tuple[int, int]) – the index of the pca components in loading matrix. Defaults to [0, 1].

  • pca_key (str) – the key to the pca embedding matrix in adata.obsm. Defaults to “X_pca”.

  • loading_key (str) – the key to the pca loading matrix in either adata.uns or adata.varm. Defaults to “PCs”.

  • figsize (Tuple[float, float]) – the size of each subplot. Defaults to (6, 4).

  • scale_pca_embedding (bool) – whether to scale the pca embedding. Defaults to False.

  • draw_pca_embedding (bool) – whether to draw the pca embedding. Defaults to False.

  • show_text (bool) – whether to show the text labels on plot. Defaults to False.

  • save_show_or_return (Literal['save', 'show', 'return']) – whether to save, show, or return the generated figure. Can be one of ‘save’, ‘show’, or ‘return’. Defaults to “show”.

  • save_kwargs (Dict[str, Any]) – a dictionary that will be passed to the save_show_ret function. By default, it is an empty dictionary and the save_show_ret function will use the function will use the {“path”: None, “prefix”: ‘variance_explained’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs. Defaults to {}.

  • ax (Optional[Axes]) – the axes object on which the graph would be plotted. If None, a new axis would be created. Defaults to None.

Raises:

ValueError – invalid loading_key.

Return type:

Axes

Returns:

None would be returned by default. If save_show_or_return is set to be ‘return’, the matplotlib Axes of the figure would be returned.