vampire.anno.pl.haplotype_distance_heatmap

vampire.anno.pl.haplotype_distance_heatmap#

vampire.anno.pl.haplotype_distance_heatmap(adata, *, store_key='haplotype', metric='structural', deduplicate=False, reorder=True, cluster=False, colormap=None, figsize=(None, None), save=None, **kwargs)[source]#

Plot sample pairwise distance matrix from haplotype analysis.

Visualises one of the distance matrices stored in obsp by vp.anno.tl.haplotype_neighbor(). Samples are annotated by their haplotype assignment so that the block structure is visible.

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

  • store_key (str) – Key prefix matching store_key used in vp.anno.tl.haplotype_neighbor().

  • metric (str) – Which distance matrix to visualise. Options: "structural", "cnv".

  • deduplicate (bool) – If True, collapse samples with identical motif arrays into a single row. The track label shows the first sample name followed by ... (n=X) where X is the number of collapsed samples. The draw order follows the position of the first occurrence in sample_order.

  • reorder (bool) – If True, rows and columns are sorted by haplotype label so that samples from the same haplotype are adjacent.

  • cluster (bool) – If True, hierarchically cluster rows and columns (overrides reorder).

  • colormap (str | list[str] | None) – Plotly colormap for the heatmap. If None, defaults to a red-to-white scale.

  • figsize (tuple[int | None, int | None] | None) – Figure size in pixels. (None, None) triggers auto-computation from the matrix dimensions so that heatmap cells are square and labels are not clipped.

  • 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'}.

  • **kwargs – Additional arguments passed to heatmap_from_matrix.

Returns:

Plotly figure with the distance matrix heatmap.

Return type:

Figure

Examples

>>> import vampire as vp
>>> vp.anno.pl.set_default_plotstyle()
>>> adata = vp.datasets.wdr7_hprc()
>>> vp.anno.tl.sample_msa(adata)
>>> vp.anno.tl.haplotype_neighbor(adata)
>>> vp.anno.pl.haplotype_distance_heatmap(adata, metric = "structural")