-1

With this code I have this complexheatmap

library(dplyr)
library(rafalib)
library(RColorBrewer)
#if (!requireNamespace("BiocManager", quietly = TRUE))
#  install.packages("BiocManager")
#BiocManager::install("genefilter")
library(genefilter)
library(gplots)
library(ComplexHeatmap)
library(circlize)
library(scales)
library(stringr)
library(reshape2)
library(Seurat)
library(limma)
library(dropbead)
library(sctransform)
library(Matrix)
library(ggrepel)
library(viridis)
library(tidyverse)
library(cowplot)


left_annotation = rowAnnotation(Peak = anno_text(left_anno$Peak),
                                Percentage = anno_barplot(left_anno$Percentage_altered_nr,
                                                          gp = gpar(fill = "gold"),
                                                          axis_param = list(direction = "reverse"),
                                                          width = unit(20, "mm"),ylim = c(0, 70))

right_annotation = rowAnnotation(Percentage = anno_barplot(right_anno$Percentage_altered_r,
                                                          gp = gpar(fill = "gold"),
                                                          width = unit(20, "mm"),ylim = c(0, 60)
                                                          ))

Heatmap(mat, border = T, show_column_names = F,
        rect_gp = gpar(col = "white", lwd = 1),
        column_split = response$response, 
        col = col_fun,
        show_column_dend = F,
        show_row_dend = F,
        left_annotation = left_annotation,
        right_annotation = right_annotation,name = "CNV")

[![enter image description here][1]][1]

This is my R object

1- The problem is, in the blocks the colors are discret but in the legend you are seeing 1 0 -1 -2 . How I can change the so in the legend I have red as Amp, blue as Del and grey as Netral please?

2- How I can make the genes to italic ?

user6517
  • 33
  • 5
  • Can you make your problem reproducible? Include packages and data so that folks can run your code. Thanks. – markus Jan 10 '21 at 20:07
  • Thank you I pasted my whole data here – user6517 Jan 10 '21 at 20:28
  • Do you need all your data and all those packages to reproduce the issue? It seems you deal with a continuous legend but want a discrete one using ggplot2?! This might be helpful [R ggplot2: legend should be discrete and not continuous](https://stackoverflow.com/questions/20301922/r-ggplot2-legend-should-be-discrete-and-not-continuous) – markus Jan 10 '21 at 21:19

1 Answers1

0
Heatmap(mat, border = T, show_column_names = F,
        rect_gp = gpar(col = "white", lwd = 1),
        column_split = response$response, 
        col = c("-2" = "blue", "0" = "grey", "1" = "red"),
        heatmap_legend_param = list(at = c("-2", "0", "1"), labels = c("Del", "Netral", "Amp")),
        show_column_dend = F,
        show_row_dend = F,
        left_annotation = left_annotation,
        right_annotation = right_annotation,name = "CNV",
        row_names_gp = gpar("fontface" = "italic")
)
user6517
  • 33
  • 5