【发布时间】:2021-01-10 19:38:52
【问题描述】:
有了这段代码,我就有了这个复杂的热图
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 。我怎样才能改变传说中的所以我有red作为Amp,blue作为Del和grey作为Netral好吗?
2- 我怎样才能使基因变为斜体?
【问题讨论】:
-
你能让你的问题重现吗?包括包和数据,以便人们可以运行您的代码。谢谢。
-
谢谢你把我的全部数据贴在这里
-
您需要所有数据和所有这些软件包来重现问题吗?似乎您处理的是一个连续的图例,但想要一个使用 ggplot2 的离散图例?!这可能会有所帮助R ggplot2: legend should be discrete and not continuous