Hi Thanks! But i want to combine all replicates together and show error bar in that.
• 0 views
•
link
Hi
I want to try ggplot to draw bar chart or line graph with 6 samples and each samples has 6 replicates. I am wondering how should I consider these replicates? should I take average or I should use reshape that
Here is an example:
sample_name R1 R2 R3 R4 R5 R6
C 3h 28.0 23.6 16.4 21.0 33.2 29.4
LPS 3h 18.5 21.8 28.9 30.6 25.5 34.2
PI 3h 23.0 15.4 16.6 15.7 54.3 27.1
C 6h 47.9 56.7 40.9 94.9 64.6 38.7
LPS 6h 29.3 33.2 18.1 19.8 22.9 52.3
PI 6h 36.6 35.7 37.3 34.5 54.3 65.9
best,
sachin
Something like this?
dat = structure(list(V1 = c("C", "LPS", "PI", "C", "LPS", "PI"), sample_name = c("3h",
"3h", "3h", "6h", "6h", "6h"), R1 = c(28, 18.5, 23, 47.9, 29.3,
36.6), R2 = c(23.6, 21.8, 15.4, 56.7, 33.2, 35.7), R3 = c(16.4,
28.9, 16.6, 40.9, 18.1, 37.3), R4 = c(21, 30.6, 15.7, 94.9, 19.8,
34.5), R5 = c(33.2, 25.5, 54.3, 64.6, 22.9, 54.3), R6 = c(29.4,
34.2, 27.1, 38.7, 52.3, 65.9)), row.names = c(NA, -6L), class = c("data.table",
"data.frame"))
dat %>%
dplyr::mutate(sample_name = stringr::str_c(V1, sample_name, sep="_")) %>%
dplyr::select(-V1) %>%
tidyr::pivot_longer(-sample_name) %>%
ggplot(aes(x=sample_name, y=value, fill=name)) +
geom_bar(stat='identity', position='dodge')
Hi Thanks! But i want to combine all replicates together and show error bar in that.
Log in to answer this question.
with OP input data:
Please change the aesthetics as per your requirements.