Hi all, I am using ggtree and gheatmap to visualize a tree in R. Tree was generate using phylophlan. I generated the tree in the following manner:
tree2 <- read.tree("mytree.tre")
x <- ggtree(tree2, layout="circular")
Load the metadata file
dd=read.table('metadata.tsv', header=T,check.names=FALSE, sep = "\t")
p1 <- gheatmap(x, dd, width=0.2, offset=0.8, color = NA, colnames_angle=90, colnames_offset_y = 0.25) + scale_fill_viridis_d(option="D", name="Phylum")
The phylum column in my metadata has no NAs. However the plot formed shows all phylum names and NAs too. This results in separate lines in my heatmap instead of continous bars (see attached).
Can anyone help me with what the issue could be here? Why the NAs are present and how to get rid of them?
Any help would be appreciated, thank you. Best DP
Of course, I can't rule out that there is something else going on, but I am still convinced that the most likely explanation is a mismatch between the provided metadata and the tree. Either the tip labels are incorrect (maybe capitalized?) or the row names mangled when reading in your metadata. I have added a minimal working example to my initial reply to better illustrate what I meant.
Hi, thank you very much, I followed your suggestions and realized the issue with annotations and corrected it. Thank you very much once again for your help. Best Dhrati