0

I am trying to graph out two different conditions of bacteria on the same graph. I have them labeled OD600.x and OD600.y. I would like to graph them out by Strain and show both conditions on the same graph.

 time Well OD600.x Strain OD600.y
1 0.0000000   A2 0.12494 SM01KA 0.16746
2 0.1666667   A2 0.15716 SM01KA 0.17866
3 0.3333333   A2 0.19320 SM01KA 0.20490
4 0.5000000   A2 0.24392 SM01KA 0.21380
5 0.6666667   A2 0.32566 SM01KA 0.22544
6 0.8333333   A2 0.39886 SM01KA 0.23802

This is what I currently have:

ggplot(Group1, aes(time, OD600.x, group=Strain))+
  geom_line(colour="green") +
  facet_wrap(~Strain)

enter image description here

ggplot(Group1, aes(time, OD600.y, group=Strain))+
  geom_line(colour="red") +
  facet_wrap(~Strain)

enter image description here

But how do I combine them on the same graph?

amonsie
  • 15
  • 4

2 Answers2

0

One way to do it:

ggplot(Group1, aes(x=time, group=Strain)) +
  geom_line(aes(y=OD600.x), colour="green") +
  geom_line(aes(y=OD600.y), colour="red") +
  facet_wrap(~Strain)
geoff
  • 942
  • 5
  • 13
0

The column names are a bit difficult to understand, but here's an idea. This makes your data longer, repeating each time period for each strain twice, with one observation for the OD600.x variable and another observation for the OD600.y variable.

graphing_group_1 <- pivot_longer(Group1, names_to = "condition_type", values_to = "condition_value")

ggplot(graphing_group_1) +
geom_line(aes(x = time, y = condition_value, color = condition_type, group = Strain))
bash1000
  • 191
  • 3