Graph in R: sort alpha-numerically X-axis
1
0
Entering edit mode
8.0 years ago
bdelolmo ▴ 10

Hello,

I am facing the problem to plot a typical CNV plot using R (and ggplot2), with ratios on the Y axis and the chromosome and position interval on the X-axis (e.g chr1:17000-17100) but I only get it sorted numerically by default. Do you know how could I do it?

R CNV ggplot • 2.6k views
ADD COMMENT
0
Entering edit mode

Not completely sure what you mean. Are the values "chr1:17000-17100" plotted like that in the x-axis? (in which case they would be considered factors and ordered by their order as factors. If that is the case then googling for something like "order factor ggplot2" may give you some hints (this is a commonly asked question). At any rate, I would suggest you add a minimum reproducible example so that people in this site can see what you get and give you an alternative.

ADD REPLY
0
Entering edit mode
8.0 years ago
bdelolmo ▴ 10

@ddiez, Thanks for answering. My problem was that for example after chr1:17000-17000 being the last interval from that chromosome, it should follow chr2:xxx-yyy following an alphanumeric order, but I was getting chr10:xxx-yyy. By using factors I can handle this, as you say, so many thanks.

ADD COMMENT
0
Entering edit mode

Please, add comments using the ADD COMMENT or ADD REPLY buttons above (instead of adding an answer). This helps keep conversations organized. Yes, what you explain looks exactly like the symptoms of using factors that follow a particular order. The searches I mentioned above should help you find a solution. Without the code you are using to obtain your plot it is not possible to go further.

ADD REPLY

Login before adding your answer.

Traffic: 2057 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6