malariagen_data.ag3.Ag3.plot_haplotype_clustering#

Ag3.plot_haplotype_clustering(region: str | Region | Mapping | List[str | Region | Mapping] | Tuple[str | Region | Mapping, ...], analysis: str = 'default', sample_sets: Sequence[str] | str | None = None, sample_query: str | None = None, cohort_size: int | None = None, random_seed: int = 42, color: str | None = None, symbol: str | None = None, linkage_method: Literal['single', 'complete', 'average', 'weighted', 'centroid', 'median', 'ward'] = 'single', count_sort: bool = True, distance_sort: bool = False, width: int | None = 1000, height: int | None = 500, show: bool = True, renderer: str | None = None, render_mode: Literal['auto', 'svg', 'webgl'] = 'auto', **kwargs) Figure | None#

Hierarchically cluster haplotypes in region and produce an interactive plot.

Parameters#

regionstr or Region or Mapping or list of str or Region or Mapping or tuple of str or Region or Mapping

Region of the reference genome. Can be a contig name, region string (formatted like “{contig}:{start}-{end}”), or identifier of a genome feature such as a gene or transcript. Can also be a sequence (e.g., list) of regions.

analysisstr, optional, default: ‘default’

Which haplotype phasing analysis to use. See the phasing_analysis_ids property for available values.

sample_setssequence of str or str or None, optional

List of sample sets and/or releases. Can also be a single sample set or release.

sample_querystr or None, optional

A pandas query string to be evaluated against the sample metadata, to select samples to be included in the returned data.

cohort_sizeint or None, optional

Randomly down-sample to this value if the number of samples in the cohort is greater. Raise an error if the number of samples is less than this value.

random_seedint, optional, default: 42

Random seed used for reproducible down-sampling.

colorstr or None, optional

Name of variable to use to color the markers.

symbolstr or None, optional

Name of the variable to use to choose marker symbols.

linkage_method{‘single’, ‘complete’, ‘average’, ‘weighted’, ‘centroid’, ‘median’, ‘ward’}, optional, default: ‘single’

The linkage algorithm to use. See the Linkage Methods section of the scipy.cluster.hierarchy.linkage docs for full descriptions.

count_sortbool, optional, default: True

For each node n, the order (visually, from left-to-right) n’s two descendant links are plotted is determined by this parameter. If True, the child with the minimum number of original objects in its cluster is plotted first. Note distance_sort and count_sort cannot both be True.

distance_sortbool, optional, default: False

For each node n, the order (visually, from left-to-right) n’s two descendant links are plotted is determined by this parameter. If True, The child with the minimum distance between its direct descendants is plotted first.

widthint or None, optional, default: 1000

Plot width in pixels (px).

heightint or None, optional, default: 500

Plot height in pixels (px).

showbool, optional, default: True

If true, show the plot. If False, do not show the plot, but return the figure.

rendererstr or None, optional

The name of the renderer to use.

render_mode{‘auto’, ‘svg’, ‘webgl’}, optional, default: ‘auto’

The type of rendering backend to use. See also https://plotly.com/python/webgl-vs-svg/.

**kwargs

Passed through to px.scatter().

Returns#

Figure or None

A plotly figure (only returned if show=False).