Package 'qtlsim'

Title: Software for Testing QTL Analysis via Simulations
Description: Software for testing QTL analysis via simulations.
Authors: Karl W Broman [aut, cre]
Maintainer: Karl W Broman <[email protected]>
License: GPL-3
Version: 0.73-6
Built: 2026-05-09 20:42:33 UTC
Source: https://github.com/kbroman/qtlsim

Help Index


Analyze a backcross

Description

Analyze a backcross using ANOVA, CIM, and forward selection.

Usage

anal.all(dat, cim.steps=7, max.steps=20)

Arguments

dat

The data: a list with components geno (the genotype data, as a matrix) and pheno (the phenotype data, as a vector).

cim.steps

Number of steps in forward selection prior to CIM analysis.

max.steps

Maximum number of steps in forward selection.

Value

A list with three components: LOD scores from ANOVA, LOD scores from CIM, and a matrix of marker indices and RSS from forward selection

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, anal.leaps, anal.mcmc, perm

Examples

dat <- simbc()
results <- anal.all(dat)

Analyze a backcross by model selection methods

Description

Analyze a backcross using forward or backward selection or either of these followed by branch-and-bound.

Usage

anal.leaps(dat, method=c("forward","backward","forwback",
                         "forwardleap","backwardleap"),
           bic.mult=2.5, max.steps=30)

Arguments

dat

The data: a list with components geno (the genotype data, as a matrix) and pheno (the phenotype data, as a vector).

method

Model search approach to use: forward selection, backward elimination, forward selection followed by backward elimination, or forward or backward selection followed by branch-and-bound.

bic.mult

Multiplier for BIC, for choosing the size of the model.

max.steps

Maximum number of steps in forward selection.

Value

A list whose first component is a vector indicating the marker columns selected and second component is the corresponding BIC-delta value.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, anal.all, anal.mcmc, perm

Examples

dat <- simbc(n.ind=100,qtl.eff=c(1,1,1,-1,1,1,1)*0.75)
results <- anal.leaps(dat,method="forwback",bic.mult=2.56)

Analyze a backcross by MCMC

Description

Analyze a backcross using an MCMC model selection method.

Usage

anal.mcmc(dat, bic.mult=2.5, n.steps=1000, start=NULL)

Arguments

dat

The data: a list with components geno (the genotype data, as a matrix) and pheno (the phenotype data, as a vector).

bic.mult

Multiplier for BIC, for choosing the size of the model.

n.steps

Number of steps to take in the Markov chain.

start

Model at which to start the chain: a vector giving the columns of the genotype matrix to use as an initial state.

Value

A list giving the marker numbers chosen, the BIC criterion for the chosen model, the iteration of MCMC at which this model was first seen, and vectors giving the number of QTLs in the model and the BIC criterion, at each step of the chain

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, anal.all, anal.leaps, perm

Examples

dat <- simbc()
results <- anal.mcmc(dat)

Simulations to test QTL analyses

Description

Run multiple simulations of a backcross, analyzed using ANOVA, CIM and forward selection (with both BIC and permutation tests).

Usage

anal.multi(n.sim=1000, cim.steps=c(3,5,7,9,11), bic.mult=c(2,2.5,3),
           max.steps=13, n.perm=1000, alpha=0.05, thresh=NULL, drop=1.5,
           n.ind=100, n.mar=rep(11,9), mar.sp=rep(10,10*9),
           qtl.chr=c(1,1,2,2,3,4,5), qtl.mar=c(4,8,4,8,6,4,1),
           qtl.dist=rep(0,7), qtl.eff=c(1,1,1,-1,1,1,1)/2,
           sigma=1)

Arguments

n.sim

Number of simulation replicates.

cim.steps

Number of steps in forward selection prior to CIM analysis.

bic.mult

Multipliers for BIC.

max.steps

Maximum number of steps in forward selection.

n.perm

Number of permutation replicates in permutation tests.

alpha

Significance level in permutation tests.

thresh

LOD thresholds for ANOVA and CIM. Should be length 1 or 1+length(cim.steps). If NULL and the chromosome structure and number of individuals match simulations that I've already done, we use my estimated LOD thresholds.

drop

Drop in LOD that is required between inferred QTLs. Should be length 1 or 1+length(cim.steps).

