Description Usage Arguments Value Author(s) See Also Examples
Converts object x
to a data frame of class genalex
.
There are seven cases:
If x
is of class genalex
, it is simply returned.
If x
is of class genalex
and force = TRUE
,
x
is examined for consistency between data and annotations,
and any inconsistencies are recalculated based on the data. To
check whether inconsistencies exist, use
is.genalex(..., force = TRUE)
and add verbose = TRUE
for descriptions of the inconsistencies. Ploidy is taken from
x
and is not reset. Attributes that may be reset include
n.samples
, sample.title
, n.loci
,
locus.columns
, locus.names
, n.pops
,
pop.labels
, pop.sizes
and pop.title
.
If x
is of class 'data.frame'
, it is examined to
see if it might be a data frame created by an earlier version of
the readGenalex
package. If so, it is converted to
class genalex
and returned. Any other arguments are
ignored.
If x
is of class 'data.frame'
and all columns from
the third to the end are of class genotype
from the
genetics
package, these columns are converted to class genalex
genotypes, with one column per allele. Once the alleles have been
split, a call to genalex
establishes the correct
attributes.
If x
is of class 'data.frame'
but does not appear to
be from an earlier version of readGenalex
and does not
have all genotype columns of class genotype
,
it is converted to class genalex
using a call to
genalex
assuming a format identical to class
genalex
, where the first column holds sample names, the
second column holds population names, and the remaining columns
hold genotypes.
If x
is of class loci
from the
pegas
package, it is converted using
splitGenotypes
and genalex
. Sample
names are taken from the row names. If there
is no column in x
named "population"
, then the
pop
argument must be supplied as a substitute. Additional
non-genotype columns will likely result in an error. No attempt
is currently made to use the "locicol"
attribute to narrow
the conversion to only locus columns. Furthermore, only diploid
genotypes are currently handled.
Any other class is an error. Further conversions between genetic data formats may be added as additional methods.
If the object is not originally of class genalex
, the
"data.file.name"
attribute will reflect this function call.
1 2 3 4 5 6 7 8 9 10 11 | ## S3 method for class 'genalex'
as.genalex(x, force = FALSE, ...)
## S3 method for class 'data.frame'
as.genalex(x, names = NULL, ploidy = 2, ...)
## S3 method for class 'loci'
as.genalex(x, sep = "/", pop, ...)
## Default S3 method:
as.genalex(x, ...)
|
x |
An object of class |
force |
If |
names |
A list of names to apply as accepted by |
ploidy |
Ploidy of the genotype columns in |
sep |
Character separating joined alleles, if converting from
object of class |
pop |
Populations to assign to samples if there is no
|
... |
Additional arguments, ignored unless |
x
converted to a class genalex
object
Douglas G. Scofield
is.genalex
, genalex
, splitGenotypes
1 2 3 4 5 | data(Qagr_adult_genotypes)
gt <- as.genalex(Qagr_adult_genotypes)
cat(attr(gt, "data.file.name"), "\n")
gt.2 <- as.genalex(as.data.frame(Qagr_adult_genotypes))
cat(attr(gt.2, "data.file.name"), "\n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.