[adegenet-forum] scatter plot problem
Irina Ilyushkina
Irina.Ilyushkina at vuw.ac.nz
Thu Feb 26 07:02:02 CET 2015
Thank you very much!
Irina Ilyushkina
PhD Candidate
School of Biological Sciences
Victoria University of Wellington
P O Box 600
Wellington 6140
New Zealand
Mobile: 0223898085
Tel: 04 463 5233 Ext 8135
________________________________
From: Maria del Carmen David [maria.david.salas at gmail.com]
Sent: Thursday, 26 February 2015 1:43 a.m.
To: Jombart, Thibaut
Cc: Irina Ilyushkina; adegenet-forum at lists.r-forge.r-project.org
Subject: Re: [adegenet-forum] scatter plot problem
Hi, Irina.
Back in September I had a similar question. Caitlin Collins wrote some codes to label individuals. If might be what you were looking for.
Message from Caitlin Collins:
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
On Wed, Feb 25, 2015 at 5:53 AM, Jombart, Thibaut <t.jombart at imperial.ac.uk<mailto:t.jombart at imperial.ac.uk>> wrote:
Hello,
so I had understood the question, and given you the answer - use the 'pop' argument in ?scatter.dapc.
Cheers
Thibaut
________________________________
From: Irina Ilyushkina [Irina.Ilyushkina at vuw.ac.nz<mailto:Irina.Ilyushkina at vuw.ac.nz>]
Sent: 24 February 2015 22:42
To: Jombart, Thibaut
Subject: RE: scatter plot problem
I'm sorry for double posting but I'm afraid my Outlook might have failed to include the images in the e-mail.
Hi,
Thank you very much for the reply! I'm sorry I didn't explain everything clearer. Initially I have 2 populations and they form 3 clusters in DAPC, here is the scatterplot I get with command "scatter(dapc_data, posi.da="bottomleft", bg="white", pch=17:22, scree.da=FALSE, col=myCol)"
[cid:7fbe74d8-9d03-420b-a8dd-d913fb75500c]
the assignment to the clusters didn't match my population structure perfectly so I need to indicate the origin (which one of 2 initial populations) of each individual in the clusters.
I made 2 plots manually in Photoshop to represent my idea better:
[cid:859dc59a-2be3-4fa9-8b39-08413fa5b536]
or an easier to read color representation:
[cid:fddf3b1d-c165-41a8-86b0-b374fab1d57f]
Many thanks,
Irina
Irina Ilyushkina
PhD Candidate
School of Biological Sciences
Victoria University of Wellington
P O Box 600
Wellington 6140
New Zealand
Mobile: 0223898085
Tel: 04 463 5233 Ext 8135
________________________________
From: Jombart, Thibaut [t.jombart at imperial.ac.uk<mailto:t.jombart at imperial.ac.uk>]
Sent: Tuesday, 24 February 2015 12:58 a.m.
To: Irina Ilyushkina; adegenet-forum at lists.r-forge.r-project.org<mailto:adegenet-forum at lists.r-forge.r-project.org>
Subject: RE: scatter plot problem
Hi Irina,
I am not sure I understand what you are after, so sorry if I miss the point. If you want to represent a different group to the one used in the DAPC analysis on the DAPC scatterplot, use the argument 'grp'; from ?scatter.dapc:
grp: a factor defining group membership for the individuals. The
scatterplot is optimal only for the default group, i.e. the
one used in the DAPC analysis.
Cheers
Thibaut
________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org> [adegenet-forum-bounces at lists.r-forge.r-project.org<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org>] on behalf of Irina Ilyushkina [Irina.Ilyushkina at vuw.ac.nz<mailto:Irina.Ilyushkina at vuw.ac.nz>]
Sent: 23 February 2015 04:41
To: adegenet-forum at lists.r-forge.r-project.org<mailto:adegenet-forum at lists.r-forge.r-project.org>
Subject: [adegenet-forum] scatter plot problem
Hi,
I'm new to R and would be extremely grateful if someone could help me with my problem. I need to indicate (with labels, with color, etc.) the original group assignment of every individual in the DAPC inferred clusters on the scatter plot. table.value(table(pop(x), grp$grp) is showing the type of plot I'm after but it's a bit confusing when you have to consider two plots at the same time so I'm looking for a way to combine both in one plot if it is possible.
Many thanks,
Irina
_______________________________________________
adegenet-forum mailing list
adegenet-forum at lists.r-forge.r-project.org<mailto:adegenet-forum at lists.r-forge.r-project.org>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
--
Maria del Carmen David Salas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150226/4dc34ccf/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplotcolors.jpg
Type: image/jpeg
Size: 40201 bytes
Desc: Rplotcolors.jpg
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150226/4dc34ccf/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rpotlabels.jpg
Type: image/jpeg
Size: 44019 bytes
Desc: Rpotlabels.jpg
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150226/4dc34ccf/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pomap2_opt1_nooutl_scatter20.jpeg
Type: image/jpeg
Size: 163399 bytes
Desc: pomap2_opt1_nooutl_scatter20.jpeg
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150226/4dc34ccf/attachment-0001.jpeg>
More information about the adegenet-forum
mailing list