swiftcnv.plot_cnv

Contents

swiftcnv.plot_cnv#

swiftcnv.plot_cnv(mat, ref_cells, regions, output_file=None, figsize=(20, 12), cmap='RdBu_r', cluster_cells=True, add_dendrogram=True, group_cells=True, vmin=None, vmax=None, vcenter=0, header=True, threads=1, **kwargs)#

Plot the SwiftCNV heatmap with chromosome/arm annotations and separate reference/observation panels.

Additional keyword arguments (**kwargs) add vertical bars to the left. The first keyword argument determines the stratification of clustering, and its legend appears at the bottom. If vmin and vmax are not defined, they are automatically set to the 1st and 99th percentiles of the observation values centered at vcenter.

Parameters:
  • mat (numpy.ndarray) – Input matrix to plot.

  • ref_cells (numpy.ndarray of bool) – Boolean array indicating reference cell status.

  • regions (numpy.ndarray of str) – Array of gene region annotations (chromosomes, arms, etc.).

  • output_file (str, optional) – Path to save the output file. If None, the Matplotlib figure is returned.

  • figsize (tuple of int, default (10, 8)) – Figure size as (width, height).

  • cmap (str, default 'RdBu_r') – Colormap to use in the heatmap.

  • cluster_cells (bool, default True) – Whether to use hierarchical clustering to order the cells.

  • add_dendrogram (bool, default False) – Whether to add a clustering dendrogram to the left of the plot.

  • group_cells (bool, default True) – Whether to group cells by the first array passed in **kwargs.

  • vmin (float, optional) – Minimum value for the colormap scale. Calculated automatically by default.

  • vmax (float, optional) – Maximum value for the colormap scale. Calculated automatically by default.

  • vcenter (float, default 0.0) – Center value for the colormap scale.

  • header (bool, default True) – Whether to add a header displaying cell and gene counts.

  • threads (int, default 1) – Number of threads to use for hierarchical clustering.

  • **kwargs (numpy.ndarray) – Named cell metadata arrays matching the cell dimension (e.g., sample, cell_type, subcluster). Each array adds a vertical color bar to the left of the plot. If group_cells=True, the first keyword argument stratifies the cell clustering.

Returns:

Returns the Matplotlib Figure object for further processing if output_file is None, otherwise returns None after saving to file.

Return type:

matplotlib.figure.Figure or None