This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Add error bars to barplot that uses melted dataframe in R

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

0 answers

No answers yet.

Log in to answer this question.