
mlg(pop, quiet = FALSE)mlg.table(pop, sublist = "ALL", blacklist = NULL, mlgsub = NULL,
bar = TRUE, total = FALSE, quiet = FALSE)
mlg.vector(pop)
mlg.crosspop(pop, sublist = "ALL", blacklist = NULL, mlgsub = NULL,
indexreturn = FALSE, df = FALSE, quiet = FALSE)
mlg.id(pop)
genind
or genclone
object.Logical
. If FALSE, progress of functions will be printed
to the screen.vector
of population names or indices that the user
wishes to keep. Default to "ALL".vector
of population names or indices that the user
wishes to discard. Default to NULL
.vector
of multilocus genotype indices with which to
subset mlg.table
and mlg.crosspop
. NOTE: The resulting table
from mlg.table
will only contain countries with those MLGslogical
If TRUE
, a bar graph for each population
will be displayed showing the relative abundance of each MLG within the
population.logical
If TRUE
, a row containing the sum of all
represented MLGs is appended to the matrix produced by mlg.table.logical
If TRUE
, a vector will be returned
to index the columns of mlg.table
.logical
If TRUE
, return a data frame containing the
counts of the MLGs and what countries they are in. Useful for making graphs
with ggplot
.list
where each element contains a named integer vector representing the number of individuals represented from each population in that MLG}indexreturn = TRUE
vector
of integers defining the multilocus genotypes that have individuals crossing populationsdf = TRUE
diversity
popsub
# 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, bar = FALSE)
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
# 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, bar=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, ]
Run the code above in your browser using DataLab