genbinary-class {polysat} | R Documentation |
Class "genbinary"
Description
This is a subclass of gendata
that allows genotypes to be stored
as a matrix indicating the presence and absence of alleles.
Objects from the Class
Objects can be created by calls of the form new("genbinary",
samples, loci, ...)
. After objects are initialized with sample and
locus names, data can be added to slots using the replacement functions.
Slots
Genotypes
:Object of class
"matrix"
. Row names of the matrix are sample names. Each column name is a locus name and an allele separated by a period (e.g."loc1.124"
); each column represents on allele. The number of alleles per locus is not limited and can be expanded even after entering initial data. Each element of the matrix must be equal to eitherPresent(object)
,Absent(object)
, orMissing(object)
. These symbols indicate, respectively, that a sample has an allele, that a sample does not have an allele, or that data for the sample at that locus are missing.Present
:Object of class
"ANY"
. The integer1
by default. This symbol is used in theGenotypes
slot to indicate the presence of an allele in a sample.Absent
:Object of class
"ANY"
. The integer0
by default. This symbol is used in theGenotypes
slot to indicate the absence of an allele in a sample.Description
:Object of class
"character"
. A character string or vector describing the dataset, for the convenience of the user.Missing
:Object of class
"ANY"
. The integer-9
by default. This symbol is used in theGenotypes
slot to indicate that data are missing for a given sample and locus.Usatnts
:Object of class
"integer"
. A vector, named by loci. This indicates the repeat length of each locus.2
indicates dinucleotide repeats,3
indicates trinucleotide repeats, and so on. If the alleles stored in the column names of theGenotypes
slot for a given locus are already written in terms of repeat number, theUsatnts
value for that locus should be1
. In other words, all alleles for a locus can be divided by the number inUsatnts
to give alleles expressed in terms of relative repeat number.Ploidies
:Object of class
"integer"
. A vector, named by samples. This indicates the ploidy of each sample.PopInfo
:Object of class
"integer"
. A vector, named by samples. This indicates the population identity of each sample.PopNames
:Object of class
"character"
. Names of each population. The position of the population name in the vector corresponds to the number used to represent that population in thePopInfo
slot.
Extends
Class "gendata"
, directly.
Methods
- Absent
signature(object = "genbinary")
: Returns the symbol used to indicate that a given allele is absent in a given sample.- Absent<-
signature(object = "genbinary")
: Changes the symbol used to indicate that a given allele is absent in a given sample. The matrix in theGenotypes
slot is searched for the old symbol, which is replaced by the new. The new symbol is then written to theAbsent
slot.- Genotype
signature(object = "genbinary")
: Returns a matrix containing the genotype for a given sample and locus (by a call toGenotypes
).- Genotypes
signature(object = "genbinary")
: Returns the matrix stored in theGenotypes
slot, or a subset as specified by thesamples
andloci
arguments.- Genotypes<-
signature(object = "genbinary")
: A method for adding or replacing genotype data in the object. Note that allele columns cannot be removed from the matrix in theGenotypes
slot using this method, although an entire column could be filled with zeros in order to effectively remove an allele from the dataset. If the order of rows invalue
(the matrix containing values to be assigned to theGenotypes
slot) is not identical toSamples(object)
, thesamples
argument should be used to indicate row order. Row names invalue
are ignored. Theloci
argument can be left at the default, even if only a subset of loci are being assigned. Column names ofvalue
are important, and should be the locus name and allele name separated by a period, as they are in theGenotypes
slot. After checking that the column name is valid, the method checks for whether the column name already exists or not in theGenotypes
slot. If it does exist, data from that column are replaced with data fromvalue
. If not, a column is added to the matrix in theGenotypes
slot for the new allele. If the column is new and data are not being written for samples, the method automatically fills inMissing
orAbsent
symbols for additional samples, depending on whether or not data for the locus appear to be missing for the sample or not.- initialize
signature(.Object = "genbinary")
: Sets up agenbinary
object whennew("genbinary")
is called. Ifsamples
orloci
arguments are missing, these are filled in with dummy values ("ind1", "ind2", "loc1", "loc2"
). The matrix is then set up in theGenotypes
slot. Sample names are used for row names, and there are zero columns. Theinitialize
method forgendata
is then called.- Missing<-
signature(object = "genbinary")
: Replaces all elements in matrix in theGenotypes
slot containing the oldMissing
symbol with the newMissing
symbol. The method forgendata
is then called to replace the value in theMissing
slot.- Present
signature(object = "genbinary")
: Returns the symbol used to indicate that a given allele is present in a given sample.- Present<-
signature(object = "genbinary")
: Changes the symbol used for indicating that a given allele is present in a given sample. The symbol is first replaced in theGenotypes
slot, and then in thePresent
slot.- Samples<-
signature(object = "genbinary")
: Changes sample names in the dataset. Changes the row names in theGenotypes
slot, then calls the method forgendata
to change the names in thePopInfo
andPloidies
slots.- Loci<-
signature(object = "genbinary")
: Changes locus names in the dataset. Replaces the locus portion of the column names in theGenotypes
slot, then calls the method forgendata
to change the names in theUsatnts
slot.- isMissing
signature(object = "genbinary")
: Returns Boolean values, by sample and locus, indicating whether genotypes are missing. If there are any missing data symbols within the genotype, it is considered missing.- summary
signature(object = "genbinary")
: Prints description of dataset and number of missing genotypes, then calls the method forgendata
to print additional information.- editGenotypes
signature(object = "genbinary")
: Opens the genotype matrix in the Data Editor for editing. Useful for making minor changes, although allele columns cannot be added using this method.- viewGenotypes
signature(object = "genbinary")
: Prints the genotype matrix to the console, one locus at a time.- deleteSamples
signature(object = "genbinary")
: Removes the specified samples from the genotypes matrix, then calls the method forgendata
.- deleteLoci
signature(object = "genbinary")
: Removes the specified loci from the genotypes matrix, then calls the method forgendata
.- "["
signature(x = "genbinary", i = "ANY", j = "ANY")
: Subscripting method. Returns agenbinary
object with a subset of the samples and/or loci fromx
. Usage:genobject[samples,loci]
.- estimatePloidy
signature(object = "genbinary")
: Creates a data frame of mean and maximum number of alleles per sample, which is then opened in the Data Editor so that the user can manually specify the ploidy of each sample. Ploidies are then written to thePloidies
slot of the object.- merge
signature(x = "genbinary", y = "genbinary")
: Merges two genotype objects together. Seemerge,genbinary,genbinary-method
.
Author(s)
Lindsay V. Clark
See Also
Examples
# show the class definition
showClass("genbinary")
# create a genbinary object
mygen <- new("genbinary", samples = c("indA", "indB", "indC", "indD"),
loci = c("loc1", "loc2"))
Description(mygen) <- "Example genbinary object for the documentation."
Usatnts(mygen) <- c(2,3)
PopNames(mygen) <- c("Maine", "Indiana")
PopInfo(mygen) <- c(1,1,2,2)
Genotypes(mygen) <- matrix(c(1,1,0,0, 1,0,0,1, 0,0,1,1,
1,-9,1,0, 0,-9,0,1, 1,-9,0,1, 0,-9,1,1),
nrow=4, ncol=7, dimnames = list(NULL,
c("loc1.140", "loc1.144", "loc1.150",
"loc2.97", "loc2.100", "loc2.106", "loc2.109")))
# view all of the data in the object
mygen