pld: Accessor, Replacement, and Manipulation Functions for...

pldR Documentation

Accessor, Replacement, and Manipulation Functions for "ploidysuper" Objects

Description

pld accesses and replaces the pld slot of objects of "ploidysuper" subclasses. plCollapse tests whether an object of one of these classes can be converted to an object of a simpler one of these classes, and optionally returns the converted object. These are generic functions with methods for the subclasses of "ploidysuper". These functions are primarily for internal use.

Usage

pld(object, samples, loci)
pld(object) <- value
plCollapse(object, na.rm, returnvalue)

Arguments

object

A "ploidysuper" object.

samples

An optional character or numeric vector indexing the samples for which to return ploidy values.

loci

An optional character or numeric vector indexing the loci for which to return ploidy values.

value

A numeric vector or matrix that can be coerced to integers. These represent the ploidies to store in the object@pld slot.

na.rm

Boolean. If TRUE, NA values are ignored when testing to see if the ploidy format can be simplified. If the sample, locus, or entire dataset all has one ploidy aside from NA, the NA values will be overwritten by that ploidy when simplifying the ploidy format. If FALSE, NA is treated as a unique ploidy.

returnvalue

Boolean. If TRUE, a "ploidysuper" object will be returned if the ploidy format can be simplified, and FALSE will be returned if it cannot be simplified. If FALSE, only TRUE or FALSE will be returned to indicate if the ploidy format can be simplified or not.

Value

pld returns the vector or matrix containing the ploidy values. This is the contents of object@pld.

plCollapse either returns a Boolean value indicating whether the ploidy can be changed to a simpler format, or a new "ploidysuper" object with all of the ploidy data of object put into a simpler format. If object is a "ploidymatrix" object, a "ploidysample", "ploidylocus", or "ploidyone" object can be returned depending on how many unique ploidy values there are and how they are distributed. If object is a "ploidysample" or "ploidylocus" object, a "ploidyone" object can be returned.

Author(s)

Lindsay V. Clark

See Also

reformatPloidies, Ploidies

Examples

test <- new("ploidymatrix", samples=c("a","b","c"),
            loci=c("l1","l2","l3"))
pld(test)       # view the ploidies
pld(test) <- 2  # make it diploid at all samples and loci
pld(test)["a",] <- c(2,4,4) # change the ploidies for sample a
pld(test, samples=c("a","b")) # view ploidies at a subset of samples

# test to see if the ploidies can be simplified
p <- plCollapse(test, na.rm=FALSE, returnvalue=TRUE)
p
# now change a ploidy and repeat the test
pld(test)["a","l1"] <- 4
p <- plCollapse(test, na.rm=FALSE, returnvalue=TRUE)
p
# change something else and collapse it further
pld(p)["a"] <- 2
p2 <- plCollapse(p, na.rm=FALSE, returnvalue=TRUE)
p2

# if na.rm=FALSE, NA values are not ignored:
pld(test)["a","l1"] <- NA
pld(test)
plCollapse(test, na.rm=FALSE, returnvalue=TRUE)
# NA values are ignored with na.rm=TRUE
plCollapse(test, na.rm=TRUE, returnvalue=TRUE)

polysat documentation built on Aug. 23, 2022, 5:07 p.m.