首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R包圆圈: circos热图颜色未出现

R包圆圈: circos热图颜色未出现
EN

Stack Overflow用户
提问于 2022-03-16 20:17:05
回答 1查看 118关注 0票数 1

我正在尝试创建一个使用圆圈包的圆形图形。当使用十六进制颜色代码时,我的绘图不会显示任何内容,但是当我使用实际颜色名称时,它会显示出来。为什么会这样呢?

代码:

代码语言:javascript
复制
suppressPackageStartupMessages({
  library(tidyverse) 
  library(circlize) 
})

# input data
dput(annot)

structure(list(Case_type = c("Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "Initial CNS Tumor", 
"Initial CNS Tumor", "Initial CNS Tumor", "no evidence of disease", 
"no evidence of disease", "no evidence of disease", "Progressive", 
"Progressive", "Progressive", "Progressive", "Progressive", "Progressive", 
"Progressive", "Progressive", "Progressive", "Progressive", "Recurrence", 
"Recurrence", "Recurrence", "Recurrence", "Recurrence", "Recurrence", 
"Recurrence", "Recurrence")), row.names = c("15635-32", "15635-37", 
"15635-38", "15635-42", "15635-43", "15635-53", "15635-58", "15635-60", 
"15635-63", "15635-70", "15635-75", "15635-80", "15635-87", "15635-100", 
"15635-108", "15635-132", "15635-134", "15635-135", "15635-2", 
"15635-7", "15635-11", "15635-145", "15635-150", "15635-154", 
"15635-161", "15635-169", "15635-170", "15635-187", "15635-197", 
"15635-214", "15635-228", "15635-225", "15635-234", "15635-239", 
"15635-251", "15635-246", "15635-254", "15635-182", "15635-45", 
"15635-46", "15635-68", "15635-90", "15635-101", "15635-127", 
"15635-1", "15635-148", "15635-156", "15635-29", "15635-31", 
"15635-215", "15635-81", "15635-120", "15635-129", "15635-158", 
"15635-279"), class = "data.frame")

# split into 4 categories
split <- factor(annot$Case_type)
circos.clear()

# does not work with the hex color codes
col_fun1 <- list('Initial CNS Tumor' = '#59acff',
                 'Recurrence' = '#ffac59',
                 'Progressive' = '#ffff59',
                 'no evidence of disease' = '#acff59')
circos.par(start.degree = 30, gap.degree = 1, points.overflow.warning = FALSE)
circos.heatmap(annot, 
               split = split, 
               col = col_fun1, 
               track.height = 0.4, 
               bg.border = "gray50",
               show.sector.labels = T)
circos.clear()

当我使用非十六进制颜色名称时,它起作用:

代码语言:javascript
复制
# this works
col_fun2 <- list('Initial CNS Tumor' = 'yellow',
                 'Recurrence' = 'blue',
                 'Progressive' = 'green',
                 'no evidence of disease' = 'orange')
circos.par(start.degree = 30, gap.degree = 1, points.overflow.warning = FALSE)
circos.heatmap(annot, 
               split = split, 
               col = col_fun2, 
               track.height = 0.4, 
               bg.border = "gray50",
               show.sector.labels = T)
circos.clear()

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-16 20:34:49

根据文档,在描述参数col

如果值是字符,则颜色应该是一个命名的颜色向量。

而你传递的是一个列表而不是一个命名的向量。因此,如果您使用unlist col_fun1 (或者用c()而不是list()创建它),您可以

代码语言:javascript
复制
circos.par(start.degree = 30, gap.degree = 1, points.overflow.warning = FALSE)
circos.heatmap(annot, 
               split = split, 
               col = unlist(col_fun1),
               track.height = 0.4, 
               bg.border = "gray50",
               show.sector.labels = T)
circos.clear()

对我来说,困惑的是为什么第一个版本能工作,而不是为什么第二个版本不行。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71503731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档