Everyone -
I'm having some trouble increasing the height of the inside vector of my circlize plot. I'd like it to be large enough to encompass the enlarged labels (see figure). I've been working mainly off this 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. I'm having an issue trying to add borders to the links. Any other formatting tips would be greatly appreciated. Thanks for your time and advice.
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()
Try to define track.height inside circos.par().
EDIT
simply changing annotationTrackHeight = c(0.03, 0.01)
to annotationTrackHeight = 0.08
does the trick.
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)
}