n.ind

Number of backcross individuals.

n.mar

Vector indicating the number of markers on each chromosome.

mar.sp

Vector of length sum(n.mar)-n.chr-1, giving the inter-marker spacings in cM.

qtl.chr

Chromosomes on which qtls are sitting.

qtl.mar

Markers to the left of each qtl, numbered 1, 2, ...

qtl.dist

Distance between qtl and marker to left, in cM.

qtl.eff

QTL effects.

sigma

Residual (environmental) standard deviation.

Value

A list of length 2+n.cim+n.bic, whose components correspond to the results of ANOVA, CIM, forward selection with BIC, and forward selection with permutation tests. Each component of this list is itself a list of length n.sim, with each component giving the chromosome numbers and marker numbers of the identified QTLs.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, sim.null, sim.mcmc, anal.multi2

Examples

## Not run: results <- anal.multi(n.sim=10)

Simulations to test QTL analyses

Description

Run multiple simulations of a backcross, analyzed using ANOVA, CIM, forward selection (with both BIC and permutation tests) and MCMC.

Usage

anal.multi2(n.sim=1000, cim.steps=c(3,5,7,9,11), bic.mult=c(2,2.5,3),
            max.steps=13, n.perm=1000, alpha=0.05, thresh=NULL, drop=1.5,
            n.ind=100, n.mar=rep(11,9), mar.sp=rep(10,10*9),
            n.mcmc=1000, mcmc.bic=2.56,
            qtl.chr=c(1,1,2,2,3,4,5), qtl.mar=c(4,8,4,8,6,4,1),
            qtl.dist=rep(0,7), qtl.eff=c(1,1,1,-1,1,1,1)/2,
            sigma=1)

Arguments

n.sim

Number of simulation replicates.

cim.steps

Number of steps in forward selection prior to CIM analysis.

bic.mult

Multipliers for BIC.

max.steps

Maximum number of steps in forward selection.

n.perm

Number of permutation replicates in permutation tests.

alpha

Significance level in permutation tests.

thresh

LOD thresholds for ANOVA and CIM. Should be length 1 or 1+length(cim.steps). If NULL and the chromosome structure and number of individuals match simulations that I've already done, we use my estimated LOD thresholds.

drop

Drop in LOD that is required between inferred QTLs. Should be length 1 or 1+length(cim.steps).

n.ind

Number of backcross individuals.

n.mar

Vector indicating the number of markers on each chromosome.

mar.sp

Vector of length sum(n.mar)-n.chr-1, giving the inter-marker spacings in cM.

n.mcmc

Number of steps in MCMC

mcmc.bic

Delta value in BIC in the MCMC runs

qtl.chr

Chromosomes on which qtls are sitting.

qtl.mar

Markers to the left of each qtl, numbered 1, 2, ...

qtl.dist

Distance between qtl and marker to left, in cM.

qtl.eff

QTL effects.

sigma

Residual (environmental) standard deviation.

Value

A list of length 3+n.cim+n.bic, whose components correspond to the results of ANOVA, CIM, forward selection with BIC, forward selection with permutation tests, and MCMC with BIC. Each component of this list is itself a list of length n.sim, with each component giving the chromosome numbers and marker numbers of the identified QTLs.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, sim.null, sim.mcmc, anal.multi

Examples

## Not run: results <- anal.multi2(n.sim=10)

Combine multiple simulation results

Description

Combine output of multiple runs of sim.mcmc.

Usage

combine.mcmc(...)

Arguments

...

Two or more objects, of the form output from sim.mcmc.

Value

A single object, of the form output from sim.mcmc.

Author(s)

Karl W Broman, [email protected]

See Also

sim.mcmc, combine.sims

Examples

## Not run: output1 <- sim.mcmc(n.sim=10)
## Not run: output2 <- sim.mcmc(n.sim=10)
## Not run: output <- combine.mcmc(output1, output2)

Combine multiple simulation results

Description

Combine output of multiple runs of anal.multi.

Usage

combine.sims(...)

Arguments

...

Two or more objects, of the form output from anal.multi.

Value

A single object, of the form output from anal.multi.

Author(s)

Karl W Broman, [email protected]

See Also

