在 'circlize' 中扩展扇区的高度和其他最后的润色
Expanding the height of sector in 'circlize' and other final touches
大家 -
我在增加圆图内部向量的高度时遇到了一些问题。我希望它足够大以包含放大的标签(见图)。我的工作主要靠这个 post. I also have a question as to why my plots seem extremely pixelated compared to the many blog posts htat have generated plots using chordDiagram()
or the examples in Circular Visualization in R。我在尝试向链接添加边框时遇到问题。任何其他格式提示将不胜感激。感谢您的时间和建议。
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()
尝试在 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
大家 -
我在增加圆图内部向量的高度时遇到了一些问题。我希望它足够大以包含放大的标签(见图)。我的工作主要靠这个 post. I also have a question as to why my plots seem extremely pixelated compared to the many blog posts htat have generated plots using chordDiagram()
or the examples in Circular Visualization in R。我在尝试向链接添加边框时遇到问题。任何其他格式提示将不胜感激。感谢您的时间和建议。
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()
尝试在 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