R: Class "gendata"

gendata-class {polysat} | R Documentation

## Class "gendata"

### Description

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 from the Class

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`.

### Slots

`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"`.

### Methods

deleteLoci

  `signature(object = "gendata")`: Permanently remove loci from the dataset. This removes elements from `Usatnts`.

deleteSamples

  `signature(object = "gendata")`: Permanently remove samples from the dataset. This removes elements from `PopInfo` and `Ploidies`.

Description

  `signature(object = "gendata")`: Returns the character vector in the `Description` slot.

Description<-

  `signature(object = "gendata")`: Assigns a new value to the character vector in the `Description` slot.

initialize

  `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.

Loci

  `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)`.

Loci

  `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.

Loci

  `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.

Loci

  `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.

Loci<-

  `signature(object = "gendata")`: Assigns new names to loci in the dataset (changes `names(object@Usants)`. Should not be used for adding or removing loci.

Missing

  `signature(object = "gendata")`: Returns the missing data symbol from `object@Missing`.

Missing<-

  `signature(object = "gendata")`: Assigns a new value to `object@Missing` (changes the missing data symbol).

Ploidies

  `signature(object = "gendata", samples = "ANY", loci = "ANY")`: Returns the ploidies in the dataset (`object@Ploidies`), indexed by sample and locus if applicable..

Ploidies<-

  `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.

PopInfo

  `signature(object = "gendata")`: Returns the population numbers of samples in the dataset (`object@PopInfo`).

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.

PopNames

  `signature(object = "gendata")`: Returns a character vector of population names (`object@PopNames`).

PopNames<-

  `signature(object = "gendata")`: Assigns new names to populations.

PopNum

  `signature(object = "gendata", popname="character")`: Returns the number corresponding to a population name.

PopNum<-

  `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.

Samples

  `signature(object = "gendata", populations = "character", ploidies = "missing")`: Returns all sample names for a given set of population names.

Samples

  `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.

Samples

  `signature(object = "gendata", populations = "missing", ploidies = "missing")`: Returns all sample names.

Samples

  `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.

Samples

  `signature(object = "gendata", populations = "numeric", ploidies = "missing")`: Returns all sample names for a given set of population numbers.

Samples

  `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.

Samples<-

  `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.

summary

  `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.

Usatnts

  `signature(object = "gendata")`: Returns microsatellite repeat lengths for loci in the dataset (`object@Usatnts`).

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.

merge

  `signature(x = "gendata", y = "gendata")`: Merges two genotype objects. See `merge,gendata,gendata-method`.

### Author(s)

Lindsay V. Clark

### See Also

`genambig`, `genbinary`, `Accessors`

### Examples

    # 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)

[Package polysat version 1.7-6 Index]