[adegenet-forum] how to label individuals in scatter(dapc)

Caitlin Collins caitiecollins at gmail.com
Thu Sep 18 17:49:10 CEST 2014


If you think the individuals you are plotting are spaced far enough that
you will be able to read labels at the individual level, one way to do it
is to use s.label.
Here is an example of how to use s.label to overlap labels to a scatterplot
of DAPC:

# generate a simulated dataset with 3 populations
simpop <- glSim(100, 500, 5, k=3, sort.pop=TRUE)
# isolate the SNPs and the population factor
snps <- as.matrix(simpop)
phen <- simpop at other$ancestral.pops
# run a dapc
dapc1 <- dapc(snps, phen, n.pca=20, n.da=4)
# create the scatter plot as before
scatter(dapc1, cstar=0, cex=5, label=NULL)
# change graphical parameter to subsequently overlay the labels without
drawing a new plot
# make a data frame of the dapc coordinates used in scatter
df <- data.frame(x = dapc1$ind.coord[,1], y = dapc1$ind.coord[,2])
# identify/ create a vector of names for the individuals in your plot
noms <- paste("ind", c(1:100), sep=".")
# use the text function to add labels to the positions given by the
coordinates you used in plot
s.label(dfxy = df, xax=1, yax=2, label=noms,
        clabel=0.7, # change the size of the labels
        boxes=TRUE, # if points are spaced wide enough, can use TRUE to add
boxes around the labels
        grid=FALSE, addaxes=FALSE) # do not draw lines or axes in addition
to the labels

The comments in the example above hopefully should give you all of the
relevant information, so please give them a read and then feel free to let
me know if you have any questions. You will almost certainly want to play
around with the arguments clabel and boxes in the s.label function to get
the labels to be readable for your case.
I hope that helps!


On Thu, Sep 18, 2014 at 3:08 PM, Maria del Carmen David <
maria.david.salas at gmail.com> wrote:

> Hello. I can't find the way of labeling individuals in my dapc graphic. I
> know that for those who work with huge amount of individuals it isn't
> necessary but i have a bit less than 150 and i want to see how they plot. I
> have used assignplot to get a better idea of the group assignments but it
> would be extremely helpful to be able to label my samples. Thanks in
> advance.
> Maria del Carmen
> _______________________________________________
> adegenet-forum mailing list
> adegenet-forum at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140918/4dc756dc/attachment.html>

More information about the adegenet-forum mailing list