Identifies which of a subjects two haplotyes is the maternal haplotype and which is the paternal haplotype.

get_phased_ancestry(sample, haps_matrix)

Arguments

sample

A dataframe in .sample format. sample$father gives the index of the father in the haps_matrix, and the sample$mother gives the index of the the mother in the haps_matrix.

haps_matrix

A n x p matrix of 0-1. Each row represents one haplotypes. To convert from indices to haplotype indices, an entry i in sample$father corresponds to the two rows 2*i - 1 and 2*i in haps_matrix.

Value

A data frame with the following elements:

subject: the row ID of the subject. An entry of i corresponds to rows 2*i -1 and 2*i of haps_matrix.

chromosome: the chromosome number 1-22.

ancestor_1: the ID of the ancestor corresponding to the first haplotype of the offspring in haps_matrix.

ancestor_2: the ID of the ancestor corresponding to the second haplotype of the offspring in haps_matrix.