YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
821 stars 172 forks source link

Heatmap colors are showing transparent when alpha is not used #572

Open ireneortega opened 1 year ago

ireneortega commented 1 year ago

I want to represent the presence/absence matrix of the pangenome with the newick tree using gheatmap. I want presence in black and absence in white:

pangenome <- read_delim(file = "gene_presence_absence.Rtab", delim = "\t", show_col_types = FALSE)

tree <- ape::read.tree(file = "accessory_binary_genes.fa.newick")
  tree_graph <- ggtree(tree, size=1/5) +
    geom_tiplab(size=2,
                align=FALSE,
                linesize=0.5) +
    geom_treescale(offset = -1)

  pangenome_tree_matrix <- gheatmap(p = tree_graph, 
           data = pangenome,
           width = 10,
           colnames = FALSE,
           font.size = 10,
           ) + 
    scale_fill_manual(breaks=c("1", "0"),
                      values=c("black", "white")) +
    theme(legend.position = 'none')

  pangenome_tree_matrix

However, the figure showed is: pangenome which is not black. Moreover, if I increase the number of genomes, the figure gets even more transparent. How can I make the colors show darker (black in fact)?

YushaLiu commented 1 year ago

@ireneortega I have encountered the same problem, and in my case this seems to be fixed by setting color = NA in your call of gpheatmap.