- Rのimage()関数を使ってペアワイズLDプロットを簡単に描く方法を以前書いた(こちら)。
- 今日は、ハプロタイプの01表記ファイル"hoge.txt"から描くことにする。
0 0 0 0 1 0 1 1 0 1 0 1 1
0 0 1 1 1 0 0 1 0 0 0 1 1
0 0 1 1 1 0 0 1 0 0 0 1 1
0 0 0 0 1 0 1 1 0 1 0 1 1
0 0 0 0 0 1 0 1 0 1 1 1 0
0 0 1 0 1 0 1 1 0 0 0 1 1
haplotypedata<-read.table(file="hoge.txt")
mhaplotypedata<-as.matrix(haplotypedata)
cormatrix<-cor(mhaplotypedata)
rsqmatrix<-cormatrix^2
rsqmatrix2<-rsqmatrix
rsqmatrix2[lower.tri(rsqmatrix2)] <- NA
diag(rsqmatrix2)<-NA
numbreaks<-10
breaks<-seq(from=0,to=1,length.out=numbreaks+1)
image(1:nrow(rsqmatrix),1:ncol(rsqmatrix),rsqmatrix2,col=gray((numbreaks:1)/numbreaks),breaks=breaks)