I am using ggplot to make a plot and I'm having trouble specifying
the values of the x-axis. I would like each sample value to be shown on the graph i.e. 1-50.
Here is a short portion of the code:
chrom chr_start chr_stop num_positions normal_depth tumor_depth log2_ratio gc_content sample
324202 1 156249804 156249858 55 12.3 4.7 -1.399 34.5 10
324203 1 156250463 156250473 11 10.0 4.6 -1.109 27.3 10
324204 1 156250664 156250705 42 12.0 7.4 -0.704 19.0 10
324205 1 156250816 156250847 32 11.7 4.6 -1.343 40.6 10
324206 1 156251108 156251132 25 10.6 3.6 -1.569 60.0 10
324207 1 156251411 156251464 54 12.3 6.8 -0.863 46.3 10
Here is the ggplot
function:
newHist = ggplot(resultsPileup1COMBINED[resultsPileup1COMBINED$sample <= 25,],
aes(x=sample)) +
geom_histogram(fill="blue") +
geom_histogram(data=resultsPileup1COMBINED[resultsPileup1COMBINED$sample > 25,],
aes(x=sample), fill="gray50")
I would plot like this:
The two main additions are
binwidth = 1
to ensure every sample gets its own column, andscale_x_continuous
to limit the scales, with the breaks = 0:50 call to manually label the axisHere's the data with a couple of 40s to test the second plot call: