I have a dataset with the number of reads for more than 3000 organisms obtained on 3 different stages of experiment. The data looks something like this:
rain day0 day7
org1 923857 505062 503292
org2 424002 198440 26314
org3 2910 1492 535
...with 3000 more rows trailing this.
I want to plot the trend (number of reads) for each organism across different stages.. (start, day0, day7). Each organism should be represented with a different color and all should be in the same plot.
I have tried doing the same in excel but it has a limit of only 255 such lines in a single plot.
Is there a way of doing this in R? I am new to R and therefore don't know much. I think ggplot might work but I'm having hard time understanding how to use it on this data.
Any help is greatly appreciated. Thanks.
Here is a version using library(tidyverse)
I created a data.frame based upon the data you provided,
gather
these variables to put the data into a long format,
changed the factor levels so that they align with the plot you provided,
and used ggplot
to produce a figure.
data.frame(org = letters[1:3],
rain = c(923857, 424002, 2910),
day0 = c(505062, 198440, 1492),
day7 = c(503292, 2614, 535)) %>%
gather(variable, value, -org) %>%
mutate(variable = factor(variable, levels = c('rain', 'day0', 'day7'))) %>%
ggplot(aes(variable, value, color = org, group = org)) +
geom_point() +
geom_line() +
theme(legend.position="bottom")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.