Genetic distance

Genetic distance calculations.

See also the examples at:

anhima.dist.pairwise_distance(gn, metric=u'euclidean')[source]

Compute pairwise distance between samples.


gn : array_like

A 2-dimensional array of shape (n_variants, n_samples) where each element is a genotype call coded as a single integer counting the number of non-reference alleles.

metric : string or function, optional

The distance metric to use. See documentation for the function scipy.spatial.distance.pdist() for a list of supported distance metrics.


dist : ndarray, float

The distance matrix in compact form.

dist_square : ndarray, float

The distance matrix in square form.

anhima.dist.plot_pairwise_distance(dist_square, labels=None, colorbar=True, ax=None, vmin=None, vmax=None, cmap=u'jet', imshow_kwargs=None)[source]

Plot pairwise distances.


dist_square : array_like

The distance matrix in square form.

labels : sequence of strings, optional

Sample labels for the axes.

colorbar : bool, optional

If True, add a colorbar to the current figure.

ax : axes, optional

The axes on which to draw. If not provided, a new figure will be created.

vmin : float, optional

The minimum distance value for normalisation.

vmax : float, optional

The maximum distance value for normalisation.

cmap : string, optional

The color map for the image.

imshow_kwargs : dict-like, optional

Additional keyword arguments passed through to plt.imshow.


ax : axes

The axes on which the plot was drawn