我正在尝试创建一个具有 4 个扇区的圆形条形图;每个扇区都有不同数量的柱。我希望扇区大小与条的数量成正比,并用特征(表型)和频率值标记每个条。
我有 4 个扇区,“fruit_sector”:“apples”、“pears”、“oranges”、“bananas”;对于每个部门,我都有几个不同的品种,“表型”。对于每个,一个频率。
color4 = c("#9E0142", "#D53E4F", "#F46D43", "#FDAE61", "#FEE08B", "#FFFFBF",
"#E6F598","#ABDDA4", "#66C2A5", "#3288BD" ,"#5E4FA2")
pheno <- na.omit(read.csv("test_circos_210506.csv",stringsAsFactors = F))%>%
group_by(fruit_sector)%>%
mutate(x=1,
x=cumsum(x))
labels=pheno$Phenotype
circos.clear()
circos.par("track.height" = 0.7, gap.degree = 2,
start.degree=-51,
circle.margin = c(0,0,0,0))
circos.initialize( pheno$fruit_sector, x = pheno$x)
circos.track(
sectors = pheno$fruit_sector,
x = pheno$x,
y = pheno$Frequency,
panel.fun = function(x,y) {
circos.barplot(
value = y,
pos = x+0.3,
col = color4,
bar_width=0.8,
border="black")
sector.index = get.cell.meta.data("sector.index")
xcenter = get.cell.meta.data("xcenter")
ycenter = get.cell.meta.data("ycenter")
circos.text(xcenter, ycenter, sector.index,
cex = 1.4,
niceFacing =T,
facing="bending.inside",
adj = c(0.5,-5))
circos.text(x,y,labels,
cex = 0.8,
facing = "clockwise")
}
)
几个问题:
- 条形标签从每个扇区的文件开头开始,而不是遍历每个扇区(所有扇区都从“苹果”表型开始
- 我无法对齐标签
- 我想将频率添加到每个条形。
- 低频条没有出现(以下错误)
- 我必须添加一条频率 = 0 的线,否则最后一个条将与间隙重叠。
警告:
Note: 2 points are out of plotting region in sector 'apples', track '1'.
Note: 6 points are out of plotting region in sector 'apples', track '1'.
Note: 2 points are out of plotting region in sector 'bananas', track '1'.
Note: 7 points are out of plotting region in sector 'bananas', track '1'.
Note: 2 points are out of plotting region in sector 'oranges', track '1'.
Note: 7 points are out of plotting region in sector 'oranges', track '1'.
Note: 2 points are out of plotting region in sector 'pears', track '1'.
Note: 5 points are out of plotting region in sector 'pears', track '1'.
我有基本的 R 技能,有什么帮助吗?