lib5c.plotters.pca module

Module for plotting visualizations of the results of principle component analyses.

lib5c.plotters.pca.plot_multi_pca(proj, pcs=3, s=100, label_points=True, labels=None, levels=None, colors=None, hue_order=None, **kwargs)[source]

Create a multi-component grid of PCA plots.

Parameters:
  • proj (np.ndarray) – The matrix of PCA-projected replicates.
  • pcs (int) – How many principle components should be plotted.
  • s (float) – The area of the points to plot on the scatterplot.
  • label_points (bool) – Pass True to annotate each point with its label.
  • labels (Optional[List[str]]) – String names identifying the replicates (the rows of proj). Pass None to simply label them with their row index within proj.
  • levels (Optional[Union[List[str], Dict[str, str]]]) – The “level” for each replicate. Can be passed as a list of string (matching the order of the rows of proj), or a dict mapping the labels to levels. Each “level” gets one color and one entry in the legend. If None is passed each replicate gets its own level (levels = labels).
  • colors (Optional[Dict[str, str]]) – Mapping from levels as strings to the color to use for that level. Pass None to use randomly assigned colors.
  • hue_order (Optional[List[str]]) – Pass a list of the level names to determine their order in the legend.
  • kwargs (kwargs) – Typical plotter kwargs.
Returns:

The axis plotted on.

Return type:

pyplot axis

Notes

If both log and scaled are True, the logarithm will be applied before scaling.

PCA will always mean-center the data.

lib5c.plotters.pca.plot_pca(proj, pcs=(0, 1), legend=True, s=100, label_points=True, labels=None, levels=None, colors=None, hue_order=None, **kwargs)[source]

Plots a PCA projection along two selected principal components.

Parameters:
  • proj (np.ndarray) – The matrix of PCA-projected replicates.
  • pcs (Tuple[int]) – Which two (zero-indexed) principle components should be plotted.
  • legend (bool) – Pass True to include a legend.
  • s (float) – The area of the points to plot on the scatterplot.
  • label_points (bool) – Pass True to annotate each point with its label.
  • labels (Optional[List[str]]) – String names identifying the replicates (the rows of proj). Pass None to simply label them with their row index within proj.
  • levels (Optional[Union[List[str], Dict[str, str]]]) – The “level” for each replicate. Can be passed as a list of string (matching the order of the rows of proj), or a dict mapping the labels to levels. Each “level” gets one color and one entry in the legend. If None is passed each replicate gets its own level (levels = labels).
  • colors (Optional[Dict[str, str]]) – Mapping from levels as strings to the color to use for that level. Pass None to use randomly assigned colors.
  • hue_order (Optional[List[str]]) – Pass a list of the level names to determine their order in the legend.
  • kwargs (kwargs) – Typical plotter kwargs.
Returns:

The axis plotted on.

Return type:

pyplot axis