[adegenet-forum] Include population info in genlight object

Linda Rutledge lrutledge at trentu.ca
Fri Sep 16 20:31:09 CEST 2011


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.


More information about the adegenet-forum mailing list