[adegenet-forum] Include population info in genlight object
Jombart, Thibaut
t.jombart at imperial.ac.uk
Fri Sep 16 22:56:20 CEST 2011
Hello,
yes, the problem is that you left the first column reading 913,914, etc. meaning as many copies of second allele. There is no limitation as to the ploidy of the data in genlight objects, and this is a pretty good illustration.
You need to provide the constructor (new) with a matrix of nb of alleles ONLY as first argument; for instance:
###
x<- new("genlight", SNPmerge[,-(1:3)], indNames = SNPmerge$sampleName, pop = SNPmerge$PopID, ploidy=2)
###
Hope this helps.
Cheers
Thibaut.
________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] on behalf of Linda Rutledge [lrutledge at trentu.ca]
Sent: 16 September 2011 19:31
To: adegenet-forum at r-forge.wu-wien.ac.at
Subject: [adegenet-forum] Include population info in genlight object
Hi,
I have managed to subset my 48K SNP data and retrieve both a pca and tree. However, I have now included population ID information in a column and I would like to plot individuals in the pca coloured and clustered by population. (As shown in section 5.2 of "practical-day1.1.2" of the adegenet documents). I think the issue may be with telling the genlight object where the population information is:
#show rows 1-5 and columns 1-5 of merged file of SNP genotypes and Sample Name (sampleName) and Population ID (PopID)
> SNPmerge[1:5, 1:5]
Order sampleName PopID chr1.100091560 chr1.100112448
1 1 dog89 3 0 2
2 2 dog93 3 2 1
3 3 dog858 3 0 2
4 4 dog859 3 0 1
5 5 dog860 3 0 NA
# take a subset of SNPmerge
>SNPmergeSub <- SNPmerge[913:1013, 1:20]
show rows 1-5 and columns 1-5 of subset
> SNPmergeSub[1:5, 1:5]
Order sampleName PopID chr1.100091560 chr1.100112448
913 913 MIDcla1 8 0 2
914 914 MIDcla2 8 1 0
915 915 Necla1 9 0 1
916 916 Necla2 9 0 1
917 917 WESTcla1 11 0 0
#remove column "Order" from subset
>SNPmergeSub$Order = NULL
#create genlight object from subset with individual names and population
> x<- new("genlight", SNPmergeSub, indNames = SNPmergeSub$sampleName, pop = SNPmergeSub$PopID)
> x
=== S4 class genlight ===
101 genotypes, 20 binary SNPs
Ploidy statistics (min/median/max): 913 / 963 / 1013
189 (0.09 %) missing data
@pop: individual membership for 7 populations
@loc.names: labels of the SNPs
So there is something wrong here because my ploidy should be 2.
Thanks.
_______________________________________________
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
More information about the adegenet-forum
mailing list