View source: R/rbind_dry_run.R
rbind_dry_run | R Documentation |
This function provides an overview of the fate of each SNP in two
gen_tibble
objects in the case of a merge. Only SNPs found in both
objects will be kept. One object is used as a reference
, and SNPs in the
other dataset will be flipped and/or alleles swapped as needed. SNPs that
have different alleles in the two datasets will also be dropped.
rbind_dry_run(
ref,
target,
use_position = FALSE,
flip_strand = FALSE,
quiet = FALSE
)
ref |
either a |
target |
either a |
use_position |
boolean of whether a combination of chromosome and
position should be used for matching SNPs. By default, |
flip_strand |
boolean on whether strand flipping should be checked to match the two datasets. Ambiguous SNPs (i.e. A/T and C/G) will also be removed. It defaults to FALSE |
quiet |
boolean whether to omit reporting to screen |
a list with two data.frames
, named target
and ref
. Each
data.frame has nrow()
equal to the number of loci in the respective
dataset, a column id
with the locus name, and boolean columns to_keep
(the valid loci that will be kept in the merge), alleles_mismatched
(loci
found in both datasets but with mismatched alleles, leading to those loci
being dropped), to_flip
(loci that need to be flipped to align the two
datasets, only found in target
data.frame) and to_swap
(loci for which
the order of alleles needs to be swapped to align the two datasets,
target
data.frame)
example_gt <- load_example_gt("gen_tbl")
# Create a second gen_tibble to merge
test_indiv_meta <- data.frame(
id = c("x", "y", "z"),
population = c("pop1", "pop1", "pop2")
)
test_genotypes <- rbind(
c(1, 1, 2, 1, 1),
c(2, 1, 2, 0, 0),
c(2, 2, 2, 0, 1)
)
test_loci <- data.frame(
name = paste0("rs", 1:5),
chromosome = paste0("chr", c(1, 1, 1, 1, 2)),
position = as.integer(c(3, 5, 65, 343, 23)),
genetic_dist = as.double(rep(0, 5)),
allele_ref = c("A", "T", "C", "G", "C"),
allele_alt = c("T", "C", NA, "C", "G")
)
test_gt <- gen_tibble(
x = test_genotypes,
loci = test_loci,
indiv_meta = test_indiv_meta,
valid_alleles = c("A", "T", "C", "G"),
quiet = TRUE
)
# Create an rbind report using rbind_dry_run
rbind_dry_run(example_gt, test_gt, flip_strand = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.