S4 class to represent the special relationships in a Pedigree.
Usage
# S4 method for class 'data.frame'
Rel(obj)
# S4 method for class 'character_OR_integer'
Rel(obj, id2, code, famid = NA_character_)
Arguments
- obj
A character vector with the id of the first individuals of each pairs or a
data.frame
with all the informations in corresponding columns.- id2
A character vector with the id of the second individuals of each pairs
- code
A character, factor or numeric vector corresponding to the relation code of the individuals:
MZ twin = Monozygotic twin
DZ twin = Dizygotic twin
UZ twin = twin of unknown zygosity
Spouse = Spouse The following values are recognized:
character() or factor() : "MZ twin", "DZ twin", "UZ twin", "Spouse" with of without space between the words. The case is not important.
numeric() : 1 = "MZ twin", 2 = "DZ twin", 3 = "UZ twin", 4 = "Spouse"
- famid
A character vector with the family identifiers of the individuals. If provide, will be aggregated to the individuals identifiers separated by an underscore.
Details
A Rel object is a list of special relationships
between individuals in the pedigree.
It is used to create a Pedigree object.
The minimal needed informations are id1
, id2
and code
.
If a famid
is provided, the individuals id
will be aggregated
to the famid
character to ensure the uniqueness of the id
.
Slots
id1
A character vector with the id of the first individual.
id2
A character vector with the id of the second individual.
code
An ordered factor vector with the code of the special relationship.
(i.e.
MZ twin
<DZ twin
<UZ twin
<Spouse
).famid
A character vector with the famid of the individuals.
Accessors
For all the following accessors, the x
parameters is a Rel object.
Each getters return a vector of the same length as x
with the values
of the corresponding slot.
code(x)
: Relationships' code
id1(x)
: Relationships' first individuals' identifier
id2(x)
: Relationships' second individuals' identifier
famid(x)
: Relationships' individuals' family identifier
famid(x) <- value
: Set the relationships' individuals' family identifiervalue
: A character or integer vector of the same length as x with the family identifiers
Generics
summary(x)
: Compute the summary of a Rel object
show(x)
: Convert the Rel object to a data.frame and print it with its summary.
as.list(x)
: Convert a Rel object to a list
as.data.frame(x)
: Convert a Rel object to a data.frame
subset(x, i, keep = TRUE)
: Subset a Rel object based on the individuals identifiers given.i
: A vector of individuals identifiers to keep.keep
: A logical value indicating if the individuals should be kept or deleted.
Examples
rel_df <- data.frame(
id1 = c("1", "2", "3"),
id2 = c("2", "3", "4"),
code = c(1, 2, 3)
)
Rel(rel_df)
#> Rel object with 3 relationshipswith 1 MZ twin, 1 DZ twin, 1 UZ twin, 0 Spouse:
#> id1 id2 code famid
#> <character> <character> <c("ordered", "factor")> <character>
#> 1 1 2 MZ twin <NA>
#> 2 2 3 DZ twin <NA>
#> 3 3 4 UZ twin <NA>
Rel(
obj = c("1", "2", "3"),
id2 = c("2", "3", "4"),
code = c(1, 2, 3)
)
#> Rel object with 3 relationshipswith 1 MZ twin, 1 DZ twin, 1 UZ twin, 0 Spouse:
#> id1 id2 code famid
#> <character> <character> <c("ordered", "factor")> <character>
#> 1 1 2 MZ twin <NA>
#> 2 2 3 DZ twin <NA>
#> 3 3 4 UZ twin <NA>