[adegenet-forum] DAPC a priori grouping

Virgilio Massimiliano massimiliano.virgilio at africamuseum.be
Fri Nov 21 22:18:18 CET 2014


got it:

# DAPC REGION
# change  genind at pop
region_pop=read.table("region_pop.txt",head=T)
data1585_region <- data1585
data1585_region at pop <- as.factor(region_pop[,1])
# change genind at pop.names<mailto:genind at pop.names>
region_pop.names=read.table("region_pop.names.txt",head=T)
popnames.region <- as.character(region_pop.names[,1])
names(popnames.region) <- paste('P',c(1:6), sep = '')
data1585_region at pop.names<mailto:data1585_region at pop.names> <- popnames.region

dapc_region <- dapc(data1585_region, grp=data1585 at pop, scale=FALSE, n.pca=30, n.da=5)
scatter(dapc_region, col=funky(6), clabel=.5,
        scree.pca=TRUE, ratio.pca=0.15,
        scree.da=TRUE, ratio.da=0.15)
mtext("dapc region 1585", side = 3, line = 3)

many thanks to Fred ;-)

M.

__________________________________
 Massimiliano Virgilio, PhD

Royal Museum for Central Africa
Leuvensesteenweg 13, B-3080 Tervuren, Belgium, +32 (0) 27695366

massimiliano.virgilio at africamuseum.be<mailto:massimiliano.virgilio at africamuseum.be>

http://www.africamuseum.be/home/contact/staff/VIRGILIO_Massimiliano/





On 18 Nov 2014, at 15:03, Virgilio Massimiliano <massimiliano.virgilio at africamuseum.be<mailto:massimiliano.virgilio at africamuseum.be>> wrote:

Dear Thibaud,
I’m trying to group populations of a genind object according to region and country of origin.
The idea was to perform DAPCs and maximise differences between individuals from different regions/countries.

I first added the region/country info to the @other slot of the genind object and then tried to perform DAPC:

dapc_region <- dapc(data, grp=data at other$region, scale=FALSE, n.pca=20, n.da=5)

yet, all I could get was a DAPC using populations as defined by the @pop slot,

so I tried and modify the @pop slot

region=read.table(“region.txt",head=T)
data841 at pop<-region

but I got:

Error in checkAtAssignment("genind", "pop", "data.frame") :
 assignment of an object of class "data.frame" is not valid for @'pop' in an object of class "genind"; is(value, "factorOrNULL") is not TRUE

Is this just something I cannot do on a genind object?
any suggestion on how to easily change the apriori grouping of individuals (@pop) and perform DAPC

many thanks in advance and all the best

Massi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20141121/2906a8a3/attachment.html>


More information about the adegenet-forum mailing list