Add error bars to barplot that uses melted dataframe in R
0
0
Entering edit mode
5.0 years ago
j.lunger18 ▴ 30

I'm attempting to add error bars to my barchart. In order to plot it, I had to melt my dataframe, which originally contained a "plus" column and a "minus" column, which indicated the top and bottom of my error bars respectively for that group of replicates. I don't know how to add in my error bars once my dataframe is melted...

ddCT_results = original data frame

> colnames(ddCT_results)
 [1] "Cell Type"   "Construst"   "Version"     "Target"      "Day"         "Target Name"
 [7] "Ct Mean"     "Ct SD"       "Reference"   "dCt"         "dCt SD"      "ddCt"       
[13] "Fold Change" "Plus"        "Minus"      

> ddCT_results_melted_fc <- melt(ddCT_results, id.vars = c("Version", "Target", "Day"), 
+                                measure.vars = c("Fold Change"))

> colnames(ddCT_results_melted_fc)
[1] "Version"  "Target"   "Day"      "variable" "value"   

> myPlot <- ggplot(ddCT_results_melted_fc, aes(x = Day, y = value, group = Target, fill = Target)) +
+     geom_bar(position = "dodge", stat="identity") +
+     facet_grid(cols = vars(Version), labeller = "label_both") +
+     scale_fill_manual(values = c("#9ecae1", "#3182bd", "#1c9099", "#bdbdbd")) +
+     theme_minimal()

> myPlot

Plot looks great aside from the fact that it doesn't have error bars.

R ggplot2 qPCR ddCT • 1.4k views
ADD COMMENT
1
Entering edit mode

try geom_errorbar j.lunger18

ADD REPLY
0
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 2547 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