anal.multi, combine.mcmc

Examples

## Not run: output1 <- anal.multi(n.sim=10)
## Not run: output2 <- anal.multi(n.sim=10)
## Not run: output <- combine.sims(output1, output2)

Convert output of anal.leaps, anal.mcmc or perm

Description

Convert the output of anal.leaps, anal.mcmc or perm for use with the function which.correct.

Usage

convertOutput(object, n.mar=rep(11,9))

Arguments

object

An object of the form output from anal.leaps, anal.mcmc, perm; namely, a vector of marker identifiers, as integers, (or a list whose first component is such a vector).

n.mar

Vector indicating the number of markers on each chromosome.

Value

A matrix whose columns are identified QTLs, and rows are chromosome and marker numbers, respectively.

Author(s)

Karl W Broman, [email protected]

See Also

anal.leaps, anal.mcmc, perm, which.correct

Examples

dat <- simbc(n.ind=250)
res1 <- anal.leaps(dat, "forward", 2.1, 27)
res2 <- anal.leaps(dat, "backward", 2.1, 27)
res <- lapply(list(res1,res2), convertOutput)
out <- which.correct(res)

Convert simulated data into form for R/qtl

Description

Convert data simulated with simbc() into the form used by R/qtl.

Usage

convertSim(object, n.chr=9, chr.len=100)

Arguments

object

A list with two components: the genotype data as a matrix, and the phenotype data as a vector.

n.chr

Number of chromosomes in the data.

chr.len

Length of the chromosomes, in cM.

Value

An object of class cross. See read.cross for details.

Author(s)

Karl W Broman, [email protected]

See Also

read.cross, simbc

Examples

dat <- simbc()
cross <- convertSim(dat, 9, chr.len=100)

Forward selection w/ permutation test

Description

Analyze a backcross using forward selection with permutation tests to choose the size of the model.

Usage

perm(dat, n.perm=1000, alpha=0.05)

Arguments

dat

The data: a list with components geno (the genotype data, as a matrix) and pheno (the phenotype data, as a vector).

n.perm

Number of permutation replicates to perform at each state.

alpha

Level of significance to use in each permutation test.

Value

A vector of marker indices.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

anal.all, anal.leaps, anal.mcmc, simbc

Examples

## Not run: dat <- simbc()
## Not run: results <- perm(dat)

Plot simulation results

Description

Plot a summary of the results of anal.multi or sim.mcmc.

Usage

plot_res(x, ..., ylim=NULL)

Arguments

x

Output of which.correct.

...

Arguments to be passed to par.

ylim

Y-axis limits. If NULL, (0,1) is used.

Value

A plot of the proportion of times each QTL was identified by each method, and the proportion of linked and unlinked extraneous loci.

Author(s)

Karl W Broman, [email protected]

See Also

anal.multi, anal.mcmc, which.correct

Examples

## Not run: output <- anal.multi()
## Not run: tab <- which.correct(output)
## Not run: plot_res(tab)

Simulations to test QTL analyses

Description

Run multiple simulations of a backcross, analyzed using several model selection techniques, including MCMC.

Usage

sim.mcmc(n.sim=1000, max.steps=28, bic.mult=2.5, n.steps=1000,
         n.ind=100, n.mar=rep(11,9), mar.sp=rep(10,10*9),
         qtl.chr=c(1,1,2,2,3,4,5), qtl.mar=c(4,8,4,8,6,4,1),
         qtl.dist=rep(0,7), qtl.eff=c(1,1,1,-1,1,1,1)/2,
         sigma=1, only.two=FALSE)

Arguments

n.sim

Number of simulation replicates.

max.steps

Maximum number of steps in forward/backward selection.

bic.mult

Multiplier for BIC.

n.steps

Number of steps in MCMC.

n.ind

Number of backcross individuals.

n.mar

Vector indicating the number of markers on each chromosome.

mar.sp

Vector of length sum(n.mar)-n.chr-1, giving the inter-marker spacings in cM.

qtl.chr

Chromosomes on which qtls are sitting.

qtl.mar

Markers to the left of each qtl, numbered 1, 2, ...

qtl.dist

Distance between qtl and marker to left, in cM.

qtl.eff

QTL effects.

sigma

