更改复杂热图中的图例

Changing the legend in complex heatmap

有了这个代码,我就有了这个复杂的热图

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

[![在此处输入图片描述][1]][1]

这是我的 R 对象

1- 问题是,块中的颜色是离散的,但在图例中您看到的是 1 0 -1 -2 。我如何更改图例中的 so,我有 redAmpblueDelgreyNetral

2- 我怎样才能使基因变成 斜体 ?

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