#start R
thin=read.table("hapmap3_thin_pruned.mdist",F)
chr21=read.table("hapmap3_chr21_pruned.mdist",F)
all=read.table("hapmap3_pruned.mdist",F)
#install.packages("vegan")
install.packages("vegan", repos="http://r-forge.r-project.org/")
library(vegan)
#multidimensional scaling
thin_coord=cmdscale(thin,2)
chr21_coord=cmdscale(chr21,2)
all_coord=cmdscale(all,2)
Warning message: In install.packages("vegan", repos = "http://r-forge.r-project.org/"): installation of package ‘vegan’ had non-zero exit status
The downloaded source packages are in ‘/private/var/folders/5s/hfqw0tvn5k70swhg64fydljr0000gn/T/RtmphsvF6Y/downloaded_packages’
Updating HTML index of packages in '.Library' Making 'packages.html' ... done
Error in library(vegan): there is no package called ‘vegan’
#plot
plot(thin_coord[1:165,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="red")
points(thin_coord[166:250,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="blue",type="p")
points(thin_coord[251:317,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),type="p")
plot(chr21_coord[1:165,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="red")
points(chr21_coord[166:250,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="blue",type="p")
points(chr21_coord[251:317,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),type="p")
plot(all_coord[1:165,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="red")
points(all_coord[166:250,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),col="blue",type="p")
points(all_coord[251:317,],xlim=c(-0.2,0.2),ylim=c(-0.2,0.2),type="p")
#grouping as a predictor:
pred=cbind(c(rep(1,165),rep(0,(416-165))), c(rep(0,165),rep(1,84),rep(0,(416-249))) ,c(rep(0,249),rep(1,(416-249))))
#GAMOVA
adonis(thin~pred)
adonis(chr21~pred)
adonis(all~pred)
Error in eval(expr, envir, enclos): could not find function "adonis"
Error in eval(expr, envir, enclos): could not find function "adonis"
Error in eval(expr, envir, enclos): could not find function "adonis"
#random grouping
p=rep(c(0,1),208)
adonis(all~p)
#why do we get lots more variation explained?
Error in eval(expr, envir, enclos): could not find function "adonis"