This is a superclass for other classes that contain population
genetic datasets. It has slots for population information, ploidy,
microsatellite repeat lengths, and a missing data symbol, but does not
have a slot to store genotypes. Sample and locus names are stored as
the names
of vectors in the slots.
Objects can be created by calls of the form new("gendata", samples, loci, ...)
.
The missing data symbol will be set to -9
by default. The
default initial value for PopNames
is a
character vector of length 0, and for Description
is the string
"Insert dataset description here"
. The default initial value for
the Ploidies
slot is a "ploidymatrix"
object, containing a matrix filled with NA
and named by samples
in the first dimension and loci in the second dimension. For
other slots, vectors filled with NA
will be generated and will be
named by samples (for PopInfo
) or loci (for
Usatnts
). The slots can then be edited
using the methods described below.
Note that in most cases you will want to instead create an
object from one of gendata
's subclasses, such as genambig
.
Description
:Object of class "character"
. One
or more character strings to name or describe the dataset.
Missing
:Object of class "ANY"
. A value to
indicate missing data in the genotypes of the dataset. -9
by default.
Usatnts
:Object of class "integer"
. This
vector must be named by locus names. Each element should be the
length of the microsatellite repeat for that locus, given in nucleotides.
For example, 2
would indicate a locus with dinucleotide
repeats, and 3
would indicate a locus with trinucleotide
repeats. 1
should be used for mononucleotide repeats OR if
alleles for that locus are already expressed in terms of repeat
number rather than nucleotides. To put it another way, if you
divided the number used to represent an allele by the corresponding
number in Usatnts
(and rounded if necessary), the result would
be the number of repeats (plus some additional length for flanking regions).
Ploidies
:Object of class "ploidysuper"
. This
object will contain a pld
slot that is a matrix named by
samples and loci, a vector named by samples or loci, or a single
value, depending on the subclass. Each element is an integer that
represents ploidy. NA
indicates unknown ploidy.
PopInfo
:Object of class "integer"
. This
vector also must be named by sample names. Each element
represents the number of the population to which each sample belongs.
PopNames
:Object of class "character"
. An
unnamed vector containing the name of each population. If a
number from PopInfo
is used to index PopNames
, it
should find the correct population name. For example, if the
first element of PopNames
is "ABC"
, then any samples
with 1
as their PopInfo
value belong to population
"ABC"
.
signature(object = "gendata")
: Permanently
remove loci from the dataset. This removes elements from Usatnts
.
signature(object = "gendata")
:
Permanently remove samples from the dataset. This removes
elements from PopInfo
and Ploidies
.
signature(object = "gendata")
: Returns the
character vector in the Description
slot.
signature(object = "gendata")
: Assigns a
new value to the character vector in the Description
slot.
signature(.Object = "gendata")
: This is
called when the new("gendata")
function is used. A new
gendata
object is created with sample and locus names used
to index the appropriate slots.
signature(object = "gendata", usatnts =
"missing", ploidies="missing")
: Returns a character vector
containing all locus
names for the object. The method accomplishes this by returning
names(object@Usatnts)
.
signature(object = "gendata", usatnts =
"numeric", ploidies = "missing")
: Returns a character vector
of all loci for a given
set of repeat lengths. For example, if usatnts = 2
all
loci with dinucleotide repeats will be returned.
signature(object= "gendata", usatnts = "missing",
ploidies = "numeric")
: Returns a character vector of all loci for a
given set of ploidies. Only works if object@Ploidies
is a
"ploidylocus"
object.
signature(object = "gendata", usatnts = "numeric",
ploidies = "numeric")
: Returns a character vector of all loci that have
one of the indicated repeat types and one of the indicated ploidies.
Only works if object@Ploidies
is a "ploidylocus"
object.
signature(object = "gendata")
: Assigns new
names to loci in the dataset (changes names(object@Usants)
.
Should not be used for adding or removing loci.
signature(object = "gendata")
: Returns the
missing data symbol from object@Missing
.
signature(object = "gendata")
: Assigns a new
value to object@Missing
(changes the missing data symbol).
signature(object = "gendata", samples = "ANY",
loci = "ANY")
: Returns the
ploidies in the dataset (object@Ploidies
), indexed by
sample and locus if applicable..
signature(object = "gendata")
: Assigns new
values to ploidies of samples in the dataset. The assigned values
are coerced to integers by the method. Names in the assigned
vector or matrix are ignored; sample and/or locus names already
present in the gendata
object are used instead.
signature(object = "gendata")
: Returns the
population numbers of samples in the dataset (object@PopInfo
).
signature(object = "gendata")
: Assigns new
population numbers to samples in the dataset. The assigned values
are coerced to integers by the method. Names in the assigned
vector are ignored; sample names already present in the
gendata
object are used instead.
signature(object = "gendata")
: Returns a
character vector of population names (object@PopNames
).
signature(object = "gendata")
: Assigns new
names to populations.
signature(object = "gendata",
popname="character")
: Returns the number corresponding to a
population name.
signature(object = "gendata", popname =
"character")
: Changes the population number for a given
population name, merging it with an existing population of that
number if applicable.
signature(object = "gendata", populations =
"character", ploidies = "missing")
: Returns all sample names
for a given set of population names.
signature(object = "gendata", populations =
"character", ploidies = "numeric")
: Returns all sample names
for a given set of population names and ploidies. Only samples
that fit both criteria will be returned.
signature(object = "gendata", populations =
"missing", ploidies = "missing")
: Returns all sample names.
signature(object = "gendata", populations =
"missing", ploidies = "numeric")
: Returns all sample names for
a given set of ploidies. Only works if object@Ploidies
is a
"ploidysample"
object.
signature(object = "gendata", populations =
"numeric", ploidies = "missing")
: Returns all sample names for
a given set of population numbers.
signature(object = "gendata", populations =
"numeric", ploidies = "numeric")
: Returns all sample names for
a given set of population numbers and ploidies. Only samples that
fit both criteria will be returned. Only works if
object@Ploidies
is a "ploidysample"
object.
signature(object = "gendata")
: Assigns new
names to samples. This edits both names(object@PopInfo)
and
names(object@Ploidies)
. It should not be used for adding
or removing samples from the dataset.
signature(object = "gendata")
: Prints some
informaton to the console, including the numbers of samples, loci,
and populations, the ploidies present, and the types of
microsatellite repeats present.
signature(object = "gendata")
: Returns
microsatellite repeat lengths for loci in the dataset
(object@Usatnts
).
signature(object = "gendata")
: Assigns new
values to microsatellite repeat lengths of loci
(object@Usatnts
). The assigned values
are coerced to integers by the method. Names in the assigned
vector are ignored; locus names already present in the
gendata
object are used instead.
signature(x = "gendata", i = "ANY", j = "ANY")
:
Subscripts the data by a subset of samples and/or loci. Should be
used in the format mygendata[mysamples, myloci]
. Returns a
gendata
object with PopInfo
, Ploidies
, and
Usatnts
truncated to only contain the samples and loci
listed in i
and j
, respectively.
Description
, Missing
, and PopNames
are left
unaltered.
signature(x = "gendata", y = "gendata")
: Merges
two genotype objects. See merge,gendata,gendata-method
.
Lindsay V. Clark
genambig
, genbinary
,
Accessors
# show class definition
showClass("gendata")
# create an object of the class gendata
# (in reality you would want to create an object belonging to one of the
# subclasses, but the procedure is the same)
mygen <- new("gendata", samples = c("a", "b", "c"),
loci = c("loc1", "loc2"))
Description(mygen) <- "An example for the documentation"
Usatnts(mygen) <- c(2,3)
PopNames(mygen) <- c("PopV", "PopX")
PopInfo(mygen) <- c(2,1,2)
Ploidies(mygen) <- c(2,2,4,2,2,2)
# view a summary of the object
summary(mygen)
Run the code above in your browser using DataLab