Learn R Programming

poppr (version 2.1.1)

poppr.msn: Create a minimum spanning network of selected populations using a distance matrix.

Description

Create a minimum spanning network of selected populations using a distance matrix.

Usage

poppr.msn(gid, distmat, palette = topo.colors, mlg.compute = "original",
  sublist = "All", blacklist = NULL, vertex.label = "MLG",
  gscale = TRUE, glim = c(0, 0.8), gadj = 3, gweight = 1,
  wscale = TRUE, showplot = TRUE, include.ties = FALSE, threshold = 0,
  clustering.algorithm = "farthest_neighbor", ...)

Arguments

gid
distmat
a distance matrix that has been derived from your data set.
palette
a vector or function defining the color palette to be used to color the populations on the graph. It defaults to topo.colors. See examples for details.
mlg.compute
if the multilocus genotypes are set to "custom" (see mll.custom for details) in your genclone object, this will specify which mlg level to calculate the nodes from. See details.
sublist
a vector of population names or indexes that the user wishes to keep. Default to "ALL".
blacklist
a vector of population names or indexes that the user wishes to discard. Default to NULL
vertex.label
a vector of characters to label each vertex. There are two defaults: "MLG" will label the nodes with the multilocus genotype from the original data set and "inds" will label the nodes with the representative indivi
gscale
"grey scale". If this is TRUE, this will scale the color of the edges proportional to the observed distance, with the lines becoming darker for more related nodes. See greycurve for details.
glim
"grey limit". Two numbers between zero and one. They determine the upper and lower limits for the gray function. Default is 0 (black) and 0.8 (20% black). See greycurv
gadj
"grey adjust". a positive integer greater than zero that will serve as the exponent to the edge weight to scale the grey value to represent that weight. See greycurve for details.
gweight
"grey weight". an integer. If it's 1, the grey scale will be weighted to emphasize the differences between closely related nodes. If it is 2, the grey scale will be weighted to emphasize the differences between more distantly related nodes
wscale
"width scale". If this is TRUE, the edge widths will be scaled proportional to the inverse of the observed distance , with the lines becoming thicker for more related nodes.
showplot
logical. If TRUE, the graph will be plotted. If FALSE, it will simply be returned.
include.ties
logical. If TRUE, the graph will include all edges that were arbitrarily passed over in favor of another edge of equal weight. If FALSE, which is the default, one edge will be arbitrarily selected when two or more edges are tied
threshold
numeric. If greater than the default value of 0.0, this will be passed to mlg.filter prior to creating the msn.
clustering.algorithm
string. If threshold is greater than 0, this this will also be passed to mlg.filter prior to creating the msn. For both of these arguments, see mlg.f
...
any other arguments that could go into plot.igraph

Value

  • grapha minimum spanning network with nodes corresponding to MLGs within the data set. Colors of the nodes represent population membership. Width and color of the edges represent distance.
  • populationsa vector of the population names corresponding to the vertex colors
  • colorsa vector of the hexadecimal representations of the colors used in the vertex colors

Details

Each node on the graph represents a different multilocus genotype. The edges on the graph represent genetic distances that connect the multilocus genotypes. In genclone objects, it is possible to set the multilocus genotypes to a custom definition. This creates a problem for clone correction, however, as it is very possible to define custom lineages that are not monophyletic. When clone correction is performed on these definitions, information is lost from the graph. To circumvent this, The clone correction will be done via the computed multilocus genotypes, either "original" or "contracted". This is specified in the mlg.compute argument, above.

See Also

plot_poppr_msn nancycats, upgma, nj, nodelabels, tab, missingno, bruvo.msn, greycurve

Examples

Run this code
# Load the data set and calculate the distance matrix for all individuals.
data(Aeut)
A.dist <- diss.dist(Aeut)

# Graph it.
A.msn <- poppr.msn(Aeut, A.dist, gadj=15, vertex.label=NA)

# Set subpopulation structure.
Aeut.sub <- as.genclone(Aeut)
setPop(Aeut.sub) <- ~Pop/Subpop

# Plot respective to the subpopulation structure
As.msn <- poppr.msn(Aeut.sub, A.dist, gadj=15, vertex.label=NA)

# Show only the structure of the Athena population.
As.msn <- poppr.msn(Aeut.sub, A.dist, gadj=15, vertex.label=NA, sublist=1:10)

# Let's look at the structure of the microbov data set

library("igraph")
data(microbov)
micro.dist <- diss.dist(microbov, percent = TRUE)
micro.msn <- poppr.msn(microbov, micro.dist, vertex.label=NA)

# Let's plot it and show where individuals have < 15% of their genotypes 
# different.

edge_weight <- E(micro.msn$graph)$weight
edge_labels <- ifelse(edge_weight < 0.15, round(edge_weight, 3), NA)
plot.igraph(micro.msn$graph, edge.label = edge_labels, vertex.size = 2, 
edge.label.color = "red")

Run the code above in your browser using DataLab