做矩阵的相关性
A.txt
A1 10.5318295 10.99222177 11.03562467 10.96557789 10.83035429
A2 6.739434821 7.116196513 6.580855876 6.373403461 6.171394699
A3 8.211470461 7.408179667 8.609446009 7.703020111 8.136612015
A4 6.390161061 5.518319096 6.389672739 5.153194736 5.190002849
A5 5.989180707 6.610817226 6.836854 6.720763378 6.84360378
A6 6.62607316 4.961029923 5.593639891 4.778684209 3.560703229
A7 10.46189081 10.49176212 10.63973095 10.18315138 10.40909579
A8 7.660263292 7.176737249 7.399346976 7.271078071 7.122749117
B.txt
B1 7.00152338 6.765920244 6.384241842 6.404021071 6.418831326
B2 12.57482526 10.03414179 9.938182489 9.975493125 11.26199792
B3 10.1657919 7.251868182 7.835566198 6.881422723 7.937006015
B4 7.349632255 7.291975344 6.726172279 6.63356767 6.615896458
B5 5.235297404 5.179921865 4.909489913 5.188679949 4.95199261
B6 8.174743212 7.924985617 10.24818328 8.670346222 9.44041227
B7 5.925499775 5.473856318 5.892044495 5.446674815 5.728264265
B8 12.02753795 11.46556743 12.09162322 13.00628889 11.70371773
B9 13.84422812 12.64773122 11.64849474 12.88361011 12.06310001
R_code
a <- read.table("A")
b <- read.table("B")
rownames(a) <- a[,1]
rownames(b) <- b[,1]
a <-a[,-1]
data_a <- t(a)
b <- b[,-1]
data_b <- t(b)
cor(data_a[1:5,1],data_b[1:5,1], method = c("pearson"))
z=matrix(nrow=8,ncol=9)
for(i in 1:8){
for(j in 1:9){
z[i,j]=cor(data_a[1:5,i],data_b[1:5,j])
}
}
print(z[1:3,1:3])
write.table(z,file="cor_data.txt")