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.
try geom_errorbar j.lunger18
have a look at this link: https://stackoverflow.com/questions/48692401/how-to-add-error-bars-to-barplot-in-r, it may help!