| 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 either- Present(object),- Absent(object), or- Missing(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 integer- 1by default. This symbol is used in the- Genotypesslot to indicate the presence of an allele in a sample.
- Absent:
- Object of class - "ANY". The integer- 0by default. This symbol is used in the- Genotypesslot 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 the- Genotypesslot 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 the- Genotypesslot for a given locus are already written in terms of repeat number, the- Usatntsvalue for that locus should be- 1. In other words, all alleles for a locus can be divided by the number in- Usatntsto 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 the- PopInfoslot.
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 the- Genotypesslot is searched for the old symbol, which is replaced by the new. The new symbol is then written to the- Absentslot.
- Genotype
- signature(object = "genbinary"): Returns a matrix containing the genotype for a given sample and locus (by a call to- Genotypes).
- Genotypes
- signature(object = "genbinary"): Returns the matrix stored in the- Genotypesslot, or a subset as specified by the- samplesand- lociarguments.
- 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 the- Genotypesslot 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 in- value(the matrix containing values to be assigned to the- Genotypesslot) is not identical to- Samples(object), the- samplesargument should be used to indicate row order. Row names in- valueare ignored. The- lociargument can be left at the default, even if only a subset of loci are being assigned. Column names of- valueare important, and should be the locus name and allele name separated by a period, as they are in the- Genotypesslot. After checking that the column name is valid, the method checks for whether the column name already exists or not in the- Genotypesslot. If it does exist, data from that column are replaced with data from- value. If not, a column is added to the matrix in the- Genotypesslot for the new allele. If the column is new and data are not being written for samples, the method automatically fills in- Missingor- Absentsymbols 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 a- genbinaryobject when- new("genbinary")is called. If- samplesor- lociarguments are missing, these are filled in with dummy values (- "ind1", "ind2", "loc1", "loc2"). The matrix is then set up in the- Genotypesslot. Sample names are used for row names, and there are zero columns. The- initializemethod for- gendatais then called.
- Missing<-
- signature(object = "genbinary"): Replaces all elements in matrix in the- Genotypesslot containing the old- Missingsymbol with the new- Missingsymbol. The method for- gendatais then called to replace the value in the- Missingslot.
- 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 the- Genotypesslot, and then in the- Presentslot.
- Samples<-
- signature(object = "genbinary"): Changes sample names in the dataset. Changes the row names in the- Genotypesslot, then calls the method for- gendatato change the names in the- PopInfoand- Ploidiesslots.
- Loci<-
- signature(object = "genbinary"): Changes locus names in the dataset. Replaces the locus portion of the column names in the- Genotypesslot, then calls the method for- gendatato change the names in the- Usatntsslot.
- 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 for- gendatato 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 for- gendata.
- deleteLoci
- signature(object = "genbinary"): Removes the specified loci from the genotypes matrix, then calls the method for- gendata.
- "["
- signature(x = "genbinary", i = "ANY", j = "ANY"): Subscripting method. Returns a- genbinaryobject with a subset of the samples and/or loci from- x. 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 the- Ploidiesslot of the object.
- merge
- signature(x = "genbinary", y = "genbinary"): Merges two genotype objects together. See- merge,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