Title: | Simulate Experimental Crosses |
---|---|
Description: | Simulate and plot general experimental crosses. The focus is on simulating genotypes with an aim towards flexibility rather than speed. Meiosis is simulated following the Stahl model, in which chiasma locations are the superposition of two processes: a proportion p coming from a process exhibiting no interference, and the remainder coming from a process following the chi-square model. |
Authors: | Karl W Broman [aut, cre] |
Maintainer: | Karl W Broman <[email protected]> |
License: | GPL-3 |
Version: | 0.6 |
Built: | 2024-11-12 03:56:06 UTC |
Source: | https://github.com/kbroman/simcross |
Example matrix describing the pedigree for advanced intercross lines
data(AILped)
data(AILped)
A data frame with five columns: individual id, mom, dad, sex (0 for females and 1 for males) and generation.
Derived from the pedF8 dataset in the QTLRel package, https://cran.r-project.org/package=QTLRel
data(AILped) x <- sim_from_pedigree(AILped)
data(AILped) x <- sim_from_pedigree(AILped)
Calculate the reduced chromosome length that will give the target expected number of chiasmata when conditioning on there being at least one chiasma on the four-strand bundle.
calc_Lstar(L, m = 0, p = 0)
calc_Lstar(L, m = 0, p = 0)
L |
Length of chromosome (in cM); must be > 50 |
m |
Interference parameter for chi-square model |
p |
Proportion of chiasmata coming from no-interference process |
Adjusted length of chromosome
cross()
, sim_meiosis()
,
sim_crossovers()
calc_Lstar(100, 0, 0) calc_Lstar(60, 10, 0.1)
calc_Lstar(100, 0, 0) calc_Lstar(60, 10, 0.1)
Get the vector of colors for the Collaborative Cross
CCcolors(palette = c("new", "original", "official"))
CCcolors(palette = c("new", "original", "official"))
palette |
Which version of the colors to use? (New or original) |
vector of eight colors
CCcolors()
CCcolors()
Perform a series of checks on the tabular data for a pedigree, checking for problems
check_pedigree(pedigree, ignore_sex = FALSE)
check_pedigree(pedigree, ignore_sex = FALSE)
pedigree |
Numeric matrix or data frame with four columns: ID,
mom ID, dad ID, sex. Sex is coded as |
ignore_sex |
If TRUE, ignore the sex values completely (appropriate for hermaphroditic species.) |
The parents should be listed before any of their
offspring. Founders should have 0's for mother and father; all
others should have non-zero values for the parents, and the parents
should appear in the pedigree. Father should be male and mothers
should be female (unless ignore_sex=TRUE
). Individual
identifiers should be unique and non-zero. There should be no
missing values anywhere. (NA
s are allowed in the sex column
if ignore_sex=TRUE
.)
TRUE (invisibly) if everything is okay; otherwise gives an error.
sim_from_pedigree()
,
sim_ril_pedigree()
tab <- sim_ril_pedigree(7) check_pedigree(tab)
tab <- sim_ril_pedigree(7) check_pedigree(tab)
When simulating Diversity Outbreds, we need to specify parents 1-16, with 9-16 being the males from strains 1-8. This function collapses replaces alleles 9-16 with 1-8, to make the result ordinary DO-type data.
collapse_do_alleles(xodata)
collapse_do_alleles(xodata)
xodata |
The sort of detailed genotype/crossover data
generated by |
The input object, with alleles 9-16 replaced by 1-8.
sim_do_pedigree()
, sim_do_pedigree_fix_n()
,
sim_from_pedigree()
# simulate DO pedigree tab <- sim_do_pedigree(8) # simulate genotypes for that pedigree dat <- sim_from_pedigree(tab) # collapse to alleles 1-8 dat <- collapse_do_alleles(dat) # also works with data on multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X") dat <- collapse_do_alleles(dat)
# simulate DO pedigree tab <- sim_do_pedigree(8) # simulate genotypes for that pedigree dat <- sim_from_pedigree(tab) # collapse to alleles 1-8 dat <- collapse_do_alleles(dat) # also works with data on multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X") dat <- collapse_do_alleles(dat)
Convert the continuous crossover location information produced by sim_from_pedigree to marker genotypes
convert2geno(xodat, map, founder_geno = NULL, shift_map = FALSE)
convert2geno(xodat, map, founder_geno = NULL, shift_map = FALSE)
xodat |
The sort of detailed genotype/crossover data generated by
|
map |
vector of marker locations; can also be a list of such vectors (one per chromosome), in which case xodat and founder_geno must be lists with the same length. |
founder_geno |
Optional matrix (size |
shift_map |
If TRUE, shift genetic map to start at 0 |
If founder_geno
is provided or there are just two
founders, the result is a numeric matrix of genotypes, individuals
x markers, with genotypes 1/2/3 codes for 11/12/22 genotypes.
If founder_geno
is not provided and there are more than two
founders, the result is a 3-dimensional array, individuals x
markers x alleles, with the third dimensional corresponding to the
maternal and paternal allele.
If the input map
is a list (the components being
chromosomes), then xodat
and founder_geno
must be
lists of the same length, and the result will be a list of
matrices.
get_geno()
, sim_from_pedigree()
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # marker map (could also use sim.map in R/qtl) map <- seq(0, 100, by=5) names(map) <- paste0("marker", seq(along=map)) # convert data to marker genotypes geno <- convert2geno(dat, map) # AIL with multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X") # marker map multmap <- list("1"=seq(0, 100, by=5), "2"=seq(0, 75, by=5), "X"=seq(0, 100, by=5)) for(i in 1:3) names(multmap[[i]]) <- paste0("marker", i, "_", 1:length(map[[i]])) geno <- convert2geno(dat, multmap) # simulate DO pedigree tab <- sim_do_pedigree(8) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # simulate founder snp alleles fg <- matrix(sample(1:2, 8*length(map), repl=TRUE), nrow=8) # for DO, need female & male founders (to deal with X chr) fg <- rbind(fg, fg) # convert dat to SNP genotypes geno <- convert2geno(dat, map, fg) # if fg not provided, result is a 3d array genoarray <- convert2geno(dat, map)
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # marker map (could also use sim.map in R/qtl) map <- seq(0, 100, by=5) names(map) <- paste0("marker", seq(along=map)) # convert data to marker genotypes geno <- convert2geno(dat, map) # AIL with multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X") # marker map multmap <- list("1"=seq(0, 100, by=5), "2"=seq(0, 75, by=5), "X"=seq(0, 100, by=5)) for(i in 1:3) names(multmap[[i]]) <- paste0("marker", i, "_", 1:length(map[[i]])) geno <- convert2geno(dat, multmap) # simulate DO pedigree tab <- sim_do_pedigree(8) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # simulate founder snp alleles fg <- matrix(sample(1:2, 8*length(map), repl=TRUE), nrow=8) # for DO, need female & male founders (to deal with X chr) fg <- rbind(fg, fg) # convert dat to SNP genotypes geno <- convert2geno(dat, map, fg) # if fg not provided, result is a 3d array genoarray <- convert2geno(dat, map)
Wrap up of convert2geno to adequate multiple chromosomes.
convert2geno_allchr( xodat, map, id = NULL, founder_geno = NULL, return.matrix = TRUE, shift_map = FALSE )
convert2geno_allchr( xodat, map, id = NULL, founder_geno = NULL, return.matrix = TRUE, shift_map = FALSE )
xodat |
The sort of detailed genotype/crossover data generated
by |
map |
marker locations, a list with elements for each chromosome |
id |
ids for which individuals genotypes is desired |
founder_geno |
Optional list of matrices (one per chromosome)
of size |
return.matrix |
If FALSE, the result is a list of length
|
shift_map |
If TRUE, shift genetic map to start at 0 |
If founder_geno
is provided or there are just two
founders, the result is a numeric matrix of genotypes, individuals
x markers, with genotypes 1/2/3 codes for 11/12/22 genotypes. If
there are more than two founders and founder_geno
are
letters, the result is a character matrix, too.
If founder_geno
is not provided and there are more than two
founders, the result is a 3-dimensional array, individuals x
markers x alleles, with the third dimensional corresponding to the
maternal and paternal allele.
library(qtl) # marker map map <- sim.map(len=rep(100, 19), n.mar=10, include.x=FALSE) # simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree_allchr(tab, map) names(map) <- paste0("marker", seq(along=map)) # convert data to marker genotypes id <- which(tab[, "gen"]==12) geno <- convert2geno_allchr(dat, map, id)
library(qtl) # marker map map <- sim.map(len=rep(100, 19), n.mar=10, include.x=FALSE) # simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree_allchr(tab, map) names(map) <- paste0("marker", seq(along=map)) # convert data to marker genotypes id <- which(tab[, "gen"]==12) geno <- convert2geno_allchr(dat, map, id)
Create a parent object
create_parent(L, allele = 1)
create_parent(L, allele = 1)
L |
chromosome length in cM |
allele |
vector of integers for alleles, of length 1 or 2 |
A list with two components, for the individual's two chromosomes. Each is a list with alleles in chromosome intervals (as integers) and locations of the right endpoints of those intervals.
create_parent(100, 1) create_parent(100, 1:2)
create_parent(100, 1) create_parent(100, 1:2)
Simulate the cross of two individuals to create a single progeny
cross( mom, dad, m = 10, p = 0, xchr = FALSE, male = FALSE, obligate_chiasma = FALSE, Lstar = NULL )
cross( mom, dad, m = 10, p = 0, xchr = FALSE, male = FALSE, obligate_chiasma = FALSE, Lstar = NULL )
mom |
An individual object, as produced by
|
dad |
An individual object, as produced by
|
m |
interference parameter for chi-square model |
p |
proportion of crossovers coming from no-interference process |
xchr |
If TRUE, simulate X chromosome |
male |
If TRUE, simulate a male (matters only if
|
obligate_chiasma |
If TRUE, require an obligate chiasma on the 4-strand bundle at meiosis. |
Lstar |
Adjusted chromosome length, if
|
Simulations are under the Stahl model with the interference parameter being an integer. This is an extension of the chi-square model, but with chiasmata being the superposition of two processes, one following the chi-square model and the other exhibiting no interference.
A list with two components, for the individual's two chromosomes. Each is a list with alleles in chromosome intervals (as integers) and locations of the right endpoints of those intervals.
create_parent()
, sim_meiosis()
,
sim_crossovers()
, calc_Lstar()
mom <- create_parent(100, 1:2) dad <- create_parent(100, 1:2) child <- cross(mom, dad)
mom <- create_parent(100, 1:2) dad <- create_parent(100, 1:2) child <- cross(mom, dad)
With data on the continuous crossover location information produced by sim_from_pedigree, grab the genotype at a given position.
get_geno(xodat, position)
get_geno(xodat, position)
xodat |
The sort of detailed genotype/XO data generated by
|
position |
Position (in cM) for which to obtain genotypes |
A numeric matrix with two columns: the maternal and paternal allele for each individual.
sim_from_pedigree()
, convert2geno()
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # get genotype at position 30 cM geno <- get_geno(dat, 30)
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # get genotype at position 30 cM geno <- get_geno(dat, 30)
Mouse chromosome lengths in cM from the Cox et al. map
data(mouseL_cox)
data(mouseL_cox)
A numeric vector with lengths in cM for the 20 mouse chromosomes.
Taken from Table 1 of Cox et al. (2009) A new standard genetic map for the laboratory mouse. Genetics 182:1335-1344. doi:10.1534/genetics.109.105486
mouseL_mgi
data(mouseL_cox)
data(mouseL_cox)
Mouse chromosome lengths in cM from the Mouse Genome Informatics (MGI) standard map.
data(mouseL_mgi)
data(mouseL_mgi)
A numeric vector with lengths in cM for the 20 mouse chromosomes.
Taken from Table 1 of Cox et al. (2009) A new standard genetic map for the laboratory mouse. Genetics 182:1335-1344. doi:10.1534/genetics.109.105486
mouseL_cox
data(mouseL_mgi)
data(mouseL_mgi)
Add lines for a cross
plot_crosslines( momloc, dadloc, kidsloc, gap = 3, chrlength = 30, cex = 1.5, lwd = 2, arrow_length = 0.1, col = "white", ... )
plot_crosslines( momloc, dadloc, kidsloc, gap = 3, chrlength = 30, cex = 1.5, lwd = 2, arrow_length = 0.1, col = "white", ... )
momloc |
An (x,y) vector with center location for mother |
dadloc |
An (x,y) vector with center location for mother |
kidsloc |
Either an (x,y) vector with center location for a kid, or a list of such for multiple kids |
gap |
Gap arrows and points/rectangles |
chrlength |
Length of chromosomes |
cex |
Character expansion for x point |
lwd |
Line width for points, segments, and arrows |
arrow_length |
The |
col |
Color of lines and points |
... |
Additional arguments passed to arrows() and segments() |
None.
mom <- create_parent(100, 1:2) dad <- create_parent(100, 3:4) kids <- lapply(1:4, function(junk) cross(mom, dad)) plot(0,0, type="n", xlim=c(0, 100), ylim=c(0,100), xaxt="n", yaxt="n", xlab="", ylab="") loc <- list(c(25,75), c(75,75), c(12.5,25), c(37.5,25), c(62.5, 25), c(87.5,25)) plot_ind(mom, loc[[1]]) plot_ind(dad, loc[[2]]) for(i in 1:4) plot_ind(kids[[i]], loc[[i+2]]) plot_crosslines(loc[[1]], loc[[2]], loc[3:6])
mom <- create_parent(100, 1:2) dad <- create_parent(100, 3:4) kids <- lapply(1:4, function(junk) cross(mom, dad)) plot(0,0, type="n", xlim=c(0, 100), ylim=c(0,100), xaxt="n", yaxt="n", xlab="", ylab="") loc <- list(c(25,75), c(75,75), c(12.5,25), c(37.5,25), c(62.5, 25), c(87.5,25)) plot_ind(mom, loc[[1]]) plot_ind(dad, loc[[2]]) for(i in 1:4) plot_ind(kids[[i]], loc[[i+2]]) plot_crosslines(loc[[1]], loc[[2]], loc[3:6])
Add an individual, as a pair of chromosomes, to a plot
plot_ind( ind, center, chrlength = 30, chrwidth = 3, gap = 3, col = CCcolors(), border = "black", lend = 1, ljoin = 1, allborders = FALSE, ... )
plot_ind( ind, center, chrlength = 30, chrwidth = 3, gap = 3, col = CCcolors(), border = "black", lend = 1, ljoin = 1, allborders = FALSE, ... )
ind |
An individual object, as output by
|
center |
(x,y) vector for the center of the individual |
chrlength |
Length of chromosomes (Can be a vector of length 2, in which case the two chromosomes will be different lengths, aligned at the top. This is for the X chromosome.) |
chrwidth |
Width of chromosomes |
gap |
Gap between chromosomes |
col |
Vector of colors |
border |
Color for border |
lend |
Passed to |
ljoin |
Passed to |
allborders |
If TRUE, put borders around all segments |
... |
Additional arguments passed to rect() |
None.
mom <- create_parent(100, 1:2) dad <- create_parent(100, 3:4) kid <- cross(mom, dad) plot(0,0, type="n", xlim=c(0, 100), ylim=c(0,100), xaxt="n", yaxt="n", xlab="", ylab="") loc <- list(c(25,75), c(75,75), c(50,25)) plot_ind(mom, loc[[1]]) plot_ind(dad, loc[[2]]) plot_ind(kid, loc[[3]]) plot_crosslines(loc[[1]], loc[[2]], loc[[3]])
mom <- create_parent(100, 1:2) dad <- create_parent(100, 3:4) kid <- cross(mom, dad) plot(0,0, type="n", xlim=c(0, 100), ylim=c(0,100), xaxt="n", yaxt="n", xlab="", ylab="") loc <- list(c(25,75), c(75,75), c(50,25)) plot_ind(mom, loc[[1]]) plot_ind(dad, loc[[2]]) plot_ind(kid, loc[[3]]) plot_crosslines(loc[[1]], loc[[2]], loc[[3]])
Simulate a 4-way cross, among four inbred lines (a table of individual, mom, dad, sex)
sim_4way_pedigree(ngen = 1, nsibs = 100)
sim_4way_pedigree(ngen = 1, nsibs = 100)
ngen |
Number of intercross generations (1 or 2) |
nsibs |
Vector with number of siblings in the sibships in the last generation. |
We start with a set of 4 individuals (representing four
inbred lines), and make a pair of crosses to generate a pair of
heterozygous individuals. These are then crosses to generate a set
of F1 individuals. If ngen==1
, we stop there, with
sum(nsibs)
individuals in this last generation. If
gen==2
, we generate length(nsibs)
male/female pairs
of F1 offspring; these are intercrossed to generate a set of
sibships, with lengths defined by the values in nsibs
.
Individuals in the last generation are alternating female/male.
A data frame with five columns: individual ID, mother ID,
father ID, sex, and generation. Founders have 0
for mother
and father ID. Sex is coded 0 for female and 1 for male.
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_do_pedigree()
,
sim_ail_pedigree()
# 100 F1s between heterozygous parents tab <- sim_4way_pedigree(1, 100) # could also do this tab2 <- sim_4way_pedigree(1, rep(10, 10)) # 120 F2s in 10 sibships each of size 12 tab3 <- sim_4way_pedigree(ngen=2, rep(12, 10))
# 100 F1s between heterozygous parents tab <- sim_4way_pedigree(1, 100) # could also do this tab2 <- sim_4way_pedigree(1, rep(10, 10)) # 120 F2s in 10 sibships each of size 12 tab3 <- sim_4way_pedigree(ngen=2, rep(12, 10))
Simulate a pedigree for advanced intercross lines (a table of individual, mom, dad, sex)
sim_ail_pedigree( ngen = 12, npairs = 30, nkids_per = 5, design = c("nosib", "random") )
sim_ail_pedigree( ngen = 12, npairs = 30, nkids_per = 5, design = c("nosib", "random") )
ngen |
Number of generations of outbreeding |
npairs |
Number of breeding pairs at each generation |
nkids_per |
Number of offspring per pair for the last generation |
design |
How to choose crosses: either random but avoiding siblings, or completely at random |
Advanced intercross lines (AIL) are generated from a pair of inbred lines.
We cross them and then cross the F1 to generate npair
breeding pairs.
The subsequent ngen
outbreeding generations then proceed by
crossing a male and female from the preceding generation (mated
completely at random, with design="random"
, or avoiding
siblings, with design="nosib"
). Each breeding pair gives a
single female and a single male to the next generation, except at
the last generation nkids_per
offspring are mated, in equal
numbers male and female. (If nkids_per
is an odd number, the
number of males and females in each sibship will differ by one,
alternating between sibships, with one additional female and then
one additional male.
A data frame with five columns: individual ID, mother ID,
father ID, sex, and generation. Founders have 0
for mother
and father ID. Sex is coded 0 for female and 1 for male.
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_do_pedigree()
,
sim_4way_pedigree()
tab <- sim_ail_pedigree(12, 30)
tab <- sim_ail_pedigree(12, 30)
Simulate a pedigree for advanced intercross lines (a table of individual, mom, dad, sex) so that the last generation reaches a desired sample size n
sim_ail_pedigree_fix_n( ngen = 12, nkids_per = 5, nsample_ngen = 150, npairs = NULL, method = c("last2", "sub2"), design = c("nosib", "random") )
sim_ail_pedigree_fix_n( ngen = 12, nkids_per = 5, nsample_ngen = 150, npairs = NULL, method = c("last2", "sub2"), design = c("nosib", "random") )
ngen |
Number of generations of outbreeding |
nkids_per |
Number of offspring per pair for the last generation |
nsample_ngen |
Number of individuals desired at the last generation |
npairs |
Number of breeding pairs at each generation. If
missing, we use 30 when |
method |
Method used to generate pedigree: either expand at the last two generations or generate a pedigree with a large number of pairs and select a subset to have the desired sample size. |
design |
How to choose crosses: either random but avoiding siblings, or completely at random |
The default value for npairs
depends on the choice of method
.
For method="last2"
, we use a default of npairs=30
; for
method="sub2"
, we use a default of npairs=300
.
A data frame with five columns: individual ID, mother ID,
father ID, sex, and generation. Founders have 0
for mother
and father ID. Sex is coded 0 for female and 1 for male.
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
,
sim_do_pedigree()
, sim_4way_pedigree()
,
sim_do_pedigree_fix_n()
tab <- sim_ail_pedigree_fix_n(12)
tab <- sim_ail_pedigree_fix_n(12)
Simulate crossover locations on a single meiotic product using the Stahl model.
sim_crossovers(L, m = 10, p = 0, obligate_chiasma = FALSE, Lstar = NULL)
sim_crossovers(L, m = 10, p = 0, obligate_chiasma = FALSE, Lstar = NULL)
L |
length of chr in cM |
m |
Interference parameter ( |
p |
Proportion of chiasmata from no-interference mechanism
( |
obligate_chiasma |
If TRUE, require an obligate chiasma on the 4-strand bundle at meiosis. |
Lstar |
Adjusted chromosome length, if
|
Chiasma locations are a superposition of two processes: a proportion p exhibiting no interference, and a proportion (1-p) following the chi-square model with interference parameter m. Crossover locations are derived by thinning the chiasma locations with probability 1/2.
Simulations are under the Stahl model with the interference parameter being an integer. This is an extension of the chi-square model, but with chiasmata being the superposition of two processes, one following the chi-square model and the other exhibiting no interference.
Numeric vector of crossover locations, in cM
Copenhaver, G. P., Housworth, E. A. and Stahl, F. W. (2002) Crossover interference in arabidopsis. Genetics 160, 1631–1639.
Foss, E., Lande, R., Stahl, F. W. and Steinberg, C. M. (1993) Chiasma interference as a function of genetic distance. Genetics 133, 681–691.
Zhao, H., Speed, T. P. and McPeek, M. S. (1995) Statistical analysis of crossover interference using the chi-square model. Genetics 139, 1045–1056.
x <- sim_crossovers(200, 10, 0) x <- sim_crossovers(200, 10, 0.04) x <- sim_crossovers(100, 0, 0, obligate_chiasma=TRUE)
x <- sim_crossovers(200, 10, 0) x <- sim_crossovers(200, 10, 0.04) x <- sim_crossovers(100, 0, 0, obligate_chiasma=TRUE)
Simulate a pedigree for generating Diversity Outbred (DO) mice (a table of individual, mom, dad, sex).
sim_do_pedigree( ngen = 12, npairs = 144, ccgen = rep(4:12, c(21, 64, 24, 10, 5, 9, 5, 3, 3)), nkids_per = 5, design = c("nosib", "random") )
sim_do_pedigree( ngen = 12, npairs = 144, ccgen = rep(4:12, c(21, 64, 24, 10, 5, 9, 5, 3, 3)), nkids_per = 5, design = c("nosib", "random") )
ngen |
Number of generations of outbreeding |
npairs |
Number of breeding pairs at each generation |
ccgen |
Vector of length |
nkids_per |
Number of offspring per pair for the last generation |
design |
How to choose crosses: either random but avoiding siblings, or completely at random |
Diversity outbred (DO) mice are generated from a set of 8 inbred lines. We need two individuals from each line (one female and one male) as the order of the initial crosses will be randomized; for example, sometimes the individual from line 1 will be a mother and sometimes a father. The founders are numbered 1-8 for the females from the 8 lines, and 9-16 for the corresponding males.
Diversity Outbred mice are generated by first creating a panel of
partially-inbred 8-way RIL (the so-called pre-CC, for
pre-Collaborative Cross). The ccgen
argument specifies the
number of inbreeding generations for each of the CC lines. We
generate a pre-CC line for each of the npairs
breeding
pairs, and generate a sibling pair from each as the starting
material.
The subsequent ngen
outbreeding generations then proceed by
crossing a male and female from the preceding generation (mated
completely at random, with design="random"
, or avoiding
siblings, with design="nosib"
). Each breeding pair gives a
single female and a single male to the next generation, except at
the last generation nkids_per
offspring are mated, in equal
numbers male and female. (If nkids_per
is an odd number, the
number of males and females in each sibship will differ by one,
alternating between sibships, with one additional female and then
one additional male.
The default for ccgen
is taken from Figure 1 of Svenson et
al. (2012).
A data frame with six columns: individual ID, mother ID, father
ID, sex, generation, and TRUE/FALSE indicator for whether DO or pre-DO.
Founders have 0
for mother and father ID. Sex is coded 0 for
female and 1 for male.
Svenson KL, Gatti DM, Valdar W, Welsh CE, Cheng R, Chesler EJ, Palmer AA, McMillan L, Churchill GA (2012) High-resolution genetic mapping using the mouse Diversity Outbred population. Genetics 190:437-447
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
,
sim_4way_pedigree()
tab <- sim_do_pedigree(8)
tab <- sim_do_pedigree(8)
Simulate a pedigree for Diversity Outbred (DO) mice (a table of individual, mom, dad, sex) so that the last generation reaches a desired sample size.
sim_do_pedigree_fix_n( ngen = 12, nkids_per = 5, nccgen = 15, nsample_ngen = 150, npairs = NULL, method = c("last2", "sub2", "fixcc"), design = c("nosib", "random"), selc.method = c("byfamily", "byindiv") )
sim_do_pedigree_fix_n( ngen = 12, nkids_per = 5, nccgen = 15, nsample_ngen = 150, npairs = NULL, method = c("last2", "sub2", "fixcc"), design = c("nosib", "random"), selc.method = c("byfamily", "byindiv") )
ngen |
Number of generations of outbreeding |
nkids_per |
Number of offspring per pair for the last generation |
nccgen |
The number of generations for each CC line, only used
when |
nsample_ngen |
Number of individuals desired at the last generation |
npairs |
Number of breeding pairs at each generation. If
missing, we use 30 when |
method |
Method used to generate the pedigree: either expand
at the last two generations or generate a pedigree with a large
number of pairs and then select a subset to have the desired sample
size. With |
design |
How to choose crosses: either random but avoiding siblings, or completely at random |
selc.method |
Method used to select the individuals from last generation. |
The default number of breeding pairs depends on the chosen
method
. With method="last2"
, the default is npairs=30
;
with method="sub2"
, the default is npairs=300
;
with method="fixcc"
, npairs
is ignored and is fixed at 144.
A data frame with six columns: individual ID, mother ID, father
ID, sex, generation, and TRUE/FALSE indicator for whether DO or pre-DO.
Founders have 0
for mother and father ID. Sex is coded 0 for
female and 1 for male.
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
,
sim_do_pedigree()
, sim_4way_pedigree()
,
sim_ail_pedigree_fix_n()
tab <- sim_do_pedigree_fix_n(8)
tab <- sim_do_pedigree_fix_n(8)
Simulate a pedigree for a set of DOF1 individuals: the F1 offspring of a set of diversity outbred mice and another inbred strain (such as a mutant line).
sim_dof1_pedigree( ngen = 12, npairs = 144, ccgen = rep(4:12, c(21, 64, 24, 10, 5, 9, 5, 3, 3)), nkids_per = 5, design = c("nosib", "random") )
sim_dof1_pedigree( ngen = 12, npairs = 144, ccgen = rep(4:12, c(21, 64, 24, 10, 5, 9, 5, 3, 3)), nkids_per = 5, design = c("nosib", "random") )
ngen |
Number of generations of outbreeding |
npairs |
Number of breeding pairs at each generation |
ccgen |
Vector of length |
nkids_per |
Number of offspring per pair for the last DO generation (each will be crossed to produce one F1) |
design |
How to choose crosses: either random but avoiding siblings, or completely at random |
Diversity outbred (DO) mice are generated from a set of 8 inbred lines. We need two individuals from each line (one female and one male) as the order of the initial crosses will be randomized; for example, sometimes the individual from line 1 will be a mother and sometimes a father. The founders are numbered 1-8 for the females from the 8 lines, and 9-16 for the corresponding males.
Diversity Outbred mice are generated by first creating a panel of
partially-inbred 8-way RIL (the so-called pre-CC, for
pre-Collaborative Cross). The ccgen
argument specifies the
number of inbreeding generations for each of the CC lines. We
generate a pre-CC line for each of the npairs
breeding
pairs, and generate a sibling pair from each as the starting
material.
The subsequent ngen
outbreeding generations then proceed by
crossing a male and female from the preceding generation (mated
completely at random, with design="random"
, or avoiding
siblings, with design="nosib"
). Each breeding pair gives a
single female and a single male to the next generation, except at
the last generation nkids_per
offspring are mated, in equal
numbers male and female. (If nkids_per
is an odd number, the
number of males and females in each sibship will differ by one,
alternating between sibships, with one additional female and then
one additional male.
The default for ccgen
is taken from Figure 1 of Svenson et
al. (2012).
We assume that the F1 offspring are all from a cross DO female x line 17 male, and so the last generation of the DO is taken to be all females.
A data frame with seven columns: individual ID, mother ID,
father ID, sex, generation, a TRUE/FALSE indicator for whether DO
or pre-DO, and a TRUE/FALSE indicator for whether DOF1. Founders
have 0
for mother and father ID. Sex is coded 0 for female
and 1 for male.
Svenson KL, Gatti DM, Valdar W, Welsh CE, Cheng R, Chesler EJ, Palmer AA, McMillan L, Churchill GA (2012) High-resolution genetic mapping using the mouse Diversity Outbred population. Genetics 190:437-447
sim_from_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
,
sim_4way_pedigree()
tab <- sim_dof1_pedigree(8)
tab <- sim_dof1_pedigree(8)
Simulate genotypes along one chromosome for a pedigree
sim_from_pedigree( pedigree, L = 100, xchr = FALSE, m = 10, p = 0, obligate_chiasma = FALSE )
sim_from_pedigree( pedigree, L = 100, xchr = FALSE, m = 10, p = 0, obligate_chiasma = FALSE )
pedigree |
Matrix or data frame describing a pedigree, with first four
columns being individual ID, mom ID, dad ID, and sex (female as
|
L |
Length of chromosome in cM (or a vector of chromosome lengths) |
xchr |
If TRUE, simulate X chromosome. (If |
m |
Crossover interference parameter, for chi-square model (m=0 corresponds to no interference). |
p |
proportion of crossovers coming from no-interference process |
obligate_chiasma |
If TRUE, require an obligate chiasma on the 4-strand bundle at meiosis. |
A list with each component being the data for one
individual, as produced by the cross()
function. Those
results are a list with two components, corresponding to the
maternal and paternal chromosomes. The chromosomes are represented
as lists with two components: an integer vector of alleles in
chromosome intervals, and a numeric vector of locations of the
right-endpoints of those intervals; these two vectors should have
the same length.
If the input L
is a vector, in order to simulate multiple
chromosomes at once, then the output will be a list with length
length(L)
, each component being a chromosome and having the
form described above.
check_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
,
sim_from_pedigree_allchr()
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # simulate multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X")
# simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree(tab) # simulate multiple chromosomes dat <- sim_from_pedigree(tab, c("1"=100, "2"=75, "X"=100), xchr="X")
Simulate genotypes along all chromosomes for a pedigree. This is a wrap up of sim_from_pedigree.
sim_from_pedigree_allchr( pedigree, map, m = 10, p = 0, obligate_chiasma = FALSE )
sim_from_pedigree_allchr( pedigree, map, m = 10, p = 0, obligate_chiasma = FALSE )
pedigree |
Matrix or data frame describing a pedigree, with first four
columns being individual ID, mom ID, dad ID, and sex (female as
|
map |
marker locations, a list with elements for each chromosome |
m |
Crossover interference parameter, for chi-square model (m=0 corresponds to no interference). |
p |
proportion of crossovers coming from no-interference process |
obligate_chiasma |
If TRUE, require an obligate chiasma on the 4-strand bundle at meiosis. |
A list with each component being the result from
sim_from_pedigree
, of length same as map
.
check_pedigree()
,
sim_ril_pedigree()
, sim_ail_pedigree()
sim_from_pedigree()
library(qtl) # marker map map <- sim.map(len=rep(100, 19), n.mar=10, include.x=FALSE) # simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree_allchr(tab, map)
library(qtl) # marker map map <- sim.map(len=rep(100, 19), n.mar=10, include.x=FALSE) # simulate AIL pedigree tab <- sim_ail_pedigree(12, 30) # simulate data from that pedigree dat <- sim_from_pedigree_allchr(tab, map)
Output a random meiotic product from an input individual.
sim_meiosis(parent, m = 10, p = 0, obligate_chiasma = FALSE, Lstar = NULL)
sim_meiosis(parent, m = 10, p = 0, obligate_chiasma = FALSE, Lstar = NULL)
parent |
An individual object, as output by
|
m |
interference parameter for chi-square model |
p |
Proportion of chiasmata coming from no-interference process. |
obligate_chiasma |
If TRUE, require an obligate chiasma on the 4-strand bundle at meiosis. |
Lstar |
Adjusted chromosome length, if
|
Simulations are under the Stahl model with the interference parameter being an integer. This is an extension of the chi-square model, but with chiasmata being the superposition of two processes, one following the chi-square model and the other exhibiting no interference.
A list with alleles in chromosome intervals (as integers) and locations of the right endpoints of those intervals.
Copenhaver, G. P., Housworth, E. A. and Stahl, F. W. (2002) Crossover interference in arabidopsis. Genetics 160, 1631–1639.
Foss, E., Lande, R., Stahl, F. W. and Steinberg, C. M. (1993) Chiasma interference as a function of genetic distance. Genetics 133, 681–691.
Zhao, H., Speed, T. P. and McPeek, M. S. (1995) Statistical analysis of crossover interference using the chi-square model. Genetics 139, 1045–1056.
create_parent()
, cross()
,
sim_crossovers()
, calc_Lstar()
ind <- create_parent(100, 1:2) prod <- sim_meiosis(ind)
ind <- create_parent(100, 1:2) prod <- sim_meiosis(ind)
Generate a pedigree for multi-way recombinant inbred lines (a table of individual, mom, dad, sex)
sim_ril_pedigree( ngen = 20, selfing = FALSE, parents = 1:2, firstind = max(parents) + 1 )
sim_ril_pedigree( ngen = 20, selfing = FALSE, parents = 1:2, firstind = max(parents) + 1 )
ngen |
Number of generations of inbreeding |
selfing |
If TRUE, use selfing |
parents |
Vector of the parents' IDs. Should be integers, and length must be a power of 2 (i.e., 2, 4, 8, ...) |
firstind |
Positive integer to assign to the first child. Must
be greater than |
A data frame with five columns: individual ID, mother ID,
father ID, sex, and generation. Founders have 0
for mother
and father ID. Sex is coded 0 for female and 1 for male.
sim_from_pedigree()
,
sim_ail_pedigree()
, sim_do_pedigree()
,
sim_4way_pedigree()
tab <- sim_ril_pedigree(7)
tab <- sim_ril_pedigree(7)
Find regions of heterozygosity in an individual
where_het(ind)
where_het(ind)
ind |
An individual object, as output be
|
A matrix with two columns; each row indicates the start and end of a region where the individual is heterozygous
sim_from_pedigree()
,
convert2geno()
mom <- create_parent(100, 1:2) dad <- create_parent(100, 1:2) child <- cross(mom, dad) where_het(child)
mom <- create_parent(100, 1:2) dad <- create_parent(100, 1:2) child <- cross(mom, dad) where_het(child)