[adegenet-forum] scatter plot labels

Maria del Carmen David maria.david.salas at gmail.com
Wed Mar 1 13:40:24 CET 2017


This must be somewhere in the email records, it's a message from Caitlin
Collins on 2014:

Hi,

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:

#############
## EXAMPLE ##
#############
set.seed(14)
# 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
par(new=TRUE)
# 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!
--------------------------------------
I don't know if it will have the same results now, I mean, in case any
upgrade in the package could have change the function of these commands.
But it worked fine when I used it back then.

On Tue, Feb 28, 2017 at 4:43 PM, Mahon, Andrew R <mahon2a at cmich.edu> wrote:

> Hi all,
> New to using adegenet. Quick question (that may or may not be simple….).
> Is there a way to use actual sample labels (i.e., what I named them) and
> plotting them in the scatter of the DAPC (i.e., when you run scatter(dapc)
> command)?
>
> Thanks for any help in advance.
>
> -andy
> --
>
>
>
> _______________________________________________
> 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/20170301/aac1eed5/attachment.html>


More information about the adegenet-forum mailing list