x = nuclearPed(1) |>
addSon(3) |>
addParents(4, father = 6, mother = 7) |>
addChildren(father = 6, mother = 7, nch = 3, sex = c(2,1,2))
# Remove 6 and 7 and their descendants
y1 = removeIndividuals(x, 6:7)
# Remove 8-10 and their parents
y2 = removeIndividuals(x, 8:10, remove = "ancestors")
# Adding a child across components
z = singletons(1:2, sex = 1:2) |> addDaughter(1:2)
# Extract a branch
w = cousinPed(1, child = TRUE)
w4 = branch(w, 4)
plot(list(w, w4))
# General subsetting depends on `missingParent`:
subset(w, c(3,7), missingParents = "exclude")
subset(w, c(3,7), missingParents = "include")
Run the code above in your browser using DataLab