【问题标题】:How to set different color every gene and add legend in ChromoMap using R studio?如何使用 R studio 为每个基因设置不同的颜色并在 ChromoMap 中添加图例?
【发布时间】:2021-11-24 03:13:40
【问题描述】:

我已经使用chromoMap 绘制了我的数据以使基因在染色体中的位置。 这里

chr file

chr anot file

这些是我的脚本

library(chromoMap)
col.set = c("purple", "#4CBB17","#0096FF", "blue", "brown")
chr.data <- read.csv("chr_file.csv", header=T)
anno.data <- read.csv("chr_anot.csv", header = T)
chromoMap(list(chr.data),list(anno.data), labels = T, data_based_color_map = T,
          data_color = list(c(col.set)))

我得到了这样的结果 output file

我想为每个基因设置不同的颜色并添加图例。

知道我该怎么做吗?请帮我。 谢谢

【问题讨论】:

    标签: colors legend


    【解决方案1】:

    为了用独特的颜色为每个基因着色,您只需在注释数据中添加第 5 个数据列anno.data 让您说出基因的名称,例如:

    anno.data <- cbind.data.frame(anno.data,Symbol=anno.data$element)
    

    然后你的每个基因都会有独特的颜色。此外,对于图例,您只需将 legend 参数设置为 true。

    这里是带有一些附加配置选项的代码:

    chromoMap(list(chr.data),list(anno.data), 
              # labelling arguments 
              labels = T, 
              label_font = 12,
              label_angle = -55,
              # group annotation arguments
              data_based_color_map = T,
              data_type = "categorical",
              data_colors = list(c(col.set)),
              # for the  legend
              legend = T,
              #adjusting the legend along y-axis
              lg_y = 250,
              #increasing canvas width for legend
              canvas_width = 600,
              #playing with plot properties
              text_font_size = 12,
              chr_color = c("#d3d3d3"))
    

    感谢和问候,

    Lakshay(chromoMap 开发者)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-01
      • 2018-01-14
      • 2021-11-27
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多