Residual (environmental) standard deviation.

only.two

If TRUE, only do forward selection and MCMC

Value

A list of three components. The first is a list of length 5, whose components correspond to the results of forward and backward selection, the same followed by branch-and-bound, with BIC, and MCMC. (Each component of this list is itself a list of length n.sim, with each component giving the chromosome numbers and marker numbers of the identified QTLs.) The second component of the main list gives the BIC values corresponding to the identified models. The last component gives the step at which the final model from MCMC was first observed, plus the number of distinct models observed.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, anal.mcmc, anal.leaps, anal.multi

Examples

## Not run: results <- sim.mcmc(n.sim=10)

Simulate under the null hypothesis of no QTLs.

Description

Simulates genotype and phenotype data for a backcross experiment with no QTLs, and applies ANOVA and CIM, in order to estimate LOD thresholds.

Usage

sim.null(n.ind=100, n.mar=rep(11,9), mar.sp=rep(10,10*9),
         cim.steps=c(3,5,7,9,11), n.sim=10000)

Arguments

n.ind

Number of backcross individuals.

n.mar

Vector indicating the number of markers on each chromosome.

mar.sp

Vector of length sum(n.mar)-n.chr-1, giving the inter-marker spacings in cM.

cim.steps

Vector giving number of steps of forward selection to perform prior to CIM.

n.sim

Number of simulation replicates to perform.

Value

A matrix of size [n.sim x (1+length(cim.steps))] giving the maximum LOD score for ANOVA and CIM (with the different values of cim.steps) for each simulation replicate.

Author(s)

Karl W Broman, [email protected]

References

Broman, K. W. (1997) Identifying quantitative trait loci in experimental crosses. PhD dissertation, Department of Statistics, University of California, Berkeley.

See Also

simbc, anal.multi

Examples

## Not run: output <- sim.null()

Simulate a backcross

Description

Simulates genotype and phenotype data for a backcross experiment with QTLs exactly at marker postions, and acting additively.

Usage

simbc(n.ind=100, n.mar=rep(11,9), mar.sp=rep(10,10*9),
      qtl.chr=c(1,1,2,2,3,4,5), qtl.mar=c(4,8,4,8,6,4,1),
      qtl.dist=rep(0,7), qtl.eff=c(1,1,1,-1,1,1,1)/2,
      sigma=1)

Arguments

n.ind

Number of backcross individuals.

n.mar

Vector indicating the number of markers on each chromosome.

mar.sp

Vector of length sum(n.mar)-n.chr-1, giving the inter-marker spacings in cM.

qtl.chr

Chromosomes on which qtls are sitting.

qtl.mar

Markers to the left of each qtl, numbered 1, 2, ...

qtl.dist

Distance between qtl and marker to left, in cM.

qtl.eff

QTL effects.

sigma

Residual (environmental) standard deviation.

Value

A list with two components: geno, a matrix containing the genotype data, and pheno, a vector of phenotypes.

Author(s)

Karl W Broman, [email protected]

See Also

convertSim

Examples

dat <- simbc()

Determine which QTLs were correctly identified in an analysis

Description

Given the results of a model selection procedure and the true underlying locations of QTLs, determine which QTLs were correctly identified and how many were extraneous.

Usage

which.correct(results, truth=rbind(c(1,1,2,2,3,4,5),c(4,8,4,8,6,4,1)),
              within=1)

Arguments

results

A list (or a list of lists), with each component in the inner lists being either numeric(0) or a matrix whose columns are identified QTLs, and rows are chromosome and marker numbers, respectively.

truth

Matrix whose columns are the true QTLs, with rows giving the chromosome and marker numbers, respectively.

within

Distance (in number of markers) allowable between true and inferred QTLs for the inferred QTL to be considered correct.

Value

A list of matrices, with the matrices of size n.sim x (n.qtl+2). The first set of columns in each matrix indicate which QTLs were correctly identified. The last two columns give the number of extraneous loci on the same chromosome as a QTL and the number of unlinked extraneous loci.

Author(s)

Karl W Broman, [email protected]

See Also

anal.multi, anal.mcmc

Examples

## Not run: dat <- simbc()
## Not run: output1 <- anal.multi(dat)
## Not run: output2 <- which.correct(output1)