ComparePairs {sequoia} | R Documentation |
Compare Pairwise Relationships
Description
Compare, count and identify different types of relative pairs between two pedigrees, or within one pedigree.
Usage
ComparePairs(
Ped1 = NULL,
Ped2 = NULL,
Pairs2 = NULL,
GenBack = 1,
patmat = FALSE,
ExcludeDummies = TRUE,
DumPrefix = c("F0", "M0"),
Return = "Counts"
)
Arguments
Ped1 |
first (e.g. original/reference) pedigree, dataframe with 3 columns: id-dam-sire. |
Ped2 |
optional second (e.g. inferred) pedigree. |
Pairs2 |
optional dataframe with as first three columns: ID1-ID2-
relationship, e.g. as returned by |
GenBack |
number of generations back to consider; 1 returns parent-offspring and sibling relationships, 2 also returns grandparental, avuncular and first cousins. GenBack >2 is not implemented. |
patmat |
logical, distinguish between paternal versus maternal relative pairs? |
ExcludeDummies |
logical, exclude dummy IDs from output? Individuals
with e.g. the same dummy father will still be counted as paternal halfsibs.
No attempt is made to match dummies in one pedigree to individuals in the
other pedigree; for that use |
DumPrefix |
character vector with the prefixes identifying dummy
individuals. Use 'F0' ('M0') to avoid matching to regular individuals with
IDs starting with 'F' ('M'), provided |
Return |
return a matrix with |
Details
If Pairs2
is as returned by GetMaybeRel
(identified by the additional column names 'LLR' and 'OH'), these
relationship categories are appended with an '?' in the output, to
distinguish them from those derived from Ped2
.
When Pairs2$TopRel
contains values other than the ones listed among
the return values for the combination of patmat
and GenBack
,
they are prioritised in decreasing order of factor levels, or in decreasing
alphabetical order, and before the default (ped2
derived) levels.
The matrix returned by DyadCompare
[Deprecated] is a subset
of the matrix returned here using default settings.
Value
Depending on Return
, one of the following, or a list with all:
Counts |
(the default), a matrix with counts, with the classification in
|
Summary |
a matrix with one row per relationship type and four columns
, named as if
|
Array |
a 2xNxN array (if |
Dataframe |
a dataframe with
Each pair is listed twice, e.g. once as P and once as O, or twice as FS. |
Relationship abbreviations and ranking
By default (GenBack=1, patmat=FALSE
) the following 7 relationships are
distinguished:
-
S: Self (not included in
Counts
) -
MP: Parent
-
O: Offspring (not included in
Counts
) -
FS: Full sibling
-
HS: Half sibling
-
U: Unrelated, or otherwise related
-
X: Either or both individuals not occurring in both pedigrees
In the array and dataframe, 'MP' indicates that the second (column) individual is the parent of the first (row) individual, and 'O' indicates the reverse.
When GenBack=1, patmat=TRUE
the categories are (S)-M-P-(O)-FS-MHS-PHS-
U-X.
When GenBack=2, patmat=TRUE
, the following relationships are
distinguished:
-
S: Self (not included in
Counts
) -
M: Mother
-
P: Father
-
O: Offspring (not included in
Counts
) -
FS: Full sibling
-
MHS: Maternal half-sibling
-
PHS: Paternal half-sibling
-
MGM: Maternal grandmother
-
MGF: Maternal grandfather
-
PGM: Paternal grandmother
-
PGF: Paternal grandfather
-
GO: Grand-offspring (not included in
Counts
) -
FA: Full avuncular; maternal or paternal aunt or uncle
-
HA: Half avuncular
-
FN: Full nephew/niece (not included in
Counts
) -
HN: Half nephew/niece (not included in
Counts
) -
FC1: Full first cousin
-
DFC1: Double full first cousin
-
U: Unrelated, or otherwise related
-
X: Either or both individuals not occurring in both pedigrees
Note that for avuncular and cousin relationships no distinction is made
between paternal versus maternal, as this may differ between the two
individuals and would generate a large number of sub-classes. When a pair is
related via multiple paths, the first-listed relationship is returned. To get
all the different paths between a pair, use GetRelM
with
Return='Array'
.
When GenBack=2, patmat=FALSE
, MGM, MGF, PGM and PGF are combined
into GP, with the rest of the categories analogous to the above.
See Also
PedCompare
for individual-based comparison;
GetRelM
for a pairwise relationships matrix of a single
pedigree; PlotRelPairs
for visualisation of relationships
within each pedigree.
To estimate P(actual relationship (Ped1) | inferred relationship (Ped2)),
see examples at EstConf
.
Examples
PairsG <- ComparePairs(Ped_griffin, SeqOUT_griffin[["Pedigree"]],
patmat = TRUE, ExcludeDummies = TRUE, Return = "All")
PairsG$Counts
# pairwise correct assignment rate:
PairsG$Summary[,"OK"] / PairsG$Summary[,"n"]
# check specific pair:
PairsG$Array[, "i190_2010_M", "i168_2009_F"]
# or
RelDF <- PairsG$Dataframe # for brevity
RelDF[RelDF$id.A=="i190_2010_M" & RelDF$id.B=="i168_2009_F", ]
# Colony-style lists of full sib dyads & half sib dyads:
FullSibDyads <- with(RelDF, RelDF[Ped1 == "FS" & id.A < id.B, ])
HalfSibDyads <- with(RelDF, RelDF[Ped1 == "HS" & id.A < id.B, ])
# Use 'id.A < id.B' because each pair is listed 2x