Skip to content

Commit

Permalink
small clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed Apr 22, 2024
1 parent 022824d commit 87948f6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
8 changes: 1 addition & 7 deletions R/gen_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,8 @@ check_allele_alphabet <- function(x,

}

# make all missing value equal to 0
# set all missing values to NA
# loci_info is usually from show_loci()
#harmonise_missing_values <- function (loci_info, missing_alleles =c("0",".")){
# loci_info$allele_ref[loci_info$allele_ref %in% missing_alleles]<-"0"
# loci_info$allele_alt[loci_info$allele_alt %in% missing_alleles]<-"0"
# return(loci_info)
#}

harmonise_missing_values <- function (loci_info, missing_alleles =c("0",".")){
# 0 is always considered as a missing value
if ("0" %in% missing_alleles){
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test_gen_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ bed_path <- gt_write_bed_from_dfs(genotypes = test_genotypes,
path_out = tempfile('test_data_'))
test_gt <- gen_tibble(bed_path, quiet = TRUE)

# we now replace NA with 0 for the test_loci
#test_loci[is.na(test_loci)]<-"0"

# this also tests show_genotypes and show_loci
test_that("create gen_tibble from bed",{
expect_true(inherits(test_gt,"gen_tbl"))
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_gen_tibble_save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ bed_path <- gt_write_bed_from_dfs(genotypes = test_genotypes,
path_out = tempfile('test_data_'))
test_gt <- gen_tibble(bed_path, quiet = TRUE)

# we now replace NA with 0 for the test_loci
#test_loci[is.na(test_loci)]<-"0"

# this also tests show_genotypes and show_loci
test_that("save and load gt",{
expect_true(inherits(test_gt,"gen_tbl"))
Expand All @@ -43,9 +40,12 @@ test_that("save and load gt",{
expect_true(file.copy(from=all_file_names[3],
to=file.path(new_dir, basename(all_file_names[3]))))
expect_true(file.remove(all_file_names[2]))

#expect_true(file.remove(all_file_names[3]))
#TODO the above test fails on Windows,
#needs a fix after response to bistatsr issue


# loading should fail
expect_error(new_test_gt2 <- gt_load(all_file_names[1]))
# this should now work:
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test_show_loci.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ test_that("show_loci gets and sets information",{
path_out = tempfile('test_data_'))
test_gt <- gen_tibble(bed_path, quiet = TRUE)

# we now replace NA with 0 for the test_loci
#test_loci[is.na(test_loci)]<-"0"


# check that we retrieve the info we put in (as a tibble)
expect_identical(show_loci(test_gt) %>% select(-big_index),as_tibble(test_loci))
# now change it directly on the genotype column
Expand Down

0 comments on commit 87948f6

Please sign in to comment.