def plot_pairwise_ld(m, colorbar=True, ax=None, imshow_kwargs=None):
    """Plot a matrix of genotype linkage disequilibrium values between
    all pairs of variants.

    Parameters
    ----------
    m : array_like
        Array of linkage disequilibrium values in condensed form.
    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.
    imshow_kwargs : dict-like, optional
        Additional keyword arguments passed through to
        :func:`matplotlib.pyplot.imshow`.

    Returns
    -------
    ax : axes
        The axes on which the plot was drawn.

    """

    import matplotlib.pyplot as plt

    # check inputs
    m_square = ensure_square(m)

    # blank out lower triangle and flip up/down
    m_square = np.tril(m_square)[::-1, :]

    # set up axes
    if ax is None:
        # make a square figure with enough pixels to represent each variant
        x = m_square.shape[0] / plt.rcParams['figure.dpi']
        x = max(x, plt.rcParams['figure.figsize'][0])
        fig, ax = plt.subplots(figsize=(x, x))
        fig.tight_layout(pad=0)

    # setup imshow arguments
    if imshow_kwargs is None:
        imshow_kwargs = dict()
    imshow_kwargs.setdefault('interpolation', 'none')
    imshow_kwargs.setdefault('cmap', 'Greys')
    imshow_kwargs.setdefault('vmin', 0)
    imshow_kwargs.setdefault('vmax', 1)

    # plot as image
    im = ax.imshow(m_square, **imshow_kwargs)

    # tidy up
    ax.set_xticks([])
    ax.set_yticks([])
    for s in 'bottom', 'right':
        ax.spines[s].set_visible(False)
    if colorbar:
        plt.gcf().colorbar(im, shrink=.5, pad=0)

    return ax
def plot_pairwise_ld ( m , colorbar = True , ax = None , imshow_kwargs = None ) : import matplotlib . pyplot as plt m_square = ensure_square ( m ) m_square = np . tril ( m_square ) [ : : - 1 , : ] if ax is None : x = m_square . shape [ 0 ] / plt . rcParams [ 'figure.dpi' ] x = max ( x , plt . rcParams [ 'figure.figsize' ] [ 0 ] ) fig , ax = plt . subplots ( figsize = ( x , x ) ) fig . tight_layout ( pad = 0 ) if imshow_kwargs is None : imshow_kwargs = dict ( ) imshow_kwargs . setdefault ( 'interpolation' , 'none' ) imshow_kwargs . setdefault ( 'cmap' , 'Greys' ) imshow_kwargs . setdefault ( 'vmin' , 0 ) imshow_kwargs . setdefault ( 'vmax' , 1 ) im = ax . imshow ( m_square , ** imshow_kwargs ) ax . set_xticks ( [ ] ) ax . set_yticks ( [ ] ) for s in 'bottom' , 'right' : ax . spines [ s ] . set_visible ( False ) if colorbar : plt . gcf ( ) . colorbar ( im , shrink = .5 , pad = 0 ) return ax
Plot a matrix of genotype linkage disequilibrium values between
    all pairs of variants.

    Parameters
    ----------
    m : array_like
        Array of linkage disequilibrium values in condensed form.
    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.
    imshow_kwargs : dict-like, optional
        Additional keyword arguments passed through to
        :func:`matplotlib.pyplot.imshow`.

    Returns
    -------
    ax : axes
        The axes on which the plot was drawn.