vampire.anno.pl.motif_abundance_pca

vampire.anno.pl.motif_abundance_pca#

vampire.anno.pl.motif_abundance_pca(adata, color_by=None, shape_by=None, components=(1, 2), figsize=(None, None), title=None, marker_size=10, colormap=None, show_variance=True, save=None, **kwargs)[source]#

Plot pairwise principal components from motif abundance PCA.

Reads pre-computed PCA results stored by vp.anno.tl.motif_abundance_pca(). Color and marker shape can be mapped to columns in adata.obs.

Parameters:
  • adata (AnnData) – Annotated data with PCA results from vp.anno.tl.motif_abundance_pca().

  • color_by (str | None) – Column in adata.obs for marker color. Categorical columns use a discrete palette; numeric columns use a continuous colorscale.

  • shape_by (str | None) – Column in adata.obs for marker shape. Must be categorical.

  • components (tuple[int, int]) – Which two PCs to plot. 1-based indexing, e.g. (1, 2) for PC1 vs PC2, (2, 3) for PC2 vs PC3.

  • figsize (tuple[int | None, int | None]) – Figure size in pixels.

  • title (str | None) – Plot title.

  • marker_size (int) – Marker size.

  • colormap (str | list[str] | None) – Plotly colormap name for numeric color_by. Defaults to "Viridis".

  • show_variance (bool) – Append explained-variance percentages to axis titles.

  • **kwargs – Additional keyword arguments passed to fig.update_layout().

  • save (str | bool | None) – If True or a str, save the figure. A string is appended to the default filename. Infer the filetype if ending on {'.pdf', '.png', '.svg'}.

Returns:

Plotly scatter figure of the chosen PCs.

Return type:

Figure

Examples

>>> import vampire as vp
>>> vp.anno.pl.set_default_plotstyle()
>>> adata = vp.datasets.wdr7_hprc()
>>> vp.anno.tl.motif_abundance_pca(adata)
>>> vp.anno.pl.motif_abundance_pca(adata, color_by="copy_number", components=(1, 2))