ehrapy.plot.pca_variance_ratio

ehrapy.plot.pca_variance_ratio(adata, n_pcs=30, log=False, show=None, save=None)[source]

Plot the variance ratio.

Parameters:
  • adata (AnnData) – AnnData object object containing all observations.

  • n_pcs (int) – Number of PCs to show.

  • log (bool) – Plot on logarithmic scale..

  • show (bool | None) – Show the plot, do not return axis.

  • save (bool | str | 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:

If show==False a Axes or a list of it.

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.pp.knn_impute(adata)
>>> ep.pp.log_norm(adata, offset=1)
>>> ep.pp.neighbors(adata)
>>> ep.pp.pca(adata)
>>> ep.pl.pca_variance_ratio(adata, n_pcs=8)
Preview:
../../_images/pca_variance_ratio.png