Skip to content

Commit

Permalink
test grouped version of indiv_inbreeding
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed Dec 7, 2024
1 parent 4b34514 commit 0a0aa40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion R/indiv_inbreeding.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ indiv_inbreeding.grouped_df <- function(.x, method = c("WG17"), allele_sharing_m
if (!is.null(allele_sharing_mat)){
stop("allele_sharing_mat can not be provided for grouped_df objects")
}
message("the grouped version of this function has not been fully tested yet")
group_map(.x, .f=~indiv_inbreeding(.x, method = method, allele_sharing_mat=NULL))
}
8 changes: 8 additions & 0 deletions tests/testthat/test_indiv_inbreeding.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@ test_that("indiv_inbreeding compute correctly",{
test_gt <- test_gt %>% dplyr::group_by(population)
# is this right???
inbreed_group_gt <- test_gt %>% indiv_inbreeding(method = "WG17")
# subset gentibble to a single population, pop 1
pop1_gt <- test_gt %>% dplyr::filter(population == "pop1")
inbreed_pop1_hier <- diag(hierfstat::beta.dosage(show_genotypes(pop1_gt)))
expect_true(all.equal(inbreed_pop1_hier, inbreed_group_gt[[1]], check.attributes = FALSE))
# subset gentibble to a single population, pop 2
pop2_gt <- test_gt %>% dplyr::filter(population == "pop2")
inbreed_pop2_hier <- diag(hierfstat::beta.dosage(show_genotypes(pop2_gt)))
expect_true(all.equal(inbreed_pop2_hier, inbreed_group_gt[[2]], check.attributes = FALSE))

})

0 comments on commit 0a0aa40

Please sign in to comment.