This function finds duplicated SNPs by checking the positions within each chromosome. It can return a list of duplicated SNPs or a logical value indicating whether there are any duplicated loci.
Arguments
- .x
a vector of class
vctrs_bigSNP
(usually thegenotype
column of agen_tibble
object), or agen_tibble
.- error_on_false
logical, if
TRUE
an error is thrown if duplicated loci are found.- list_duplicates
logical, if
TRUE
returns duplicated SNP names.- ...
other arguments passed to specific methods.
Value
if list_duplicates
is TRUE, returns a vector of duplicated loci.
If list_duplicates
is FALSE, returns a logical value indicating whether
there are any duplicated loci. If error_on_false
is TRUE and there are
duplicates, an error is thrown.
Examples
example_gt <- load_example_gt("gen_tbl")
show_loci(example_gt) <- test_loci <- data.frame(
big_index = c(1:6),
name = paste0("rs", 1:6),
chromosome = paste0("chr", c(1, 1, 1, 1, 1, 1)),
position = as.integer(c(3, 3, 5, 65, 343, 46)),
genetic_dist = as.double(rep(0, 6)),
allele_ref = c("A", "T", "C", "G", "C", "T"),
allele_alt = c("T", "C", NA, "C", "G", "A"),
chr_int = rep(1, 6)
)
show_loci(example_gt)
#> # A tibble: 6 × 8
#> big_index name chromosome position genetic_dist allele_ref allele_alt chr_int
#> <int> <chr> <chr> <int> <dbl> <chr> <chr> <dbl>
#> 1 1 rs1 chr1 3 0 A T 1
#> 2 2 rs2 chr1 3 0 T C 1
#> 3 3 rs3 chr1 5 0 C NA 1
#> 4 4 rs4 chr1 65 0 G C 1
#> 5 5 rs5 chr1 343 0 C G 1
#> 6 6 rs6 chr1 46 0 T A 1
# Find which loci are duplicated
example_gt %>% find_duplicated_loci()
#> [1] "rs1" "rs2"