Example #1
0
def phase_parents_by_transmission(g, window_size):
    """Phase parent genotypes from a trio or cross, given progeny genotypes
    already phased by Mendelian transmission.

    Parameters
    ----------
    g : GenotypeArray
        Genotype array, with parents as first two columns and progeny as
        remaining columns, where progeny genotypes are already phased.
    window_size : int
        Number of previous heterozygous sites to include when phasing each
        parent. A number somewhere between 10 and 100 may be appropriate,
        depending on levels of heterozygosity and quality of data.

    Returns
    -------
    g : GenotypeArray
        Genotype array with parents phased where possible.

    """

    # setup
    check_type(g, GenotypeArray)
    check_dtype(g.values, 'i1')
    check_ploidy(g.ploidy, 2)
    if g.is_phased is None:
        raise ValueError('genotype array must first have progeny phased by transmission')
    check_min_samples(g.n_samples, 3)

    # run the phasing
    is_phased = g.is_phased.view('u1')
    phase_parents_by_transmission_int8(g.values, is_phased, window_size)

    # outputs
    return g
Example #2
0
 def is_phased(self, is_phased):
     if is_phased is not None:
         is_phased = ensure_dask_array(is_phased, self.chunks[:-1])
         check_shape(is_phased, self.shape[:-1])
         check_dtype(is_phased, bool)
     self._is_phased = is_phased
Example #3
0
 def mask(self, mask):
     if mask is not None:
         mask = ensure_dask_array(mask, self.chunks[:-1])
         check_shape(mask, self.shape[:-1])
         check_dtype(mask, bool)
     self._mask = mask