最后一行给出错误:
library(ggtree)
nwk <- read.tree("nwk_file")
metadata <- read.table("metadata_file", sep="\t", stringsAsFactor=FALSE)
g <- ggtree(nwk)
gheatmap(g, metadata, offset=5, width=0.5, font.size=3, colnames_angle=-45,
hjust=0)
该错误显示为:
"Error: Must request at least one colour from a hue palette."
我检查了一下,gheatmap函数的默认参数为colours
。
编辑
我试图举一个可重复的例子:
library(ggtree)
tree_nwk <- "(((((((A:4,B:4):6,C:5):8,D:6):3,E:21):10,
((F:4,G:12):14,H:8):13):13,((I:5,J:2):30,(K:11,L:11):2):17):4,M:56);"
write(tree_nwk, file = "data.nwk")
tree <- read.tree("data.nwk")
p <- ggtree(tree)
dd <- data.frame(taxa = LETTERS[1:13],
place = c(rep("GZ", 5), rep("HK", 3), rep("CZ", 4), NA),
value = round(abs(rnorm(13, mean=70, sd=10)), digits=1))
dd <- dd[sample(1:13, 13), ]
row.names(dd) <- NULL
write(t(dd), "test_data.txt", ncolumns = 3, append = FALSE, sep = "\t")
test_table <- read.table("test_data.txt", sep="\t", stringsAsFactor=F)
gheatmap(p, test_table, offset=5, width=0.5, font.size=3,
colnames_angle=-45, hjust=0)