def rogers_huff_r(gn):
    """Estimate the linkage disequilibrium parameter *r* for each pair of
    variants using the method of Rogers and Huff (2008).

    Parameters
    ----------
    gn : array_like, int8, shape (n_variants, n_samples)
        Diploid genotypes at biallelic variants, coded as the number of
        alternate alleles per call (i.e., 0 = hom ref, 1 = het, 2 = hom alt).

    Returns
    -------
    r : ndarray, float, shape (n_variants * (n_variants - 1) // 2,)
        Matrix in condensed form.

    Examples
    --------

    >>> import allel
    >>> g = allel.GenotypeArray([[[0, 0], [1, 1], [0, 0]],
    ...                          [[0, 0], [1, 1], [0, 0]],
    ...                          [[1, 1], [0, 0], [1, 1]],
    ...                          [[0, 0], [0, 1], [-1, -1]]], dtype='i1')
    >>> gn = g.to_n_alt(fill=-1)
    >>> gn
    array([[ 0,  2,  0],
           [ 0,  2,  0],
           [ 2,  0,  2],
           [ 0,  1, -1]], dtype=int8)
    >>> r = allel.rogers_huff_r(gn)
    >>> r  # doctest: +ELLIPSIS
    array([ 1.       , -1.0000001,  1.       , -1.0000001,  1.       ,
           -1.       ], dtype=float32)
    >>> r ** 2  # doctest: +ELLIPSIS
    array([1.       , 1.0000002, 1.       , 1.0000002, 1.       , 1.       ],
          dtype=float32)
    >>> from scipy.spatial.distance import squareform
    >>> squareform(r ** 2)
    array([[0.       , 1.       , 1.0000002, 1.       ],
           [1.       , 0.       , 1.0000002, 1.       ],
           [1.0000002, 1.0000002, 0.       , 1.       ],
           [1.       , 1.       , 1.       , 0.       ]], dtype=float32)

    """

    # check inputs
    gn = asarray_ndim(gn, 2, dtype='i1')
    gn = memoryview_safe(gn)

    # compute correlation coefficients
    r = gn_pairwise_corrcoef_int8(gn)

    # convenience for singletons
    if r.size == 1:
        r = r[0]

    return r
Estimate the linkage disequilibrium parameter *r* for each pair of
    variants using the method of Rogers and Huff (2008).

    Parameters
    ----------
    gn : array_like, int8, shape (n_variants, n_samples)
        Diploid genotypes at biallelic variants, coded as the number of
        alternate alleles per call (i.e., 0 = hom ref, 1 = het, 2 = hom alt).

    Returns
    -------
    r : ndarray, float, shape (n_variants * (n_variants - 1) // 2,)
        Matrix in condensed form.

    Examples
    --------

    >>> import allel
    >>> g = allel.GenotypeArray([[[0, 0], [1, 1], [0, 0]],
    ...                          [[0, 0], [1, 1], [0, 0]],
    ...                          [[1, 1], [0, 0], [1, 1]],
    ...                          [[0, 0], [0, 1], [-1, -1]]], dtype='i1')
    >>> gn = g.to_n_alt(fill=-1)
    >>> gn
    array([[ 0,  2,  0],
           [ 0,  2,  0],
           [ 2,  0,  2],
           [ 0,  1, -1]], dtype=int8)
    >>> r = allel.rogers_huff_r(gn)
    >>> r  # doctest: +ELLIPSIS
    array([ 1.       , -1.0000001,  1.       , -1.0000001,  1.       ,
           -1.       ], dtype=float32)
    >>> r ** 2  # doctest: +ELLIPSIS
    array([1.       , 1.0000002, 1.       , 1.0000002, 1.       , 1.       ],
          dtype=float32)
    >>> from scipy.spatial.distance import squareform
    >>> squareform(r ** 2)
    array([[0.       , 1.       , 1.0000002, 1.       ],
           [1.       , 0.       , 1.0000002, 1.       ],
           [1.0000002, 1.0000002, 0.       , 1.       ],
           [1.       , 1.       , 1.       , 0.       ]], dtype=float32)