?dapc
for
details about this method. DAPC graphics are detailed in the DAPC tutorial
accessible using vignette("adegenet-dapc")
. These functions all require an object of class dapc
(the ".dapc" can be ommitted when calling the functions):
- scatter.dapc
: produces scatterplots of principal components (or
'discriminant functions'), with a screeplot of eigenvalues as inset.
- assignplot
: plot showing the probabilities of assignment of
individuals to the different clusters.
- compoplot
: barplot showing the probabilities of assignment of
individuals to the different clusters.
## S3 method for class 'dapc':
scatter(x, xax=1, yax=2, grp=x$grp, col=seasun(length(levels(grp))),
pch=20, bg="white", solid=.7, scree.da=TRUE,
scree.pca=FALSE, posi.da="bottomright",
posi.pca="bottomleft", bg.inset="white", ratio.da=.25,
ratio.pca=.25, inset.da=0.02, inset.pca=0.02,
inset.solid=.5, onedim.filled=TRUE, mstree=FALSE, lwd=1,
lty=1, segcol="black", legend=FALSE, posi.leg="topright",
cleg=1, txt.leg=levels(grp), cstar = 1, cellipse = 1.5,
axesell = FALSE, label = levels(grp), clabel = 1, xlim =
NULL, ylim = NULL, grid = FALSE, addaxes = TRUE, origin =
c(0,0), include.origin = TRUE, sub = "", csub = 1, possub =
"bottomleft", cgrid = 1, pixmap = NULL, contour = NULL, area
= NULL, label.inds = NULL, ...)assignplot(x, only.grp=NULL, subset=NULL, new.pred=NULL, cex.lab=.75,pch=3)
compoplot(x, only.grp=NULL, subset=NULL, new.pred=NULL, col=NULL, lab=NULL,
legend=TRUE, txt.leg=NULL, ncol=4, posi=NULL, cleg=.8, bg=transp("white"), ...)
dapc
object.integers
specifying which principal components of DAPC
should be shown in x and y axes.numeric
indicating the type of point to be used to indicate
the prior group of individuals (see points
documentation for
more details); one value is expected for each group; recycled i?add.scatter
for more details.?add.scatter
for more details.locator
can be used).s.class
; see ?s.class
for more informationscharacter
vector indicating which groups should be
displayed. Values should match values of x$grp
. If NULL
, all
results are displayedinteger
or logical
vector indicating which
individuals should be displayed. If NULL
, all
results are displayedpredict
method for
dapc
objects; if provided, the individuals with unknown groups are added
at the bottom of the plot. To visualize these individuals only, specify
only.grp="
numeric
indicating the size of labels.x$tab
are used.x$grp
are
used.?legend
.orditorp
function. This will label individual points
witout overlapping. Arguments x
and display
are hardcoded and
shouldscatter
, arguments passed to points
; for compoplot
,
arguments passed to barplot
.dapc
for more information about the method.dapc
: implements the DAPC. - find.clusters
: to identify clusters without prior.
- dapcIllus
: a set of simulated data illustrating the DAPC
data(H3N2)
dapc1 <- dapc(H3N2, pop=H3N2$other$epid, n.pca=30,n.da=6)
## defautl plot ##
scatter(dapc1)
## label individuals at the periphery
# air = 2 is a measure of how much space each label needs
# pch = NA suppresses plotting of points
scatter(dapc1, label.inds = list(air = 2, pch = NA))
## showing different scatter options ##
## remove internal segments and ellipses, different pch, add MStree
scatter(dapc1, pch=18:23, cstar=0, mstree=TRUE, lwd=2, lty=2, posi.da="topleft")
## only ellipse, custom labels, use insets
scatter(dapc1, cell=2, pch="", cstar=0, posi.pca="topleft", posi.da="topleft", scree.pca=TRUE,
inset.pca=c(.01,.3), label=paste("year\n",2001:2006), axesel=FALSE, col=terrain.colors(10))
## without ellipses, use legend for groups
scatter(dapc1, cell=0, cstar=0, scree.da=FALSE, clab=0, cex=3,
solid=.4, bg="white", leg=TRUE, posi.leg="topleft")
## only one axis
scatter(dapc1,1,1,scree.da=FALSE, legend=TRUE, solid=.4,bg="white")
## example using genlight objects ##
## simulate data
x <- glSim(50,4e3-50, 50, ploidy=2)
x
plot(x)
## perform DAPC
dapc2 <- dapc(x, n.pca=10, n.da=1)
dapc2
## plot results
scatter(dapc2, scree.da=FALSE, leg=TRUE, txt.leg=paste("group",
c('A','B')), col=c("red","blue"))
## SNP contributions
loadingplot(dapc2$var.contr)
loadingplot(tail(dapc2$var.contr, 100), main="Loading plot - last 100 SNPs")
## assignplot / compoplot ##
assignplot(dapc1, only.grp=2006)
data(microbov)
dapc3 <- dapc(microbov, n.pca=20, n.da=15)
compoplot(dapc3, lab="")
Run the code above in your browser using DataLab