R: Simulate null distribution

nullSim {QTLRel} | R Documentation

## Simulate null distribution

### Description

Simulate distribution under the hypothesis of no QTL by permutation (of genotypic data) or gene dropping.

### Usage

    nullSim(y, x, gdat, prdat, ped, gmap, hap,
    	method = c("permutation","gene dropping"), vc = NULL, intcovar = NULL,
    	test = c("None","F","Chisq"), minorGenoFreq = 0.05, rmv = TRUE,
    	gr = 2, ntimes = 10)

### Arguments

`y` | A numeric vector or a numeric matrix of one column (representing a phenotype for instance).
`x` | A data frame or matrix, representing covariates if not missing.
`gdat` | Genotype data without missing values. Should be a matrix or a data frame, with each row representing an observation and each column a marker locus. Ignored in the case of gene dropping.
`prdat` | An object from `genoProb`, or in the same form.
`ped` | A pedigree, which is a data frame (id, sex, sire, dam, ...). In "sex", male should be "M", "Male" or 1, and female should be "F", "Female" or 2 (other than 0 and 1). If given, "generation" can be numeric 0, 1, 2, ... or non-numeric "F0", "F1", "F2", ... Note that 0 is reserved for missing values. Ignored in the case of permutation.
`gmap` | A genetic map. Should be data frame (snp, chr, dist, ...), where "snp" is the SNP (marker) name, "chr" is the chromosome where the "snp" is, and "dist" is the genetic distance in centi-Morgan (cM) from the left of the chromosome. Ignored in the case of permutation.
`hap` | Founders' haplotype data if not missing. Rows correspond to all founders, which should be in the first places in the pedigree `ped`, in the exact order and columns correspond to loci in the genetic map `gmap` in the exact order. For an individual, the haplotype should be (f1 m1 f2 m2 ...) where fi is the allele from father at the i-th locus and mi is the allele from mother at the i-th locus. Elements should be non-negative integers that are not larger than 16384. If missing, two founders with alleles 1 and 2 are assumed.
`method` | Permutation or gene dropping.
`vc` | An object from `estVC` or `aicVC`, or an estimated variance-covariance matrix induced by relatedness. The scan will assume no polygenic variation if `vc` is NULL.
`intcovar` | Covariates that interact with QTL.
`test` | "None", "F" or "Chisq".
`minorGenoFreq` | Specify the minimum tolerable minor genotype frequency at a scanning locus if `gdat` is used.
`rmv` | A logical variable. If true, then the scanning locus will be skipped if the minor genotype frequency at the locus is smaller than `minorGenoFreq`. Otherwise, the scanning process will stop and return with NULL.
`gr` | The generation under consideration.
`ntimes` | Number of simulations.

### Details

Two methods considered here are permutation test and gene dropping test as described as follows.

Permutation test. Depending on the genome-scan, one can provide either `gdat` or `prdat` respectively corresponding to single-marker analysis or interval mapping. Then only arguments in `scanOne` are needed in addition to `method` and `ntimes`.

Gene dropping test. If `prdat` is provided, then `gdat` will be ignored. The procedure will first call `genoSim` to generate new genotype data and then call `genoProb` to generate data for Haley-Knott interval mapping. If `prdat` is not provided, then `gdat` should be provided. The procedure will generate new genotype data and scan the genome using these generated genotype data. Haldane mapping function is used to generate data.

### Value

A vector of numbers of length `ntimes` if `minorGenoFreq > 0` and `rmv = TRUE`, each element of which is maximum of the test statistic over the genome scan (so `test` should be "None"), or a matrix of `ntimes` rows, each row of which records a genome scan.

### See Also

`genoSim`, `genoProb` and `scanOne`.

### Examples

    data(miscEx)

    ## Not run:
    # impute missing genotypes
    pheno<- pdatF8[!is.na(pdatF8$bwt) & !is.na(pdatF8$sex),]
    ii<- match(rownames(pheno), rownames(gdatF8))
    geno<- gdatF8[ii,]
    ii<- match(rownames(pheno), rownames(gmF8$AA))
    v<- list(A=gmF8$AA[ii,ii], D=gmF8$DD[ii,ii])

    gdatTmp<- genoImpute(geno, gmap=gmapF8, step=Inf,
       gr=8, na.str=NA)
    # estimate variance components
    o<- estVC(y=pheno$bwt, x=pheno$sex, v=v)

    # scan marker loci & permutation
    ex1<- nullSim(y=pheno$bwt, x=pheno$sex, gdat=gdatTmp,
    	method="permutation", vc=o, ntimes=10)
    dim(ex1)

    # scan marker loci & gene dropping
    ex2<- nullSim(y=pheno$bwt, x=pheno$sex, gdat=gdatTmp, ped=ped,
    	gmap=gmapF8, method="gene", vc=o, ntimes=10)
    dim(ex2)

    # Haley-Knott method & permutation
    gdtmp<- geno
       gdtmp<- replace(gdtmp,is.na(gdtmp),0)
    prDat<- genoProb(gdat=gdtmp, gmap=gmapF8, step=Inf,
       gr=8, method="Haldane", msg=TRUE)
    ex3<- nullSim(y=pheno$bwt, x=pheno$sex, prdat=prDat,
    	method="permutation", vc=o, ntimes=10)
    dim(ex3)

    # Haley-Knott method & gene dropping
    ex4<- nullSim(y=pheno$bwt, x=pheno$sex, prdat=prDat, ped=ped,
    	gmap=gmapF8, method="gene", vc=o, gr=8, ntimes=10)
    dim(ex4)

    ## End(Not run)

[Package QTLRel version 1.0 Index]