segments2markers {gscramble} | R Documentation |
Map alleles from scrambled founders to the sampled segments from a GSP.
Description
Map alleles from scrambled founders to the sampled segments from a GSP.
Usage
segments2markers(
Segs,
Im,
Mm,
G,
preserve_haplotypes = FALSE,
preserve_individuals = FALSE
)
Arguments
Segs |
the simulated segments. A tibble like that returned from
|
Im |
the individual meta data, like that in |
Mm |
the marker meta data formatted like that in |
G |
the marker genotype data as a matrix like |
preserve_haplotypes |
If TRUE then the Geno data is assumed phased (first allele at an individual on one haplotype and second allele on the other) and those haplotypes are preserved in this permutation of genomic material amongst the founders. |
preserve_individuals |
If TRUE then whole individuals are permuted
around the data set and the two gene copies at each locus are randomly
permuted within each individual. If |
Value
A list with three components:
-
ret_geno
: A character matrix where each row is an individual and each pair of columns are the alleles at a locus, thus it is N x 2L where N is the number of individuals and L is the number of markers. -
ret_ids
: A tibble providing the individual meta data with columnsgroups
andindiv
. -
hyb_Qs
: A tibble of the admixture Q values.
Examples
#### First, get input segments for the function ####
# We construct an example here where we will request segregation
# down a GSP with two F1s and F1B backcrosses between two hypothetical
# populations, A and B.
set.seed(5)
gsp_f1f1b <- create_GSP("A", "B", F1 = TRUE, F1B = TRUE)
# We will imagine that in our marker data there are three groups
# labelled "Pop1", "Pop2", and "Pop3", and we want to create the F1Bs with backcrossing
# only to Pop3.
reppop <- tibble::tibble(
index = as.integer(c(1, 1, 2, 2)),
pop = c("A", "B", "A", "B"),
group = c("Pop3", "Pop1", "Pop3", "Pop2")
)
# combine those into a request
request <- tibble::tibble(
gpp = list(gsp_f1f1b),
reppop = list(reppop)
)
# now segegate segments. Explicitly pass the markers
# in M_meta so that the order of the markers is set efficiently.
segs <- segregate(request, RecRates, M_meta)
#### Now, use segs in an example with segments2markers() ####
# this uses several package data objects that are there for examples
# and illustration.
s2m_result <- segments2markers(segs, I_meta, M_meta, Geno)