Description Usage Arguments Value Author(s) See Also Examples
Create a formatted data.frame or matrix from a gtypes object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## S4 method for signature 'gtypes'
as.data.frame(
x,
one.col = FALSE,
sep = "/",
ids = TRUE,
strata = TRUE,
sort.alleles = TRUE,
coded.snps = FALSE,
ref.allele = NULL,
...
)
## S4 method for signature 'gtypes'
as.matrix(
x,
one.col = FALSE,
sep = "/",
ids = TRUE,
strata = TRUE,
sort.alleles = TRUE,
...
)
|
x |
a gtypes object. |
one.col |
logical. If |
sep |
character to use to separate alleles if |
ids |
logical. include a column for individual identifiers ( |
strata |
logical. include a column for current statification
( |
sort.alleles |
logical. for non-haploid objects, should alleles be
sorted in genotypes or left in original order? (only takes affect if
|
coded.snps |
return diploid SNPs coded as 0 (reference allele homozygote), 1 (heterozygote), or 2 (alternate allele homozygote). If this is 'TRUE', the data is diploid, and all loci are biallelic, a data frame of coded genotypes will be returned with one column per locus. |
ref.allele |
an optional vector of reference alleles for each SNP.
Only used if 'coded.snps = TRUE'. If provided, it must be at least as long
as there are biallelic SNPs in |
... |
additional arguments to be passed to or from methods. |
A data.frame
or matrix
with one row per individual.
Eric Archer eric.archer@noaa.gov
df2gtypes as.matrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | data(msats.g)
# with defaults (alleles in multiple columns, with ids and stratification)
df <- as.data.frame(msats.g)
str(df)
# one column per locus
onecol.df <- as.data.frame(msats.g, one.col = TRUE)
str(onecol.df)
# just the genotypes
genotypes.df <- as.data.frame(msats.g, one.col = TRUE, ids = FALSE, strata = FALSE)
str(genotypes.df)
# as a matrix instead
genotypes.mat <- as.matrix(msats.g)
str(genotypes.mat)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.