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