either an object of class genotype or
haplotype or an object to be converted to class genotype or
haplotype.
a1,a2
vector(s) or matrix containing two alleles
for each individual. See details, below.
alleles
names (and order if reorder="yes") of possible
alleles.
sep
character separator or column number used to divide
alleles when a1 is a vector of strings where each string
holds both alleles. See below for details.
remove.spaces
logical indicating whether spaces and tabs will
be removed from a1 and a2 before processing.
reorder
how should alleles within an individual be reordered.
If reorder="no", use the order specified by the alleles
parameter. If reorder="freq" or
reorder="yes", sort alleles within each individual by
observed frequency. If reorder="ascii", reorder alleles in
ASCII order (alphabetical, with all upper case before
lower case). The default value for genotype
is "freq". The default value for haplotype is
"no".
allow.partial.missing
logical indicating whether one allele is
permitted to be missing. When set to FALSE both alleles
are set to NA when either is missing.
locus
object of class locus, gene, or marker, holding
information about the source of this genotype.
genotypeOrder
character, vector of genotype/haplotype names so
that further functions can sort genotypes/haplotypes in wanted
order
...
optional arguments
Details
Genotype objects hold information on which gene or marker alleles were
observed for different individuals. For each individual, two alleles
are recorded.
The genotype class considers the stored alleles to be unordered, i.e., "C/T"
is equivalent to "T/C". The haplotype class considers the order of the
alleles to be significant so that "C/T" is distinct from "T/C".
When calling genotype or haplotype:
If only a1 is provided and is a character vector, it is
assumed that each element encodes both alleles. In this case, if
sep is a character string, a1 is assumed to be coded
as "Allele1<sep>Allele2". If sep is a numeric value, it is
assumed that character locations 1:sep contain allele 1 and
that remaining locations contain allele 2.
If a1 is a matrix, it is assumed that column 1 contains
allele 1 and column 2 contains allele 2.
If a1 and a2 are both provided, each is assumed to
contain one allele value so that the genotype for an individual is
obtained by paste(a1,a2,sep="/").
If remove.spaces is TRUE, (the default) any whitespace
contained in a1 and a2 is removed when the genotypes are
created. If whitespace is used as the separator, (eg "C C", "C T",
...), be sure to set remove.spaces to FALSE.
When the alleles are explicitly specified using the alleles
argument, all potential alleles not present in the list will be
converted to NA.
NOTE: genotype assumes that the order of the alleles is not important
(E.G., "A/C" == "C/A"). Use class haplotype if order is significant.
If genotypeOrder=NULL (the default setting), then
expectedGenotypes is used to get standard sorting order.
Only unique values in genotypeOrder are used, which in turns
means that the first occurrence prevails. When genotypeOrder is
given some genotype names, but not all that appear in the data, the
rest (those in the data and possible combinations based on allele
variants) is automatically added at the end of
genotypeOrder. This puts "missing" genotype names at the end of
sort order. This feature is especially useful when there are a lot of
allele variants and especially in haplotypes. See examples.
Value
The genotype class extends "factor" and haplotype extends
genotype. Both classes have the following attributes:
levels
character vector of possible genotype/haplotype values
stored coded by paste( allele1, "/", allele2, sep="").
allele.names
character vector of possible alleles. For a SNP,
these might be c("A","T"). For a variable length dinucleotyde
repeat this might be c("136","138","140","148").
allele.map
matrix encoding how the factor levels correspond to
alleles. See the source code to allele.genotype() for how to
extract allele values using this matrix. Better yet, just use
allele.genotype().
genotypeOrder
character, genotype/haplotype names in
defined order that can used for sorting in various functions. Note
that this slot stores both ordered and unordered genotypes
i.e. "A/B" and "B/A".