def rogers_huff_r_between(gna, gnb, fill=np.nan): """Estimate the linkage disequilibrium parameter *r* for each pair of variants between the two input arrays, using the method of Rogers and Huff (2008). Parameters ---------- gna, gnb : 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). fill : float, optional Value to use where r cannot be calculated. Returns ------- r : ndarray, float, shape (m_variants, n_variants ) Matrix in rectangular form. """ # check inputs gna = asarray_ndim(gna, 2, dtype='i1') gnb = asarray_ndim(gnb, 2, dtype='i1') # compute correlation coefficients r = gn_pairwise2_corrcoef_int8(gna, gnb, fill) # convenience for singletons if r.size == 1: r = r[0, 0] return r
def rogers_huff_r_between(gna, gnb, fill=np.nan): """Estimate the linkage disequilibrium parameter *r* for each pair of variants between the two input arrays, using the method of Rogers and Huff (2008). Parameters ---------- gna, gnb : 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 (m_variants, n_variants ) Matrix in rectangular form. """ # check inputs gna = asarray_ndim(gna, 2, dtype='i1') gnb = asarray_ndim(gnb, 2, dtype='i1') # compute correlation coefficients from allel.opt.stats import gn_pairwise2_corrcoef_int8 r = gn_pairwise2_corrcoef_int8(gna, gnb, fill) # convenience for singletons if r.size == 1: r = r[0, 0] return r