绘制多个长度和列

时间:2018-08-24 16:29:34

标签: r plot

我想在X轴上绘制17K组间隔,在其中绘制每个Chr列的开始和停止间隔。但是,这些间隔未正确绘制到每个chr?我从图的右边弄清楚了,红点与输入数据不匹配。对修复有何想法?要清楚,hrn.len是每个染色体的长度。

Data;
ID  Chr Start   Stop
XLOC_007681 2R  11896162    11896597
XLOC_024365 3R  11283380    11286479
XLOC_021494 3R  16392979    16396291
XLOC_012125 3L  136830  138533
XLOC_031405 X   8002493 8004054
XLOC_014371 3L  15537489    15538755
XLOC_005808 2L  20704834    20706685
XLOC_005809 2L  20706861    20708183
XLOC_005807 2L  20703325    20703897

================================================ ============

chr.len <- c(22422827, 204112, 347038, 23011544, 368872, 21146708, 3288731, 24543557, 2555491, 27905053, 2517507, 1351857, 10049037)
names(chr.len) <- c("X", "XHet", "YHet", "2L", "2LHet", "2R", "2RHet", "3L", "3LHet", "3R", "3RHet", "4", "U")
chr.gap <- 2000000
chr.cum <- cumsum(c(0, chr.len[1:12])) + (0:12)*chr.gap
names(chr.cum) <- names(chr.len)
# ============================================================
png(file = "C:/Users/cahighfi/Desktop/XLOC_Position.png", width = 10, height = 5, units = "in", res = 300)
plot(c(0, chr.cum["U"] + chr.len["U"]), c(0, 1), type = "n", axes = FALSE, ylab = "", xlab = "", )
segments(XLOC.pos$Start + chr.cum[XLOC.pos$Chr], 0.5, XLOC.pos$Stop + chr.cum[XLOC.pos$Chr], 0.5, lwd = 10)
segments(DrugXLOC.pos$Start + chr.cum[DrugXLOC.pos$Chr], 0.5, DrugXLOC.pos$Stop + chr.cum[DrugXLOC.pos$Chr], 0.5, lwd = 10, col = c("red"))
axis(side = 1, at = chr.cum + chr.len/2, labels = parse(text = paste("italic(\"", names(chr.len), "\")", sep = "")), mgp = c(2.5, 0.5, 0), tck = -0.015, cex.axis = 1.0)
dev.off()

[输出图] [[1]]

[[1]]:https://i.stack.imgur.com/qPObX.png

0 个答案:

没有答案