as.loci | R Documentation |
These functions do conversion among different allelic data classes.
as.loci(x, ...)
## S3 method for class 'genind'
as.loci(x, ...)
genind2loci(x)
## S3 method for class 'data.frame'
as.loci(x, allele.sep = "/|", col.pop = NULL, col.loci = NULL, ...)
loci2genind(x, ploidy = 2, na.alleles = c("0", "."), unphase = TRUE)
## S3 method for class 'factor'
as.loci(x, allele.sep = "/|", ...)
## S3 method for class 'character'
as.loci(x, allele.sep = "/|", ...)
loci2SnpMatrix(x, checkSNP = TRUE)
x |
an object of class |
allele.sep |
the character(s) separating the alleles for each locus in the data file (a forward slash by default). |
col.pop |
specifies whether one of the column of the data file
identifies the population; default |
col.loci |
a vector of integers or of characters specifying the indices or the names of the columns that are loci. By default, all columns are taken as loci except the one labelled "population", if present or specified. |
ploidy |
the ploidy level (see details). |
na.alleles |
a vector of charater strings giving the alleles to be treated as missing data. |
unphase |
a logical value; by default, the genotypes are unphased before conversion (this should not be changed). |
... |
further arguments to be passed to or from other methods. |
checkSNP |
a logical value. If you are sure that all data in the
|
The main objectives of these functions is to provide easy conversion
between the data structures of adegenet and pegas, so both
packages can be used together smoothly. In addition, it is possible to
create a "loci"
object directly from a data frame, a vector, or
a factor.
genind2loci(x)
and as.loci(x)
are the same if x
is of class "genind"
.
The ploidy level specified in loci2genind
can be a vector in
which case it should be of length equal to the number of individuals
and will be interpreted as giving the ploidy of each of them. Note
that this is different from getPloidy
which returns the
ploidy level of each locus.
An object of class c("loci", "data.frame")
for as.loci
and genind2loci
; an object of class "genind"
for
loci2genind
; an object of class "SnpMatrix"
for
loci2SnpMatrix
.
Emmanuel Paradis
read.loci
, genind
,
df2genind
for converting data frames to
"genind"
, alleles2loci
x <- c("A-A", "A-a", "a-a")
as.loci(x, allele.sep = "-")
## Not run:
require(adegenet)
data(nancycats)
x <- as.loci(nancycats)
y <- loci2genind(x) # back to "genind"
identical(nancycats@tab, y@tab)
identical(nancycats@pop, y@pop)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.