fixParents.RdFix the sex of parents, add parents that are missing from the pedigree
fixParents(id, dadid, momid, sex, missid = 0)Identification variable for individual
Identification variable for father. Founders parents should be coded to NA, or another value specified by missid.
Identification variable for mother. Founders parents should be coded to NA, or another value specified by missid.
Gender of individual noted in `id`. Either character ("male","female","unknown","terminated") or numeric (1="male", 2="female", 3="unknown", 4="terminated") data is allowed. For character data the string may be truncated, and of arbitrary case.
The founders are those with no father or mother in the pedigree. The
dadid and momid values for these subjects will either be
NA or the value of this variable. The default for missid is 0
if the id variable is numeric, and "" (the empty string)
otherwise.
A data.frame with id, dadid, momid, sex as columns
First look to add parents whose ids are given in momid/dadid. Second, fix sex of parents. Last look to add second parent for children for whom only one parent id is given.
test1char <- data.frame(id=paste("fam", 101:111, sep=""),
sex=c("male","female")[c(1,2,1,2,1, 1,2, 2,1,2, 1)],
father=c(0,0,"fam101","fam101","fam101", 0,0,"fam106","fam106","fam106", "fam109"),
mother=c(0,0,"fam102","fam102","fam102", 0,0,"fam107","fam107","fam107", "fam112"))
test1newmom <- with(test1char, fixParents(id, father, mother, sex, missid="0"))
newped <- with(test1newmom, pedigree(id, dadid, momid, sex, missid="0"))
as.data.frame(newped)
#> id dadid momid sex
#> 1 fam101 0 0 male
#> 2 fam102 0 0 female
#> 3 fam103 fam101 fam102 male
#> 4 fam104 fam101 fam102 female
#> 5 fam105 fam101 fam102 male
#> 6 fam106 0 0 male
#> 7 fam107 0 0 female
#> 8 fam108 fam106 fam107 female
#> 9 fam109 fam106 fam107 male
#> 10 fam110 fam106 fam107 female
#> 11 fam111 fam109 fam112 male
#> 12 fam112 0 0 female