mlg | R Documentation |
Create counts, vectors, and matrices of multilocus genotypes.
mlg(gid, quiet = FALSE)
mlg.table(
gid,
strata = NULL,
sublist = "ALL",
exclude = NULL,
blacklist = NULL,
mlgsub = NULL,
bar = TRUE,
plot = TRUE,
total = FALSE,
color = FALSE,
background = FALSE,
quiet = FALSE
)
mlg.vector(gid, reset = FALSE)
mlg.crosspop(
gid,
strata = NULL,
sublist = "ALL",
exclude = NULL,
blacklist = NULL,
mlgsub = NULL,
indexreturn = FALSE,
df = FALSE,
quiet = FALSE
)
mlg.id(gid)
gid |
a |
quiet |
|
strata |
a formula specifying the strata at which computation is to be performed. |
sublist |
a |
exclude |
a |
blacklist |
DEPRECATED, use exclude. |
mlgsub |
a |
bar |
deprecated. Same as |
plot |
|
total |
|
color |
an option to display a single barchart for mlg.table, colored by
population (note, this becomes facetted if |
background |
an option to display the the total number of MLGs across populations per facet in the background of the plot. |
reset |
logical. For genclone objects, the MLGs are defined by the input
data, but they do not change if more or less information is added (i.e.
loci are dropped). Setting |
indexreturn |
|
df |
|
Multilocus genotypes are the unique combination of alleles across
all loci. For details of how these are calculated see vignette("mlg",
package = "poppr")
. In short, for genind and genclone objects, they are
calculated by using a rank function on strings of alleles, which is
sensitive to missing data. For genlight and snpclone objects, they are
calculated with distance methods via bitwise.dist
and
mlg.filter
, which means that these are insensitive to missing
data. Three different types of MLGs can be defined in poppr:
original - the default definition of multilocus genotypes as detailed above
contracted - these are multilocus genotypes
collapsed into multilocus lineages (mll
) with genetic
distance via mlg.filter
custom - user-defined multilocus genotypes. These are useful for information such as mycelial compatibility groups
All of the functions documented here will work on any of the MLG types defined in poppr
an integer describing the number of multilocus genotypes observed.
a matrix with columns
indicating unique multilocus genotypes and rows indicating populations.
This table can be used with the funciton diversity_stats
to calculate
the Shannon-Weaver index (H), Stoddart and Taylor's
index (aka inverse Simpson's index; G), Simpson's index (lambda), and evenness (E5).
a numeric vector naming the multilocus genotype of each individual in the dataset.
default a list
where each element contains a named integer
vector representing the number of individuals represented from each
population in that MLG
indexreturn = TRUE
a vector
of
integers defining the multilocus genotypes that have individuals crossing
populations
df = TRUE
A long form data frame with the
columns: MLG, Population, Count. Useful for graphing with ggplot2
a list of multilocus genotypes with the associated individual names per MLG.
a list
containing vectors of population names for each MLG.
The resulting matrix of mlg.table
can be used for analysis with
the vegan
package.
mlg.vector will recalculate the mlg vector for
genind
objects and will return the contents of the mlg
slot in genclone
objects. This means that MLGs will be
different for subsetted genind
objects.
Zhian N. Kamvar
diversity
diversity_stats
popsub
mll
mlg.filter
mll.custom
# Load the data set
data(Aeut)
# Investigate the number of multilocus genotypes.
amlg <- mlg(Aeut)
amlg # 119
# show the multilocus genotype vector
avec <- mlg.vector(Aeut)
avec
# Get a table
atab <- mlg.table(Aeut, color = TRUE)
atab
# See where multilocus genotypes cross populations
acrs <- mlg.crosspop(Aeut) # MLG.59: (2 inds) Athena Mt. Vernon
# See which individuals belong to each MLG
aid <- mlg.id(Aeut)
aid["59"] # individuals 159 and 57
## Not run:
# For the mlg.table, you can also choose to display the number of MLGs across
# populations in the background
mlg.table(Aeut, background = TRUE)
mlg.table(Aeut, background = TRUE, color = TRUE)
# A simple example. 10 individuals, 5 genotypes.
mat1 <- matrix(ncol=5, 25:1)
mat1 <- rbind(mat1, mat1)
mat <- matrix(nrow=10, ncol=5, paste(mat1,mat1,sep="/"))
mat.gid <- df2genind(mat, sep="/")
mlg(mat.gid)
mlg.vector(mat.gid)
mlg.table(mat.gid)
# Now for a more complicated example.
# Data set of 1903 samples of the H3N2 flu virus genotyped at 125 SNP loci.
data(H3N2)
mlg(H3N2, quiet = FALSE)
H.vec <- mlg.vector(H3N2)
# Changing the population vector to indicate the years of each epidemic.
pop(H3N2) <- other(H3N2)$x$country
H.tab <- mlg.table(H3N2, plot = FALSE, total = TRUE)
# Show which genotypes exist accross populations in the entire dataset.
res <- mlg.crosspop(H3N2, quiet = FALSE)
# Let's say we want to visualize the multilocus genotype distribution for the
# USA and Russia
mlg.table(H3N2, sublist = c("USA", "Russia"), bar=TRUE)
# An exercise in subsetting the output of mlg.table and mlg.vector.
# First, get the indices of each MLG duplicated across populations.
inds <- mlg.crosspop(H3N2, quiet = FALSE, indexreturn = TRUE)
# Since the columns of the table from mlg.table are equal to the number of
# MLGs, we can subset with just the columns.
H.sub <- H.tab[, inds]
# We can also do the same by using the mlgsub flag.
H.sub <- mlg.table(H3N2, mlgsub = inds)
# We can subset the original data set using the output of mlg.vector to
# analyze only the MLGs that are duplicated across populations.
new.H <- H3N2[H.vec %in% inds, ]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.