I have data that looks like this:
Name Odds_Ratio_(log2) p-value
Ann -1.80494 0.05
Lucy 2.51017 0.1
Sally -1.97779 0.01
...
And I want to make graph that would look something like Figure B or C.
To have p-values on y-axis, odds ratio on x axis (divided by such vertical line) and Names next to plotted symbol. I don't have fractional size so it's impossible to change symbol size here.
How can I do it?
I really hope that someone will help me with this, as my R plotting knowledge lets me to make plots only like this:
plot(data$V2,data$V3, main="Ratio", xlab="p-value",ylab="Odds ratio (Log2)")
.
You should refer to
?plot
,?abline
, and?text
. That said, here's one way to do it with base functions.UPDATE:
I've added
yaxs='i'
to theplot
call above, because unless we do this, the top axis intercepts slightly higher than y=1, perhaps giving an impression of lower p-values.Note that the plot is not "rotated", per se. Rather, we suppress axis 1 and 2 (the default x and y axes), with
axes=F
, and instead we plot axis 3 (the top axis; see?axis
). We then usemtext
to plot the label for axis 3. To plot a label at the left edge of the plot, you can either use theylab
argument (which I've set equal to''
) in theplot
function, or usemtext('p-value', 2)
.Alternatively, if you want the central vertical line to have ticks and labels corresponding to y-values, . Then, use
segments
to add tick marks, andtext
to add tick labels, e.g.:The end result will look something like this: