Dear all,
I have the following problem when I use gheatmap with ggtree:
Error in guides_train():
! Guide colorbar cannot be used for fill_new.
Run rlang::last_error() to see where the error occurred.
To explain: I attemp to include differe datafram with gheatmap (both categorical variables rather than continous), but each time the new variable fill sobstitute the previous variable fill as well as it appears to change the values.
I attached my code
tree <- ape::read.tree("tree.nwk")
data <- as.data.frame(read_xlsx("data2.xlsx"))
head(data)
Bacteroidetes <- data.frame("Bacteroidetes" = data[,c("Bacteroidetes")])
rownames(Bacteroidetes) <- data$Sample_ID
h2 <- h1 + new_scale_fill()
h3 <- gheatmap(h2,Bacteroidetes, offset=0.034, width=0.05, font.size=4,
colnames_position = "top",
colnames_offset_y = 1, color = "black", colnames_angle=90, hjust=0.5) +
scale_fill_continuous(name = "Bacteroidetes", # here we define a gradient color scheme for the continuous variable of Richness
low = "yellow", high = "red",
breaks = c(0,0.25,0.50,0.75,1.00),
na.value = "gray70") +
guides(fill = guide_colourbar(barwidth = 3, barheight = 1)) +
theme(legend.position = "bottom",
legend.title = element_text(size = 12),
legend.text = element_text(size = 10),
legend.box = "vertical", legend.margin = margin())
h3
I would like to use different continous colors for my data with respect to scale (for example some data have range 0-1, whereas other, i.e. Richness show higher numbers)
I have almost updated each package to last versions.
Dear all, I have the following problem when I use gheatmap with ggtree: Error in
guides_train()
: ! Guidecolorbar
cannot be used for fill_new. Runrlang::last_error()
to see where the error occurred.To explain: I attemp to include differe datafram with gheatmap (both categorical variables rather than continous), but each time the new variable fill sobstitute the previous variable fill as well as it appears to change the values.
I attached my code
tree <- ape::read.tree("tree.nwk") data <- as.data.frame(read_xlsx("data2.xlsx")) head(data)
data1 <- data[,-c(1,2)]
p <- ggtree(tree) %<+% data + geom_tiplab(offset = 0.01, hjust = 0.5, size=2.5) + geom_tippoint(mapping = aes(color = Cluster), size = 3.5) + scale_color_manual( values=c("Cluster 1"="firebrick3","Cluster 2"="royalblue","other"="forestgreen") ) + theme_tree2(legend.position = "bottom") p
Actinobacteria <- data.frame("Actinobacteria" = data[,c("Actinobacteria")]) rownames(Actinobacteria) <- data$Sample_ID h1 <- gheatmap(p,Actinobacteria, offset=0.004, width=0.05, font.size=4, colnames_position = "top", colnames_offset_y = 1,color = "black", colnames_angle=90, hjust=0.5) + scale_fill_continuous(name = "Actinobacteria", # here we define a gradient color scheme for the continuous variable of Richness low = "yellow", high = "red", breaks = c(0,0.25,0.50,0.75,1.00), na.value = "gray70") + guides(fill = guide_colourbar(barwidth = 3, barheight = 1))+ theme(legend.position = "bottom", legend.title = element_text(size = 12), legend.text = element_text(size = 10), legend.box = "vertical", legend.margin = margin()) h1
Bacteroidetes <- data.frame("Bacteroidetes" = data[,c("Bacteroidetes")]) rownames(Bacteroidetes) <- data$Sample_ID h2 <- h1 + new_scale_fill() h3 <- gheatmap(h2,Bacteroidetes, offset=0.034, width=0.05, font.size=4, colnames_position = "top", colnames_offset_y = 1, color = "black", colnames_angle=90, hjust=0.5) + scale_fill_continuous(name = "Bacteroidetes", # here we define a gradient color scheme for the continuous variable of Richness low = "yellow", high = "red", breaks = c(0,0.25,0.50,0.75,1.00), na.value = "gray70") + guides(fill = guide_colourbar(barwidth = 3, barheight = 1)) + theme(legend.position = "bottom", legend.title = element_text(size = 12), legend.text = element_text(size = 10), legend.box = "vertical", legend.margin = margin()) h3
I would like to use different continous colors for my data with respect to scale (for example some data have range 0-1, whereas other, i.e. Richness show higher numbers)
I have almost updated each package to last versions.
Thank you so much