View source: R/class_conversion.R
genambig.to.genbinary | R Documentation |
These functions convert back and forth between the genambig
and
genbinary
classes.
genambig.to.genbinary(object, samples = Samples(object), loci = Loci(object)) genbinary.to.genambig(object, samples = Samples(object), loci = Loci(object))
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. |
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.
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.
Lindsay V. Clark
genambig
, genbinary
# 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.