我想制作一张图表,在其中比较病毒丰度和代谢读数,并且已经为每次比较计算了皮尔逊相关系数。我想根据Pearson的相关系数对数据进行分层聚类。我试图通过以下方式做到这一点:
##r contains a matrix of correlation coefficients
dissimilarity <- 1-abs(r)
dist = as.dist(dissimilarity)
Warning message:
In as.dist.default(dissimilarity) : non-square matrix
plot(hclust(dist))
Error in hclust(dist) : dissimilarities of improper length
但是,由于轴不同,因此会产生错误。 您可以找到相关系数here。这有可能吗?预先感谢!
*编辑: 1.我的数据分为两页,分别位于标题和str下方:
病毒:
'data.frame': 6 obs. of 81 variables:
$ X0305phi8.36.like.viruses : num 0.02074 0 0.07831 0 0.00977 ...
$ Bcep22.like.viruses : num 0.12443 1.66016 0.23493 0.11682 0.00977 ...
$ BcepMu.like.viruses : num 0.0104 0 0 0 0 ...
$ FelixO1.like.viruses : num 0.0207 0 0.3915 0 0 ...
$ HAP1.like.viruses : num 0.03111 0 0 0.02336 0.00977 ...
$ Hp1.like.viruses : num 0 0.0977 0 0 0 ...
$ JS98.like.viruses : num 0 0 0 0.0234 0 ...
$ K.like.viruses : num 0 0 0 0 0 ...
X0305phi8.36.like.viruses Bcep22.like.viruses BcepMu.like.viruses
1 0.020738283 0.124429697 0.01036914
2 0.000000000 1.660156250 0.00000000
3 0.078308536 0.234925607 0.00000000
4 0.000000000 0.116822430 0.00000000
5 0.009774216 0.009774216 0.00000000
6 0.000000000 0.010016026 0.00000000
FelixO1.like.viruses HAP1.like.viruses Hp1.like.viruses JS98.like.viruses
1 0.02073828 0.031107424 0.00000000 0.00000000
2 0.00000000 0.000000000 0.09765625 0.00000000
3 0.39154268 0.000000000 0.00000000 0.00000000
4 0.00000000 0.023364486 0.00000000 0.02336449
5 0.00000000 0.009774216 0.00000000 0.00000000
6 0.00000000 0.040064103 0.00000000 0.00000000
K.like.viruses P1.like.viruses P100.like.viruses P2.like.viruses PAKP1.like.viruses
1 0.00000000 0.01036914 0.04147657 0.05184571 0.00000000
2 0.00000000 0.00000000 0.00000000 0.39062500 0.00000000
3 0.00000000 0.07830854 0.00000000 1.33124511 0.00000000
4 0.00000000 0.00000000 0.00000000 0.08177570 0.00000000
5 0.00000000 0.00000000 0.00000000 0.02932265 0.00000000
6 0.01001603 0.00000000 0.02003205 0.01001603 0.01001603
PB1.like.viruses phiCD119.like.viruses phiKZ.like.viruses phiPLPE.like.viruses
1 0 2.2397346 0.01036914 0.06221485
2 0 16.7968750 0.00000000 0.09765625
3 0 12.5293657 0.39154268 0.15661707
4 0 0.4556075 0.01168224 0.00000000
5 0 0.1759359 0.01954843 0.00000000
6 0 0.7712340 0.01001603 0.00000000
RB49.like rV5.like.viruses Schizot4.like.viruses Secunda5.like.viruses
1 0.00000000 0.000000000 0.00000000 0.02073828
2 0.09765625 0.097656250 0.00000000 0.19531250
3 0.07830854 0.000000000 0.00000000 0.00000000
4 0.00000000 0.000000000 0.00000000 0.00000000
5 0.00000000 0.009774216 0.00000000 0.00000000
6 0.00000000 0.010016026 0.01001603 0.00000000
SfV.like.viruses SP18.like.viruses SPO1.like.viruses T4.like.viruses
1 0 0.0000000 0.6325176 1.3583575
2 0 0.3906250 0.1953125 6.9335938
3 0 0.4698512 1.4878622 6.1080658
4 0 0.5490654 0.7827103 0.3037383
5 0 0.3616460 0.3518718 0.7037435
6 0 0.2203526 1.3922276 0.2604167
Twort.like.viruses unclassified..derived.from.Myoviridae.
1 0.134798839 0.041476566
2 0.195312500 0.000000000
3 2.114330462 0.000000000
4 0.023364486 0.011682243
5 0.009774216 0.009774216
6 0.020032051 0.030048077
Unclassified..derived.from.Spounavirinae. VHML.like.viruses Vi1.like.viruses
1 0.02073828 0.02073828 0
2 0.00000000 0.00000000 0
3 0.15661707 0.00000000 0
4 0.00000000 0.00000000 0
5 0.04887108 0.00000000 0
6 0.03004808 0.00000000 0
Bcep781.like.viruses Bpp.1.like.viruses Epsilon15.like.viruses F116.like.viruses
1 0.00000000 1.1198673 0 0.00000000
2 0.00000000 3.2226562 0 0.00000000
3 2.50587314 4.9334377 0 0.00000000
4 0.00000000 0.7593458 0 0.00000000
5 0.06841951 0.0000000 0 0.01954843
6 0.00000000 1.1418269 0 0.00000000
KP34.like.viruses LUZ24.like.viruses N4.like.viruses P22.like.viruses
1 0.020738283 0.03110742 0 0.01036914
2 0.097656250 0.00000000 0 0.00000000
3 0.000000000 0.00000000 0 0.00000000
4 0.000000000 0.00000000 0 0.01168224
5 0.009774216 0.01954843 0 0.00000000
6 0.010016026 0.00000000 0 0.00000000
P68.like.viruses Phi29.like.viruses phiKMV.like.viruses SP6.like.viruses
1 0.4562422 0.18664455 0 0.03110742
2 0.0000000 0.00000000 0 0.00000000
3 0.1566171 1.09631950 0 0.00000000
4 0.6892523 0.01168224 0 0.01168224
5 0.7232920 0.00000000 0 0.02932265
6 0.8613782 0.22035256 0 0.00000000
T7.like.viruses unclassified..derived.from.Podoviridae.
1 0.14516798 0.01036914
2 0.00000000 0.19531250
3 0.00000000 0.15661707
4 0.03504673 0.02336449
5 0.08796794 0.04887108
6 0.10016026 0.15024039
unclassified..derived.from.Autogrphivirinae. unclassified..derived.from.Picovirinae.
1 0.01036914 0
2 0.00000000 0
3 0.00000000 0
4 0.00000000 0
5 0.00000000 0
6 0.00000000 0
X1706.like.viruses X3a.like.viruses X77.like.viruses X936.like.viruses
1 1.0161759 0.00000000 0.00000000 0.31107424
2 9.0820312 0.00000000 0.09765625 0.29296875
3 9.9451840 0.39154268 0.07830854 0.07830854
4 1.2149533 0.00000000 0.00000000 0.26869159
5 0.3323233 0.01954843 0.00000000 0.30300068
6 0.8012821 0.03004808 0.00000000 0.68108974
c2.like.viruses Che8.like.viruses CJW1.like.viruses D3.like.viruses
1 0.05184571 0.42513480 0 0.01036914
2 0.00000000 0.09765625 0 0.00000000
3 0.15661707 0.39154268 0 0.00000000
4 0.01168224 0.01168224 0 0.00000000
5 0.04887108 0.03909686 0 0.00000000
6 0.06009615 0.00000000 0 0.00000000
HK578.like.viruses IEBH.like.viruses Jersey.like.viruses L5.like.viruses
1 0 0.7673165 0.00000000 0.010369141
2 0 3.2226562 0.09765625 0.292968750
3 0 3.9154268 0.00000000 0.391542678
4 0 1.1565421 0.00000000 0.268691589
5 0 0.8601310 0.00000000 0.009774216
6 0 1.0116186 0.00000000 0.000000000
Lambda.like.viruses Lebron.like.viruses Omega.like.viruses P23.45.like.viruses
1 0.4769805 0 0.00000000 0
2 0.4882812 0 0.29296875 0
3 2.7407987 0 0.00000000 0
4 0.0817757 0 0.00000000 0
5 0.1075164 0 0.00000000 0
6 0.4306891 0 0.01001603 0
P335.like.viruses PhiC31.like.viruses phiE125.like.viruses phiETA.like.viruses
1 27.467856 0 0.21775197 2.250104
2 4.296875 0 1.56250000 1.855469
3 2.505873 0 1.80109632 1.566171
4 25.747664 0 0.18691589 2.207944
5 30.016616 0 0.16616167 4.613430
6 19.741587 0 0.09014423 3.175080
phiFL.like.viruses phiLJ1.like.viruses PsiM1.like.viruses Sfi11.like.viruses
1 15.325591 0.010369141 0 0.04147657
2 3.417969 0.292968750 0 0.00000000
3 6.186374 0.078308536 0 0.00000000
4 17.266355 0.058411215 0 0.07009346
5 14.524484 0.009774216 0 0.05864529
6 17.387821 0.010016026 0 0.10016026
Sfi21.like.viruses SPbeta.like.viruses T5.like.viruses TLS.like.viruses
1 0.06221485 0.6532559 0.03110742 0
2 0.39062500 1.1718750 0.00000000 0
3 0.62646828 2.7407987 0.00000000 0
4 0.09345794 0.3621495 0.00000000 0
5 0.04887108 0.2834523 0.00000000 0
6 0.13020833 0.3205128 0.00000000 0
TM4.like.viruses TP21.like.viruses unclassified..derived.from.Siphoviridae.
1 0.00000000 1.8871837 41.45583
2 0.00000000 0.3906250 30.37109
3 0.00000000 0.3132341 21.84808
4 0.00000000 0.9579439 46.00467
5 0.00000000 2.0916821 43.41707
6 0.01001603 1.9631410 48.29728
Wbeta.like.viruses Xp10.like.viruses Yua.like.viruses Cvm10.like.viruses
1 0.10369141 0 0 0
2 0.00000000 0 0 0
3 0.00000000 0 0 0
4 0.04672897 0 0 0
5 0.04887108 0 0 0
6 0.05008013 0 0 0
unclassified..derived.from.Caudovirales.
1 0.54956450
2 11.62109375
3 9.78856695
4 0.04672897
5 0.24435539
6 0.36057692
Metab:
'data.frame': 6 obs. of 5 variables:
$ Day.EE : num 0.366 0.334 0.348 0.425 0.454 ...
$ Night.RER : num 0.941 0.884 0.948 0.771 0.849 ...
$ Visceral.Fat : num 0.0283 0.0356 0.0256 0.0726 0.0928 ...
$ Percent.Weight.Change: num 21.4 20 20.3 40.5 42.2 ...
$ HOMA.IR : num 8.43 7.91 4.64 22.96 33.25 ...
head(D2)
Day.EE Night.RER Visceral.Fat Percent.Weight.Change HOMA.IR
1 0.3659900 0.9409150 0.02830189 21.43435 8.428624
2 0.3338380 0.8838706 0.03564390 20.04065 7.906044
3 0.3477030 0.9478585 0.02556391 20.30075 4.642277
4 0.4249553 0.7709375 0.07257911 40.48837 22.961244
5 0.4544125 0.8494122 0.09284971 42.22649 33.246229
6 0.4864046 0.8814634 0.08163690 45.03449 35.661550
>
这是我的系数之首:
Day.EE Night.RER Visceral.Fat Percent.Weight.Change
X0305phi8.36.like.viruses -0.4744741 0.64074328 -0.5746224 -0.5330374
Bcep22.like.viruses -0.6353393 0.09046829 -0.4410990 -0.5588352
BcepMu.like.viruses -0.2857413 0.46571242 -0.4591139 -0.4096812
FelixO1.like.viruses -0.4492620 0.54772835 -0.5335849 -0.4815672
HAP1.like.viruses 0.6324260 -0.14644627 0.3638282 0.5263814
Hp1.like.viruses -0.5393393 0.03610703 -0.3378353 -0.4659172
HOMA.IR
X0305phi8.36.like.viruses -0.5648587
Bcep22.like.viruses -0.4982786
BcepMu.like.viruses -0.3714296
FelixO1.like.viruses -0.5315103
HAP1.like.viruses 0.5154564
Hp1.like.viruses -0.3901310