An equivalent to dplyr::select_if()
that works on the genotype
column
of a gen_tibble
. This function has access to the genotypes (and thus can
work on summary statistics to select), but not the names of the loci (look
at select_loci()
for that feature.
Details
#' Note that the select_loci_if
verb does not modify the backing FBM files,
but rather it subsets the list of loci to be used stored in the gen_tibble
.
Examples
example_gt <- example_gt("gen_tbl")
# Select loci by chromosome
example_gt_subset <- example_gt %>%
select_loci_if(loci_chromosomes(genotypes) == "chr2")
show_loci(example_gt_subset)
#> # A tibble: 2 × 8
#> big_index name chromosome position genetic_dist allele_ref allele_alt chr_int
#> <int> <chr> <chr> <int> <dbl> <chr> <chr> <int>
#> 1 5 rs5 chr2 23 0 C G 2
#> 2 6 rs6 chr2 456 0 T A 2
# Select loci by a summary statistic
example_gt_subset <- example_gt %>%
select_loci_if(loci_maf(genotypes) > 0.2)
show_loci(example_gt_subset)
#> # A tibble: 5 × 8
#> big_index name chromosome position genetic_dist allele_ref allele_alt chr_int
#> <int> <chr> <chr> <int> <dbl> <chr> <chr> <int>
#> 1 1 rs1 chr1 3 0 A T 1
#> 2 2 rs2 chr1 5 0 T C 1
#> 3 4 rs4 chr1 343 0 G C 1
#> 4 5 rs5 chr2 23 0 C G 2
#> 5 6 rs6 chr2 456 0 T A 2