我的数据方式比以下大得多
df<- structure(c(14.12087951, 14.99460661, 33.46234987, 10.17615856,
5.274590779, 2262.260928, 30.95475607, 489.3857185, 100.2231956,
1.927758832, 12063.47923, 12.40706075, 2010.075103, 1161.375364,
789.7376463, 3118.915801, 202.9969196, 5.098794774, 913.8294948,
25.66624202, 254.0262357, 351.1804779, 1.164233553, 1.725950597,
1.73866603, -0.182861618, 1.073288641, 2.355917497, 1.903814342,
2.106296918, 1.641698736, 1.00452836, 1.530285115, 1.224115304,
1.549014357, 1.571649698, 1.336788511, 1.566214154, 1.287767608,
1.43739379, 1.107868132, 1.446075949, 1.053322707, 1.084792083
), .Dim = c(22L, 2L), .Dimnames = list(c("A", "AAA", "AAAA",
"AAAAA", "AAAAAA", "AAAAAAA", "B", "BB", "BBB", "BBBB", "BBBBB",
"F", "FFF", "FFFFF", "FFFFFF", "FFFFFFF", "FFFFFFFF", "E62534",
"GDTDFS", "AZE", "ZIEY", "SIS"), c("value1", "value2")))
当我使用heatmap时,我试图只显示特定的标签。所以我这样做
Labelst <- c("BBBBB", "AAAAAAA", "SIS","ZIEY")
heatmap.2(df, labRow = Labelst)
我不使用labRow,那么标签的顺序是不同的。例如,将以下内容与上述进行比较
heatmap.2(df)
现在,最大的问题是如何避免重叠?当我有1000行时,当我尝试只显示特定的行时,它们重叠。有人可以告诉我如何用闪光灯显示特定的行标记吗?或者彼此相距很远?我不想改变字体并使其变小
请务必阅读heatmap.2
的帮助页面,因为它非常详细。虽然没有特别说明,但labRow
采用与data.frame相同长度的向量。帮助陈述these default to rownames(x)
。
因此,只需用空字符串替换任何不需要的标签。
have <- rownames(df)
want <- c("BBBBB", "AAAAAAA", "SIS","ZIEY")
have[!(have %in% want)] <- ""
heatmap.2(df, labRow = have)
我错过了你问题的后半部分。 heatmap.2可用于修改/更改行/列名的选项如下:
# Row/Column Labeling
margins = c(5, 5),
ColSideColors,
RowSideColors,
cexRow = 0.2 + 1/log10(nr),
cexCol = 0.2 + 1/log10(nc),
labRow = NULL,
labCol = NULL,
srtRow = NULL,
srtCol = NULL,
adjRow = c(0,NA),
adjCol = c(NA,0),
offsetRow = 0.5,
offsetCol = 0.5,
colRow = NULL,
colCol = NULL,
特别注意cexRow
,它指定了大小。更改此变量以停止重叠。