Skip to content

Commit

Permalink
test loci_maf on subset of data
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed May 7, 2024
1 parent 1109f1d commit ad7c4f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/test_loci_freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ test_that("snpbin_list_means computes correctly",{
freq[freq>0.5] <- 1 - freq[freq>0.5]
expect_true(all(loci_maf(test_gt$genotypes)==freq))

# repeat the tests for a subset of the data
# remove the 2nd individual and the 3rd and 5th snp
test_genotypes <- test_genotypes[-2,c(-3,-5)]
test_gt <- test_gt %>% filter(id!="b") %>% select_loci(c(-3,-5))
freq <- colSums(test_genotypes, na.rm=TRUE)/(c(2,2,2,1)*2)
expect_true(all(loci_alt_freq(test_gt$genotypes)==freq))
# convert to minor frequencies
freq[freq>0.5] <- 1 - freq[freq>0.5]
expect_true(all(loci_maf(test_gt$genotypes)==freq))
})

0 comments on commit ad7c4f4

Please sign in to comment.