| 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 integer1by default. This symbol is used in theGenotypesslot to indicate the presence of an allele in a sample.Absent:Object of class
"ANY". The integer0by default. This symbol is used in theGenotypesslot 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-9by default. This symbol is used in theGenotypesslot 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.2indicates dinucleotide repeats,3indicates trinucleotide repeats, and so on. If the alleles stored in the column names of theGenotypesslot for a given locus are already written in terms of repeat number, theUsatntsvalue for that locus should be1. In other words, all alleles for a locus can be divided by the number inUsatntsto 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 thePopInfoslot.
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 theGenotypesslot is searched for the old symbol, which is replaced by the new. The new symbol is then written to theAbsentslot.- 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 theGenotypesslot, or a subset as specified by thesamplesandlociarguments.- 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 theGenotypesslot 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 theGenotypesslot) is not identical toSamples(object), thesamplesargument should be used to indicate row order. Row names invalueare ignored. Thelociargument can be left at the default, even if only a subset of loci are being assigned. Column names ofvalueare important, and should be the locus name and allele name separated by a period, as they are in theGenotypesslot. After checking that the column name is valid, the method checks for whether the column name already exists or not in theGenotypesslot. If it does exist, data from that column are replaced with data fromvalue. If not, a column is added to the matrix in theGenotypesslot for the new allele. If the column is new and data are not being written for samples, the method automatically fills inMissingorAbsentsymbols 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 agenbinaryobject whennew("genbinary")is called. Ifsamplesorlociarguments are missing, these are filled in with dummy values ("ind1", "ind2", "loc1", "loc2"). The matrix is then set up in theGenotypesslot. Sample names are used for row names, and there are zero columns. Theinitializemethod forgendatais then called.- Missing<-
signature(object = "genbinary"): Replaces all elements in matrix in theGenotypesslot containing the oldMissingsymbol with the newMissingsymbol. The method forgendatais then called to replace the value in theMissingslot.- 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 theGenotypesslot, and then in thePresentslot.- Samples<-
signature(object = "genbinary"): Changes sample names in the dataset. Changes the row names in theGenotypesslot, then calls the method forgendatato change the names in thePopInfoandPloidiesslots.- Loci<-
signature(object = "genbinary"): Changes locus names in the dataset. Replaces the locus portion of the column names in theGenotypesslot, then calls the method forgendatato change the names in theUsatntsslot.- 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 forgendatato 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 agenbinaryobject 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 thePloidiesslot 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