I'm trying to make a bar plot in ggplot with 2 values for each bin (fold change values from RNA-Seq and qPCR experiments):
Gene FC expt se
a 1.02 RNA-Seq 0
b 2.79 RNA-Seq 0
c 1.63 RNA-Seq 0
d 0.84 RNA-Seq 0
e 0.81 RNA-Seq 0
f 1.45 RNA-Seq 0
g 1.27 RNA-Seq 0
h 1.72 RNA-Seq 0
i 2.52 RNA-Seq 0
a 0.84 qPCR 0.16
b 1.92 qPCR 0.15
c 1.14 qPCR 0.78
d 0.47 qPCR 0.76
e 0.95 qPCR 0.26
f 0.32 qPCR 0.51
g 0.92 qPCR 0.39
h 0.97 qPCR 0.61
i 1.73 qPCR 0.77
My RNA-Seq values don't have error bars. As such I want to plot a barchart with:
- Error bars that only extend up
- Error bars only for q-PCR bars
I'm not sure where my code (or input format) is going wrong:
df <- read.table("stack.txt", header=TRUE)
limits <- aes(ymax = FC + se, ymin = FC)
dodge <- position_dodge(width = 0.9)
ggplot(data=df, aes(x=Gene, y=FC)) +
geom_errorbar(limits, position = dodge, width = 0.25) +
geom_bar(aes(fill=expt),colour="black", stat="identity", position = dodge)
Which produces:
As you can see, the error bars are in the middle of each bin, rather than being onto of each bar. Any suggestions/comments would be hugely appreciated!
position_dodge(width = <...>)
– Neckerchief