log10値を表示するcirclizeパッケージでコードダイアグラムを作成することはできますか? これまでのところ、正しいサイズのリンクでプロットを作成できましたが、対応する軸が一致しません。軸は、セクターごとのすべてのリンク/ログ値の合計を表示します。これは、ログ値の合計が生の値の合計に対応しないため、正しくありません。この軸の問題を解決する方法はありますか?
以下は私がこれまでに試したことの例です
library(circlize)
export_country <- c("DEU","USA","IDN","USA","IDN","USA","IDN","CAN","DEU","DEU","IDN","NZL","DEU","USA","USA","USA","IDN","SGP","IDN")
import_country <- c("JPN","JPN","USA","JPN","TWN","CAN","CHN","USA","CHN","CHN","DEU","JPN","USA","DNK","JPN","CHN","JPN","CHN","CHN")
flow <- c(2000,65780,78010,851,35353,845,738,120788,245900,90002,4426,6870,152681,78114,32591,19274,10915,23100,6275)
df <- data.frame(export_country, import_country, flow,stringsAsFactors = FALSE)
country = unique(c(df[[1]], df[[2]]))
color <- c("#E41A1C","#800000","#ff8c00","#ffd700","#008000","#00bfff","#377EB8",
"#ff69b4","#800080","#4b0082")
df1 <- data.frame(country, color,stringsAsFactors = FALSE)
circos.clear()
circos.par(start.degree = 90, gap.degree = 5, track.margin = c(-0.1, 0.1), points.overflow.warning = FALSE)
par(mar = rep(0, 4))
chordDiagram(x = df[1:2],log10(df[3]), grid.col = color, transparency = 0.25,
order = country, directional = 1,
direction.type = c("arrows", "diffHeight"), diffHeight = -0.04,
annotationTrack = c("grid","axis"), annotationTrackHeight = c(0.05, 0.1),
link.arr.type = "big.arrow", link.sort = TRUE, link.largest.ontop = TRUE)
circos.trackPlotRegion(
track.index = 1,
bg.border = NA,
panel.fun = function(x, y) {
xlim = get.cell.meta.data("xlim")
sector.index = get.cell.meta.data("sector.index")
country = df1$country[df1$country == sector.index]
circos.text(x = mean(xlim), y = 4.4,
labels = country, facing = "bending", cex = 1, niceFacing = TRUE, adj = c(0.5, 0))
}
)
次のプロットを与える