genambig.to.genbinary {polysat} | R Documentation |
Convert Between Genotype Object Classes
Description
These functions convert back and forth between the genambig
and
genbinary
classes.
Usage
genambig.to.genbinary(object, samples = Samples(object),
loci = Loci(object))
genbinary.to.genambig(object, samples = Samples(object),
loci = Loci(object))
Arguments
object |
The object containing the genetic dataset. A |
samples |
An optional character vector indicating samples to include in the new object. |
loci |
An optional character vector indicating loci to include in the new object. |
Details
The slots Description
, Ploidies
, Usatnts
,
PopNames
, and PopInfo
are transferred as-is from the old
object to the new. The value in the
Genotypes
slot is converted from one format to the other, with
preservation of allele names.
Value
For genambig.to.genbinary
: a genbinary
object containing
all of the data from object
. Missing
, Present
,
and Absent
are set at their default values.
For genbinary.to.genambig
: a genambig
object containing
all of the data from object
. Missing
is at the default
value.
Author(s)
Lindsay V. Clark
See Also
Examples
# set up a genambig object for this example
mygen <- new("genambig", samples = c("A", "B", "C", "D"),
loci = c("locJ", "locK"))
PopNames(mygen) <- c("PopQ", "PopR")
PopInfo(mygen) <- c(1,1,2,2)
Usatnts(mygen) <- c(2,2)
Genotypes(mygen, loci="locJ") <- list(c(178, 184, 186), c(174,186),
c(182, 188, 190),
c(182, 184, 188))
Genotypes(mygen, loci="locK") <- list(c(133, 135, 141),
c(131, 135, 137, 143),
Missing(mygen), c(133, 137))
# convert it to a genbinary object
mygenB <- genambig.to.genbinary(mygen)
# check the results
viewGenotypes(mygenB)
viewGenotypes(mygen)
PopInfo(mygenB)
# convert back to a genambig object
mygenA <- genbinary.to.genambig(mygenB)
viewGenotypes(mygenA)
# note: identical(mygen, mygenA) returns FALSE, because the alleles
# origninally input are not stored as integers, while the alleles
# produced by genbinary.to.genambig are integers.