从一个hclust
对象中,如何仅提取选定的观测值(to_plot
如下)并从这些选定的观测值中绘制一个树状图?我想绘制为树状图的这个观察子集与hclust
对象的树结构不对应,因此我无法从树状图中提取分支。
注意。我不希望使用所选观测值的子集来聚类或计算距离矩阵
数据
1/hclust
对象
structure(list(merge = structure(c(-31L, -62L, -46L, -37L, -55L,
-47L, -75L, -57L, -6L, -2L, -45L, -99L, -51L, -12L, -30L, -4L,
3L, -53L, -61L, -27L, -56L, -83L, -38L, -101L, -69L, -11L, -14L,
-21L, -34L, -48L, -82L, -92L, -15L, -7L, -35L, -65L, -105L, -52L,
-40L, -64L, -23L, -94L, -98L, -1L, -25L, -8L, 8L, -41L, -3L,
-33L, -108L, 23L, -58L, -20L, -5L, -93L, 30L, -68L, -49L, -28L,
-17L, 9L, -32L, 35L, -95L, -67L, 26L, -107L, 17L, -19L, -74L,
-63L, 37L, 20L, -84L, 50L, -10L, -13L, 49L, 34L, 39L, 60L, -16L,
63L, 44L, 29L, 10L, -24L, 75L, 73L, 47L, 61L, 57L, 18L, 66L,
43L, 80L, 83L, -78L, -71L, 90L, 93L, 84L, 94L, 102L, 98L, 100L,
87L, 106L, 108L, -97L, 1L, -100L, -43L, -59L, -106L, 4L, -90L,
5L, 2L, -87L, -103L, -86L, -54L, -89L, -42L, 11L, 13L, 12L, -77L,
7L, 14L, 6L, -110L, 22L, -60L, -44L, -91L, -111L, -102L, -88L,
-104L, -50L, -22L, -36L, -79L, 28L, 24L, -66L, 15L, -29L, 25L,
32L, -109L, -39L, 45L, 42L, -96L, 16L, 33L, 19L, 40L, 27L, 31L,
-9L, 41L, 46L, -80L, -81L, -70L, -26L, 21L, -73L, 48L, 38L, 36L,
53L, 56L, 51L, -72L, -85L, -76L, 52L, 58L, 71L, 59L, 64L, -18L,
68L, 54L, 55L, 65L, 70L, 79L, 72L, 74L, 69L, 78L, 77L, 76L, 62L,
81L, 82L, 67L, 86L, 85L, 95L, 89L, 92L, 88L, 91L, 97L, 96L, 99L,
103L, 104L, 105L, 101L, 107L, 109L), .Dim = c(110L, 2L)), height = c(0,
0.188350217744365, 0.247401000321179, 0.249231910045009, 0.261866742195707,
0.377720124194474, 0.378461142310176, 0.527418629683044, 0.636480697844057,
0.70489556723743, 0.799857388088743, 0.895267189098051, 0.940604516439695,
1, 1, 1.25645841742159, 1.47637080579504, 1.49661353166068, 1.60280854934758,
1.64538982117314, 1.65011076915935, 1.66666666666667, 1.8661900064933,
1.91530600787293, 1.95979930296005, 2, 2, 2, 2, 2, 2, 2, 2.06532735656427,
2.32083831336158, 2.44558763136158, 2.48004395957454, 2.65074432837975,
2.69489799737569, 2.71536352494182, 2.75337988132381, 2.87695888696678,
2.89093184314013, 2.91669905927746, 3, 3.03504556878056, 3.42442760079317,
3.50924315636259, 3.54456009196554, 3.58118052752614, 3.80716728885077,
4.26149878117642, 4.63502500606874, 4.66666666666667, 4.66666666666667,
4.76912295317528, 4.90702353976517, 4.92512811564295, 5, 5.15887380396718,
5.20227981903921, 5.39890417564938, 5.71781232947912, 5.94961450567626,
6.17569787723772, 6.21000141305934, 6.47150288200403, 6.48552894195153,
6.61209720286382, 7.27379923250834, 7.65301130607984, 7.74920607244712,
7.8800745368487, 8.17570945188961, 8.75305138718179, 8.87870428752716,
9.36365055557565, 9.68439736325147, 10, 10.121604958431, 10.2845151775143,
10.7517404855684, 10.8165382868783, 11.4489962313067, 11.5939995243571,
12.8179231278111, 12.3055509866599, 14.1589468158871, 14.6988252554622,
14.7792803434488, 15.276874084329, 16.0150635281041, 17.9467649484583,
21.2687065983256, 21.3844895922187, 24.196270007066, 25.3163200486723,
34.1772731084418, 37.4454933955768, 42.6291683810462, 45.1916356921658,
52.531016897072, 55.6590891226214, 61.0699226448619, 73.7706208334886,
98.5310119994231, 148.608243702477, 150.474954574704, 187.419419688973,
241.610436881262, 487.90491231433), order = c(2L, 62L, 31L, 97L,
46L, 100L, 45L, 87L, 108L, 61L, 99L, 103L, 105L, 21L, 91L, 38L,
47L, 106L, 64L, 30L, 89L, 33L, 15L, 50L, 49L, 81L, 57L, 90L,
94L, 69L, 83L, 12L, 54L, 6L, 55L, 59L, 56L, 75L, 37L, 43L, 16L,
19L, 72L, 84L, 74L, 85L, 10L, 35L, 36L, 41L, 96L, 53L, 51L, 86L,
11L, 60L, 58L, 14L, 44L, 78L, 17L, 26L, 40L, 66L, 5L, 9L, 71L,
24L, 13L, 18L, 48L, 102L, 8L, 25L, 39L, 28L, 70L, 95L, 52L, 101L,
110L, 7L, 22L, 20L, 82L, 88L, 67L, 65L, 79L, 34L, 111L, 27L,
77L, 68L, 80L, 32L, 73L, 3L, 4L, 42L, 107L, 93L, 23L, 29L, 98L,
92L, 104L, 1L, 109L, 63L, 76L), labels = c("DX_100203", "DX_100208",
"DX_30528", "DX_100159", "DX_100211", "DX_100215", "DX_100246", "DX_100253",
"DX_100271", "DX_100212", "DX_100035", "DX_100164", "DX_100249", "DX_100036",
"DX_100165", "DX_100221", "DX_100254", "DX_100262", "DX_100274", "DX_100046",
"DX_100171", "DX_100230", "DX_100255", "DX_100275", "DX_100180", "DX_100269",
"DX_100278", "DX_100161", "DX_100229", "DX_100238", "DX_100093", "DX_100191",
"DX_100241", "DX_100237", "DX_100268", "DX_30515", "DX_90862", "DX_30529",
"DX_100073", "DX_90264", "DX_90221", "DX_30550", "DX_90885", "DX_100028",
"DX_100049", "DX_90257", "DX_90215", "DX_30527", "DX_30526", "DX_90892",
"DX_100051", "DX_90333", "DX_90286", "DX_90217", "DX_90252", "DX_90232",
"DX_30573", "DX_100214", "DX_90769", "DX_90907", "DX_100037", "DX_100054",
"DX_30568", "DX_90230", "DX_90280", "DX_90779", "DX_90959", "DX_100187",
"DX_100081", "DX_90310", "DX_90782", "DX_100023", "DX_90994", "DX_100042",
"DX_90304", "DX_100152", "DX_90272", "DX_90861", "DX_100043", "DX_100068",
"DX_30571", "DX_100085", "DX_90312", "DX_30590", "DX_90413", "DX_30561",
"DX_30548", "DX_90296", "DX_30558", "DX_90243", "DX_90293", "DX_90365",
"DX_30584", "DX_90274", "DX_90332", "DX_30583", "DX_30575", "DX_30523",
"DX_30578", "DX_90377", "DX_90297", "DX_30593", "DX_30555", "DX_30549",
"DX_90292", "DX_30565", "DX_30512", "DX_90285", "DX_90231", "DX_90209",
"DX_30570"), method = "ward", call = hclust(d = distance, method = method.hclust),
dist.method = "maximum"), .Names = c("merge", "height", "order",
"labels", "method", "call", "dist.method"), class = "hclust")
2/要提取的观察子集以绘制为树状图
to_plot <- c("DX_90264", "DX_90221", "DX_30550", "DX_90885", "DX_100028", "DX_100159",
"DX_100049", "DX_90257", "DX_90215", "DX_30527", "DX_30526", "DX_90892",
"DX_100051", "DX_90333", "DX_90286", "DX_90217", "DX_90252", "DX_90232",
"DX_30573", "DX_100214", "DX_90769", "DX_90907", "DX_100037", "DX_100054", "DX_30565")