Generate a matrix or 3D array with all pairwise relationships from a pedigree or dataframe with pairs.
GetRelM(
Pedigree = NULL,
Pairs = NULL,
GenBack = 1,
patmat = FALSE,
Return = "Matrix"
)
dataframe with columns id - dam - sire.
dataframe with columns ID1 - ID2 - Rel.
number of generations back to consider; 1 returns parent-offspring and sibling relationships, 2 also returns grand-parental, avuncular and first cousins.
logical, distinguish between paternal versus maternal relative pairs? For avuncular pairs, the distinction is never made.
'Matrix' or 'Array'. The former returns an N x N matrix with the closest relationship between each pair, the latter an N x N x R array with for each of the R considered relationships whether it exists between the pair (1) or not (0). See Details below.
If Return='Matrix'
, an N x N square matrix, with N equal to
the number of rows in Pedigree
(after running
PedPolish
) or the number of unique individuals in
Pairs
. If Return='Array'
, an N x N x R array is returned,
with R, the number of different relationships, determined by GenBack
and patmat
.
The following abbreviations are used within the returned Matrix
, or as
names of the 3rd dimension in the Array
:
Self
Mother
Father
Mother or Father (patmat=FALSE
)
Offspring
Full sibling
Maternal half-sibling
Paternal half-sibling
other half-sibling (hermaphrodites)
half-sibling (patmat=FALSE
)
Maternal grandmother
Maternal grandfather
Paternal grandmother
Paternal grandfather
Grandparent (patmat=FALSE
)
Grand-offspring
Full avuncular; maternal or paternal aunt or uncle
Half avuncular
Full nephew/niece
Half nephew/niece
Full first cousin
Double full first cousin
Unrelated (or otherwise related)
Double relationships are ignored when Return='Matrix'
, but
not when Return='Array'
. For example, when A and B are both
mother-offspring and paternal siblings (A mated with her father to produce
B), only the mother-offspring relationship will be indicated when
Return='Matrix'
.
Note that full siblings are the exception to this rule: in the Array
they will be indicated as 'FS' only, and not as 'MHS' or 'PHS'. Similarly,
full avuncular pairs are not indicated as 'HA'.
When Pairs
is provided, GenBack
and patmat
are
ignored, and no check is performed if the abbreviations are compatible with
other functions.
ComparePairs
for comparing pairwise relationships
between two pedigrees; PlotRelPairs
.
# NOT RUN {
data(Ped_griffin)
Rel.griffin <- GetRelM(Ped_griffin, patmat=TRUE, GenBack=2)
table(c(Rel.griffin))
# turning matrix into vector first makes table() much faster
PlotRelPairs(Rel.griffin)
# }
Run the code above in your browser using DataLab