[adegenet-forum] customize labels within centroid

J. Richardson jrichardson4 at gmail.com
Fri Nov 23 22:58:10 CET 2012


Hi,

Thank you for your reply Thibaut. I was able to use your suggestion to
produce the 'epid' vector from H3N2.

I have a follow-up question that will likely highlight my novice abilities
with R. When you say that this vector can by "passed" to the 'pop' part of
the genind object, I think this is the step I am now having trouble doing
successfully. I have created a vector with the desired population names
listed for each individual (with then number of entries equaling the number
of individuals, as you stated). However, I am not able to append this to
the 'pop' or 'other' component of the genind object.

Calling "pop('my genind object')" displays the name of the last unique
individual in each separate population group (i.e. separated by POP in the
Genepop file). There are 326 such entries.

I created a vector with 326 rows/entries with my preferred names for the
scatterplot labels, as described in the previous email ("new labels
vector").

Attempting "pop(my genind object) <- new labels vector", I receive an error:

"Error in `pop<-`(`*tmp*`, value = list(V1 = c(12L, 12L, 12L, 12L, 12L,  :
  wrong length for population factor"

Again, any insight you can provide on passing the new population name
vector to the 'pop' part of the genind object would be greatly appreciated.
Ultimately, I am hoping to replicate the amendment of the scatterplot that
you did with the H3N2 epidemic year to change the labels within each
ellipse (i.e. page 18 in the DAPC tutorial). Thank you again.

Jonathan



On Tue, Nov 13, 2012 at 5:28 AM, Jombart, Thibaut
<t.jombart at imperial.ac.uk>wrote:

> Hello,
>
> Just to clarify, R uses no 'file' for storing objects during a session,
> everything is stored in the RAM.
>
> The rule in R is to type the name of an object to print its content. You
> can use '@' or '$' to access the content of genind objects.
> In your case, you're looking for:
> ##
> H3N2 at other$epid
> ##
>
> which is simply a vector of numeric. You can pass any vector of character,
> numeric, or factor to 'pop' to change the population information of a
> genind. The only requirement is for this vector to have a length which is
> the number of individuals in the study.
>
> Cheers
>
> Thibaut
>
>
> ________________________________________
> From: adegenet-forum-bounces at lists.r-forge.r-project.org [
> adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of J.
> Richardson [jrichardson4 at gmail.com]
> Sent: 12 November 2012 21:05
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] customize labels within centroid
>
> Hi Thibaut and Adegenet users,
>
> I have what I think is a simple/quick question, but have not been able to
> figure out on my own or via the archives. I have a dataset (Genepop
> formatted) I have been working with to conduct DAPC and create a
> scatterplot. I have a legend with each population/sampling site name listed
> (there are 13), which roughly corresponds to the population/site names
> within the Genepop file (between each "POP" line). I would like to include
> these same labels within each of the 13 centroids on the scatterplot, but
> currently when I set "clab=1" the labels are displayed "P01", "P02"...
> "P13" rather than the names of the populations/sites in the data file or
> the object created to put this names in the legend.
>
> Do you know how I can change these labels, either manually with a new
> object for the "clab=" command to use, or for "scatter" to refer to in the
> Genepop input file? I see in the H3N2 example, that the labels were amended
> to the epidemic years - I think using the "pop(H3N2) <- H3N2$other$epid"
> line. But I can't figure out how to display the H3N2 data to see how the
> "epid" item is incorporated into the file.
>
> Thank you in advance for any advice or insights.
>
> Jonathan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20121123/fbb5ed4f/attachment.html>


More information about the adegenet-forum mailing list