【问题标题】:Expanding the height of sector in 'circlize' and other final touches在“circlize”和其他最后润色中扩大扇区高度
【发布时间】:2020-09-01 14:04:37
【问题描述】:

每个人-

我在增加 circlize 图的内部向量高度时遇到了一些问题。我希望它足够大以包含放大的标签(见图)。我一直主要在这个post 上工作。我还有一个问题,为什么与 htat 使用chordDiagram()Circular Visualization in R 中的示例生成图的许多博客文章相比,我的图看起来非常像素化。我在尝试为链接添加边框时遇到问题。任何其他格式提示将不胜感激。感谢您的时间和建议。

Link to the data

library(circlize) 

    df <- read.csv("./circlize_df.csv", header = TRUE)

    (pop_id = c(structure(df$uncor_from,
                        names = df$cor_from),
              structure(df$uncor_to,
                        names = df$cor_to)))

    (pop_id = pop_id[!duplicated(names(pop_id))])

    uncorrelated_color = c("BM" = "gray",
                           "ECPSRM" = "darkorange1", 
                           "DMS" = "black",
                           "MHSS" = "green",
                           "SIS" = "blue2",
                           "TP" = "coral2")

    correlated_color = c("BM" = "gray",
                         "LSM" = "orange", 
                         "SJC" = "orangered",
                         "SCM" = "darkorange1", 
                         "ZM" = "orangered4",
                         "MT" = "orange4",
                         "SMM" = "green",
                         "MR" = "black",
                         "GC" = "gray30",
                         "SM" = "green4",
                         "SIN" = "slategray",
                         "HSRM" = "blue",
                         "CHC" = "blue4",
                         "TP" = "coral2")

    circos.par(start.degree = 135,
               track.margin = c(.01,0.01))

    chordDiagram(df[,1:3], 
                 order = c("BM","LSM", "SJC","SCM","ZM","MT","SMM","SM","TP","CHC","HSRM","SIN","GC","MR"),
                 grid.col = correlated_color,
                 link.border = border.color,
                 annotationTrackHeight = c(0.03, 0.01),
                 link.arr.type = "big.arrow",
                 link.arr.length = uh(3, "mm"),
                 link.rank = rank(df$value),
                 h.ratio = 0.8,
                 transparency = .5,
                 directional = 1,
                 diffHeight = -uh(1, "mm"),
                 direction.type = c("diffHeight", "arrows"),
                 annotationTrack = c("grid"),
                 preAllocateTracks = list(
                   list(track.height = 0.03)))

    circos.trackPlotRegion(track.index = 2, 
                           panel.fun = function(x, y) {
                             xlim = get.cell.meta.data("xlim")
                             ylim = get.cell.meta.data("ylim")
                             sector.index = get.cell.meta.data("sector.index")
                             circos.text(mean(xlim), 
                                         mean(ylim), 
                                         sector.index, 
                                         col = "white",
                                         cex = 0.8,
                                         facing = "bending.inside", 
                                         niceFacing = TRUE)
    }, bg.border = NA)

    for(p in unique(pop_id)) {
      sub_pop = names(pop_id[pop_id == p])
      highlight.sector(sector.index = sub_pop, 
                       track.index = 1, 
                       col = uncorrelated_color[p], 
                       text = p, 
                       font = 2,
                       text.vjust = -0.5, 
                       niceFacing = TRUE)
    }

    circos.clear()

【问题讨论】:

    标签: r circlize


    【解决方案1】:

    尝试在 circos.par() 中定义 track.height。

    编辑

    只需将 annotationTrackHeight = c(0.03, 0.01) 更改为 annotationTrackHeight = 0.08 即可。

    ccircos.par(start.degree = 135,
               track.margin = c(.01,0.01))
    
    chordDiagram(df[,1:3], 
                 order = c("BM","LSM", "SJC","SCM","ZM","MT","SMM","SM","TP","CHC","HSRM","SIN","GC","MR"),
                 grid.col = correlated_color,
                 #link.border = border.color,
                 #annotationTrackHeight = c(0.03, 0.01),
                 annotationTrackHeight = 0.08,
                 link.arr.type = "big.arrow",
                 link.arr.length = uh(3, "mm"),
                 link.rank = rank(df$value),
                 h.ratio = 0.8,
                 transparency = .5,
                 directional = 1,
                 diffHeight = -uh(1, "mm"),
                 direction.type = c("diffHeight", "arrows"),
                 annotationTrack = c("grid"),
                 preAllocateTracks = list(
                   list(track.height = 0.03)))
    
    circos.trackPlotRegion(track.index = 2, 
                           panel.fun = function(x, y) {
                             xlim = get.cell.meta.data("xlim")
                             ylim = get.cell.meta.data("ylim")
                             sector.index = get.cell.meta.data("sector.index")
                             circos.text(mean(xlim), 
                                         mean(ylim), 
                                         sector.index, 
                                         col = "white",
                                         cex = 0.8,
                                         facing = "bending.inside", 
                                         niceFacing = TRUE)
                           }, bg.border = NA)
    
    for(p in unique(pop_id)) {
      sub_pop = names(pop_id[pop_id == p])
      highlight.sector(sector.index = sub_pop, 
                       track.index = 1, 
                       col = uncorrelated_color[p], 
                       text = p, 
                       font = 2,
                       text.vjust = -0.5, 
                       niceFacing = TRUE)
    }
    

    graph here

    【讨论】:

    • 试过了,但没有骰子。感谢您的建议。
    • 你是最棒的,birdMig。那工作得很好。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-23
    相关资源
    最近更新 更多