Title: | Functions to Simulate Haplotypes |
---|---|
Description: | Simulate haplotypes through meioses. Allows specification of population parameters. |
Authors: | Albart Coster [aut, cre], John Bastiaansen [aut] |
Maintainer: | Albart Coster <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.8.4.2 |
Built: | 2024-10-28 06:59:47 UTC |
Source: | CRAN |
AssignQTL
assigns QTL to the qtl
of objects of class
haplotype
. ListQTL
returns a list of qtl which for the
object of class haploList
.
AssignQTL(hList,nqtl = NA,frqtl = NA,sigma2qtl = NULL,shQTL = 1,scQTL = 1, nTraits = 1,overlap = 0,MAF = 0.1,rmCausSNP = TRUE) ListQTL(hList,nqtl = NA,frqtl = NA,sigma2qtl = NULL,shQTL = 1,scQTL = 1, nTraits = 1,overlap = 0,MAF = 0.1)
AssignQTL(hList,nqtl = NA,frqtl = NA,sigma2qtl = NULL,shQTL = 1,scQTL = 1, nTraits = 1,overlap = 0,MAF = 0.1,rmCausSNP = TRUE) ListQTL(hList,nqtl = NA,frqtl = NA,sigma2qtl = NULL,shQTL = 1,scQTL = 1, nTraits = 1,overlap = 0,MAF = 0.1)
hList |
List of haplotype objects. |
nqtl |
If specified, the number of qtl which are placed on the genome. |
frqtl |
If specified, the fraction of heterozygous SNP loci which become QTL. |
sigma2qtl |
If specified, the qtl variance. If
|
shQTL |
If alpha is not specified, shQTL specifies the shape parameter of the gamma distribution from which allele substitution effects are sampled. |
scQTL |
If alpha is not specified, scQTL specifies the scale parameter of the gamma distribution from which allele substitution effects are sampled. |
nTraits |
The number of traits. |
overlap |
Numeric between 0 and 1. Specifies the percantage of pleiotropic QTL. |
MAF |
Minor Allele Frequency. Loci with maf below MAF are not considered to become QTL. Do not count for frqtl. |
rmCausSNP |
Remove causative SNPs. |
A list of length nHaplotpes
.
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects hListd <- SampleHaplotypes(orig = hList,genDist = 1,nDec = 3) hListQTL <- AssignQTL(hList,frqtl = 0.1,MAF = 0.0) hListd <- SampleHaplotypes(orig = hListQTL,genDist = 1,nDec = 3,QTL = TRUE) qtlList <- ListQTL(hList,frqtl = 0.1,MAF = 0.0)
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects hListd <- SampleHaplotypes(orig = hList,genDist = 1,nDec = 3) hListQTL <- AssignQTL(hList,frqtl = 0.1,MAF = 0.0) hListd <- SampleHaplotypes(orig = hListQTL,genDist = 1,nDec = 3,QTL = TRUE) qtlList <- ListQTL(hList,frqtl = 0.1,MAF = 0.0)
Builds a haplotype pedigree from a list of objects of class
haplotype
. Objects have attributes hID
and phID0
,
phID1
, the last two refer to the two haplotypes in the
parent. Function can construct a new pedigree or continue a given pedigree.
Simulate a list of haplotypes, either sampling using population
parameters or from a previous list of haplotypes through a series of
meioses.
buildhPedigree(hPedigree = NULL,hList)
buildhPedigree(hPedigree = NULL,hList)
hPedigree |
If unspecified, the previous haplotype pedigree upon which buildhPed builds the additional haplotypes. |
hList |
A |
The function buildhPedigree
uses the attributes hID
,
phID0
, phID1
of objects of class haplotype to
build a pedigree of haplotypes. Each haplotype originates
from a pair of parental haplotypes between which the meiosis event
occured or has no known parental haplotypes.
A data.frame
.
example(SampleHaplotypes) hPedigree <- buildhPedigree(hList = hList) for(g in 1:10) { hList <- SampleHaplotypes(orig = hList,genDist = 1,roundDec = 3) hPedigree <- buildhPedigree(hPedigree=hPedigree,hList = hList) }
example(SampleHaplotypes) hPedigree <- buildhPedigree(hList = hList) for(g in 1:10) { hList <- SampleHaplotypes(orig = hList,genDist = 1,roundDec = 3) hPedigree <- buildhPedigree(hPedigree=hPedigree,hList = hList) }
Extract the sequence of snp alleles from a list of objects of
class haplotype
.
getAll(hList,what = c("snp","qtl"),removeHomozygotes = FALSE,translatePos = TRUE)
getAll(hList,what = c("snp","qtl"),removeHomozygotes = FALSE,translatePos = TRUE)
hList |
List of objects of class |
what |
Specifies if snp or qtl alleles are extracted from haplotype objects. |
removeHomozygotes |
If TRUE, homozygote genotypes are removed from the marker data. |
translatePos |
Translates marker positions to positions in Morgan, else keeps the positions as integers. |
Function removes homozygous snp loci before extracting these.
Matrix.
example(AssignQTL) hh <- getAll(hList = hList) qq <- getAll(hList = hList,what = 'qtl')
example(AssignQTL) hh <- getAll(hList = hList) qq <- getAll(hList = hList,what = 'qtl')
Function to create objects of class 'haploList'
. Can eiter copy
the attributes of an earlier object of class 'haploList'
or
create a new 'haploList'
object. Function mostly used within
other functions.
haploList(list = NULL,hList = NULL,nDec,genDist,nChrom = 1)
haploList(list = NULL,hList = NULL,nDec,genDist,nChrom = 1)
list |
List of objects of class |
hList |
Object of class |
nDec |
Number of decimal positions of new object. |
genDist |
Genome size of new object measured in Morgan. |
nChrom |
Number of chromosomes. |
An object of class 'haploList'
. If list
is not NULL,
object of filled with objects of class 'haplotype'
.
hList <- haploList(nDec= 1,genDist = 1) validhaploListObject(hList)
hList <- haploList(nDec= 1,genDist = 1) validhaploListObject(hList)
Class definition of haploList
. Extends lists to
contian objects of class haplotype
. Attributes are nDec
,
the number of decimal positions and genDist
, the genome size
measured in Morgan.
Objects can be created by calls of the form new("haploList", ...)
.
.Data
:Object of class "list"
containing
objects of class 'haplotype'
genDist
:Object of class "numeric"
expressing the genome size in Morgan.
nDec
:Object of class "integer"
expressing the number of decimal positions of the
haplotypes.
nChrom
:Object of class "integer"
expressing the number of chromosomes.
Class "list"
, from data part.
Class "vector"
, by class "list", distance 2.
signature(x = "haploList", i = "ANY", j =
"missing")
: subset and extract from object of class 'haploList'
signature(x = "haploList")
: concatenate object of
class 'haploList'
.
showClass("haploList")
showClass("haploList")
Definition of 'haplotype'
class.
Objects can be created by calls of the form new("haplotype", ...)
.
snp
:Object of class "integer"
containing the
positions on the genome where the haplotype has a 1 allele. The
number of snp positions is the genome size in Morgan times the
number of decimal positions, both stored in 'haploList'
objects.
qtl
:Object of class "list"
. Names of the list
are the QTL positions, on the same scale as snp positions. Objects
in the list are the QTL alleles.
hID
:Object of class "numeric"
identifying the
current object of class 'haplotype'
.
phID0
:Object of class "numeric"
pointing to
the first parental haplotype.
phID1
:Object of class "numeric"
pointing to
the second parental haplotype.
No methods defined with class "haplotype" in the signature.
SampleHaplotype
,
SampleHaplotypes
,
haploList
showClass("haplotype")
showClass("haplotype")
Transforms a haplotype pedigree into a pedigree. Individuals in a haplotype pedigree are identified through meiosis. The number of rows of the pedigree equals the number of unique combinations of haplotypes plus the number of haplotypes which did not 'participate' in a meiosis event. The latter haplotypes form individuals with only one haplotype and thus only one parent. Row number of the pedigree identifies individuals. The pedigree has four columns. Columns 3 and 4 identify the haplotypes of the individual. Columns 1 and 2 identify parental individuals of the individuals by their row number in the pedigree.
hPed2Ped(hPed)
hPed2Ped(hPed)
hPed |
The haplotype pedigree from which the pedigree is build. |
A data.frame
.
SampleHaplotype
, buildhPedigree
example(buildhPedigree) ped <- hPed2Ped(hPedigree)
example(buildhPedigree) ped <- hPed2Ped(hPedigree)
Finds homozygotic marker loci in a list of haplotypes and removes these from all haplotypes.
RemoveHomozygotes(hList)
RemoveHomozygotes(hList)
hList |
List of objects of class |
A list of objects of class haplotype
.
SampleHaplotypes
, SampleHaplotype
.
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects hList <- RemoveHomozygotes(hList)
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects hList <- RemoveHomozygotes(hList)
Simulates a base population haplotype.
SampleBaseHaplotype(genDist,nDec,nLoc,pSnp = seq(0,1,length.out = nLoc))
SampleBaseHaplotype(genDist,nDec,nLoc,pSnp = seq(0,1,length.out = nLoc))
genDist |
Map size of the simulated genome in Morgan. |
nDec |
Number of decimals until which marker positions are rounded. Partially specifies marker density on the chromosome. |
nLoc |
Maximal number of snp loci on genome, default is number of available positions on genome. |
pSnp |
Optional,if specified the snp positions. Default:
uniform distribution of loci over the whole genome. Consequence will
be that loci have allele frequency equal to one. If NULL, positions
will be randomly sampled for each haplotype and allele frequencies
will be close to 0, depending on |
Generally called by function SampleHaplotypes
.
An object of class haplotype
.
SampleHaplotypes
,
SampleBaseHaplotype
hList <- sapply(1:10,function(x)SampleBaseHaplotype(genDist = 1,nDec = 2,nLoc = 50))
hList <- sapply(1:10,function(x)SampleBaseHaplotype(genDist = 1,nDec = 2,nLoc = 50))
Simulates a haplotype, either sampling using population parameters or through a meiosis event with two parental haplotypes.
SampleHaplotype(H0 = NULL,H1 = NULL,genDist,nDec,nChrom = 1,prMut = 1E-5,QTL = F,checkValidity = TRUE)
SampleHaplotype(H0 = NULL,H1 = NULL,genDist,nDec,nChrom = 1,prMut = 1E-5,QTL = F,checkValidity = TRUE)
H0 |
If specified, the first parental haplotype. |
H1 |
If specified, the second parental haplotype. If neither H0 nor H1 are specified, a new haplotype is sampled from a base population. Errors message is displayed when only one haplotype is provided as meiosis occurs between two haplotypes. |
genDist |
Map size of the simulated genome in Morgan. |
nDec |
Number of decimals until which marker positions are rounded. Partially specifies marker density on the chromosome. |
nChrom |
Number of chromosomes, default at 1 |
prMut |
Probability of marker bp mutation. |
QTL |
If TRUE, qtl alleles are inherited to the next
generation. See function |
checkValidity |
If TRUE, tests if a pair of haplotypes is compatible; e.g. if the number of traits in both is equal (or 0) and if the sizes are equal. |
Markers are continually spaced over the whole genome. Marker density
is specified in SampleBaseHaplotype
. Position
of 1 alleles is recorded and stored in @snp attribute of the object of
class haplotype
.
If QTL is TRUE, haplotypes with QTL's need to be provided. If not,
nothing happens apart from mutations (same prob. as for single
basepairs).
Function SampleHaplotype
is generally called by function
SampleHaplotypes
.
An object of class haplotype
.
SampleHaplotypes
,
SampleBaseHaplotype
hList <- SampleHaplotypes(nHaplotypes = 20,genDist = 1,nDec = 3,nLoc = 20) ## create objects h <- SampleHaplotype(H0 = hList[[1]],H1 = hList[[2]],genDist = 1,nDec = 3)
hList <- SampleHaplotypes(nHaplotypes = 20,genDist = 1,nDec = 3,nLoc = 20) ## create objects h <- SampleHaplotype(H0 = hList[[1]],H1 = hList[[2]],genDist = 1,nDec = 3)
Simulate a list of haplotypes, either sampling using population parameters or from a previous list of haplotypes through a series of meioses.
SampleHaplotypes(orig = NULL,nHaplotypes = 10,nMeioses = 2,gg = NULL,...)
SampleHaplotypes(orig = NULL,nHaplotypes = 10,nMeioses = 2,gg = NULL,...)
orig |
If unspecified, the function samples base population
haplotypes. If specified, the function requests a list
containing objects of class |
nHaplotypes |
The requested number of haplotypes. |
nMeioses |
The number of offspring from each individual. For details see below. |
gg |
If specified, the combinations of haplotypes in individuals. Meiosis only occur within individuals. If not specified, individuals are sampled as random combinations of haplotypes. |
... |
Additional arguments to be passed to function
|
The function SampleHaplotypes
creates individuals by randomly
combining haplotypes from the list. Meiosis events in individuals
create new haplotypes. Argument nOff
sets the number of meiosis
events within each individual. Argument nHaplotypes
has only
effect when sampling a base population. See
SampleBaseHaplotype
for sampling base
haplotypes and for arguments of this function.
A list of length nHaplotpes
or nOff * length(orig)
of objects of class haplotype
.
SampleHaplotype
,
SampleBaseHaplotype
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects for(g in 1:10)hList <- SampleHaplotypes(orig = hList,genDist = 1,nDec = 3)
hList <- SampleHaplotypes(nHaplotypes = 20,nLoc = 100,genDist = 1,nDec = 3) ## create objects for(g in 1:10)hList <- SampleHaplotypes(orig = hList,genDist = 1,nDec = 3)
Simulates haplotypes within a given pedigree. Haplotypes for a base
individual are sampled from a list of base haplotypes. Parameters for
sampling haplotypes are passed to function SampleHaplotype
.
SamplePedigree(orig,ped,...)
SamplePedigree(orig,ped,...)
orig |
List of objects of class |
ped |
|
... |
Arguments to be passed to function |
Samples haplotypes for individuals in a pedigree and returns a
pedigree with two additional columns which identify the two haplotypes
of an individual together with a list of haplotypes. Uses function
SampleHaplotype
to sample a meiosis event between two parental
haplotypes.
A list with a pedigree and a list of objects of class
haplotype
.
example(SampleHaplotypes) ID <- 1:10 pID0 <- c(rep(0,5),1,1,3,3,5) pID1 <- c(rep(0,4),2,2,2,4,4,6) ped <- data.frame(ID,pID0,pID1) phList <- SamplePedigree(orig = hList,ped = ped)
example(SampleHaplotypes) ID <- 1:10 pID0 <- c(rep(0,5),1,1,3,3,5) pID1 <- c(rep(0,4),2,2,2,4,4,6) ped <- data.frame(ID,pID0,pID1) phList <- SamplePedigree(orig = hList,ped = ped)
Checks of object is of class 'haploList'
and checks if all
entries in [email protected]
are of class
'haplotype'
.
validhaploListObject(object)
validhaploListObject(object)
object |
Any object. |
Logical