Reputation: 1071
I trying to plot this
ggplot() +
geom_rect(data = don7, aes(xmin = startPos , xmax = finalPos , ymin = 0, ymax = 1, fill=sv)) +
geom_rect(data = don10, aes(xmin = startPos, xmax = finalPos , ymin = 1, ymax = 2, fill=sv)) +
scale_fill_manual(values=c("red", "green", "blue", "black"))+
theme_bw() +
theme(
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
axis.title.x=element_text(size=20),
)
where
> head(don7)
chrteq start end sv chr tot startPos finalPos
1 NC_045001.1 76169 76207 INS 3 0 76169 76207
2 NC_045001.1 211586 211615 INS 3 0 211586 211615
3 NC_045001.1 253399 253424 INS 3 0 253399 253424
4 NC_045001.1 260178 260299 DUP 3 0 260178 260299
5 NC_045001.1 323052 323156 DEL 3 0 323052 323156
6 NC_045001.1 348140 348180 DEL 3 0 348140 348180
> head(don10)
chrteq start end sv chr tot startPos finalPos
1 NC_045001.1 30695 30731 INS 3 0 30695 30731
2 NC_045001.1 91074 91155 INS 3 0 91074 91155
3 NC_045001.1 123627 123658 INS 3 0 123627 123658
4 NC_045001.1 158838 158923 DEL 3 0 158838 158923
5 NC_045001.1 177204 177231 DEL 3 0 177204 177231
6 NC_045001.1 212236 212878 DEL 3 0 212236 212878
but some rectangles are not shown, as depending how big I save the plot different rectangles show up/disappear
why is that?
thxs
EDIT: using pointed strategies
I noticed that bc I have much more DEL than INV, for example, the plot will look a lot red, in this case. I was wondering how I can grep only INS and plot from 0-1, DUP 1-2 and so on.
Upvotes: 0
Views: 53
Reputation: 160687
As the comments suggest, if you plot this into a vector-based engine (e.g., pdf), you can see all of the lines:
pdf("~/Downloads/5719890_66093693.pdf", height = 2)
# your plot code
dev.off()
Taking @teunbrand's suggestion, adding colour=sv
gives some more break-out:
ggplot() +
geom_rect(data = don7, aes(xmin = startPos , xmax = finalPos , ymin = 0, ymax = 1, fill = sv, colour = sv)) +
geom_rect(data = don10, aes(xmin = startPos, xmax = finalPos , ymin = 1, ymax = 2, fill = sv, colour = sv)) +
scale_fill_manual(values=c("red", "green", "blue", "black"))+
theme_bw() +
theme(
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
axis.title.x=element_text(size=20),
)
Upvotes: 1