Describe the bug
The diagonal for the additive relatedness matrix is not reflecting 1 when both parents are present. Instead, it is getting set to .5 because somehow the parents aren't being registered as present. The same build is fine for other datasets, it's just this dog dataset....
12917_2019_2146_MOESM4_ESM.xlsx
ped <- readxl::read_xlsx("data-raw/12917_2019_2146_MOESM4_ESM.xlsx",
) %>%
janitor::clean_names() %>%
rename(
personID = id_of_the_individual,
dadID = id_of_the_sire,
momID = id_of_the_dam,
litterID = id_of_the_litter
)
puppy_repaired <- recodeSex(ped,
code_male = 1,
code_female = 2
) %>% checkSex(.,
code_male = 1,
code_female = 2,
verbose = TRUE,
repair = TRUE
) %>% rename(
personID = ID)
puppy_repaired_skin <- puppy_repaired %>% ped2fam(personID="personID") %>%
filter(litterID<155) %>%
select(personID, momID, dadID, famID, sex) %>%
mutate(personID = as.character(personID),
momID = as.character(momID),
dadID = as.character(dadID),
famID = as.character(famID))
pedadd <- ped2com(ped = puppy_repaired_skin,component = "additive",
personID = "personID",
momID = "momID",
dadID = "dadID",
verbose = TRUE,
sparse=F,
saveable =T)
# force_symmetric = T,
# mz_twins =F,
# adjacency_method = "loop",
# isChild_method = "classic")
diag(pedadd) %>% summary()
output
Preparing checkpointing...
Standardizing column names...
Family Size = 842
Building parent adjacency matrix...
Computing parent-child adjacency matrix...
Final checkpoint saved for adjacency matrix.
Constructed sparse matrix
Initializing adjacency matrix...
Completed first degree relatives (adjacency)
Computing isChild matrix...
About to do RAM path tracing
Completed 0 degree relatives
Completed RAM path tracing
Doing I-A inverse times diagonal multiplication
Doing tcrossprod
> diag(pedadd) %>% summary()
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.5000 0.5000 0.5000 0.5154 0.5000 0.6250
In contrast from the same session:
> library(BGmisc)
> library(ggpedigree)
> data("redsquirrels")
>
> # Set up the data
> # sumped <- BGmisc::summarizePedigrees(redsquirrels,
> # famID = "famID",
> # personID = "personID",
> # nbiggest = 5
> # )
>
>
> # Set target family for visualization
> fam_filter <- 160 # sumped$biggest_families$famID[3]
>
> # Filter for reasonably sized family, recode sex if needed
> ped_filtered <- redsquirrels %>%
+ BGmisc::recodeSex(code_female = "F") %>%
+ dplyr::filter(famID == fam_filter)
>
> # Calculate relatedness matrices
> add_mat <- BGmisc::ped2add(ped_filtered, isChild_method = "partialparent", sparse = FALSE)
> diag(add_mat) %>% summary()
Min. 1st Qu. Median Mean 3rd Qu. Max.
1 1 1 1 1 1
Describe the bug
The diagonal for the additive relatedness matrix is not reflecting 1 when both parents are present. Instead, it is getting set to .5 because somehow the parents aren't being registered as present. The same build is fine for other datasets, it's just this dog dataset....
12917_2019_2146_MOESM4_ESM.xlsx
output
In contrast from the same session: