d<-dist(X) stree<-spantree(d) depths<-spandepth(stree) plot(stree,type="t",label=depths) sum(stree[[2]]) StatsMST<-function(X,perm=TRUE,tobeshuffled=NULL,Nperm=1000,dist.method="euclid"){ library(vegan) Nnode<-length(X[,1]) distM<-dist(X,method=dist.method) # calculate stats MST<-spantree(distM) if(!perm){ return(list(Nnode=Nnode,distM=distM,MST=MST,L=sum(MST[[2]]),PermL=NULL,perm=perm,Nperm=Nperm,dist.method=dist.method)) }else{ if(is.null(tobeshuffled)){ tobeshuffled<-2:length(X[1,]) } PermL<-rep(0,Nperm) for(i in 1:Nperm){ tmpdistM<-dist(ShuffleForPerm(X,tobeshuffled),method=dist.method) tmpMST<-spantree(tmpdistM) PermL[i]<-sum(tmpMST[[2]]) } return(list(Nnode=Nnode,distM=distM,MST=MST,L=sum(MST[[2]]),PermL=PermL,perm=perm,Nperm=Nperm,dist.method=dist.method)) } } sMST<-StatsMST(X) plot.MST.L<-function(mst){ ylim<-range(c(mst$L,mst$PermL)) plot(sort(mst$PermL),ylim=ylim) abline(h=mst$L) } plot.MST.L(sMST) matplot(X[,1:3],type="l") plot(as.data.frame(X[,1:3]) plot3d(X[,1:3])
遺伝学・遺伝統計学関連の姉妹ブログ『ryamadaの遺伝学・遺伝統計学メモ』
京都大学大学院医学研究科ゲノム医学センター統計遺伝学分野のWiki
講義・スライド
医学生物学と数学とプログラミングの三重学習を狙う学習ツール
駆け足で読む○○シリーズ
ぱらぱらめくるシリーズ
カシオの計算機
オンライン整数列大辞典