Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using ggplot2 to do some plotting of genomic data, so the basic format is that there is a chromosome and a position along it. I convert the positions to be on a continuous scale, then put the breaks at the boundaries of the chromosomes with:

scale_x_continuous("Genome Position", breaks = c(0, cumsum(chromosome_length)))

That looks great, as far as the actual plotting is concerned, but the labels are then put at the start and end of the chromosomes. I would like them to be centered along each chromosome, at the position where the minor break is drawn by default.

Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
944 views
Welcome To Ask or Share your Answers For Others

1 Answer

How about this?

breaks <- c(0, cumsum(chromosome_length))
scale_x_continuous("Genome Position", breaks = breaks + 0.5, labels = breaks)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...