-
Notifications
You must be signed in to change notification settings - Fork 0
/
genlib.R
24 lines (16 loc) · 862 Bytes
/
genlib.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
###########################@ GENLIB functions @############################
library("GENLIB")
?`GenlibR-package`
saguenay <- as.data.frame(read_excel("C:/Users/walid/OneDrive/Bureau/Work/Pedigree/Saguenay_ind.xlsx"))
saguenay[,6] <- NULL
saguenay$datn <- as.numeric(format(as.Date(saguenay$datn, format = "%Y-%m-%d"),"%Y")) #extract only birth year
saguenay <- saguenay[saguenay$sexe != 9,] #remove individuals with unknown sex
####setting up genlib object
saguenay_genlib <- cbind.data.frame("ind"=saguenay$ind,"father"=saguenay$pere,"mother"=saguenay$mere,"sex"=saguenay$sexe)
sag_gen <- gen.genealogy(saguenay_genlib, autoComplete = TRUE)
####getting number of children
ped_sag$n_child <- rep(0,nrow(ped_sag))
ind <- ped_sag$ind
for (i in ind) {
ped_sag[ped_sag$ind == i,]$n_child <- gen.nochildren(sag_gen, individuals = i)
}