ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Heatmap colors are showing transparent when alpha is not used

Open ireneortega opened this issue 2 years ago • 1 comments
trafficstars

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)?

ireneortega avatar Jun 06 '23 08:06 ireneortega

@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.

YushaLiu avatar Jul 03 '23 18:07 YushaLiu