Reputation: 5059
I have a dataset that looks like this:
chr1 chr2 chr3 chr4 chr5 chr6 chr7
0.036087058 0.1710794 0.07083756 0.9182151 0.1927984 0.0000000 0.12830954
0.004343812 0.1690745 0.14401409 0.4871753 0.2435876 0.1002418 0.70837558
0.045108822 0.7170632 0.14267753 0.2135151 0.6505695 0.7835569 0.07150584
0.000000000 0.2018202 0.19012533 0.5991120 0.5580128 0.6712861 0.23824141
0.000000000 0.2840185 0.16105520 0.6181579 0.7912422 0.2766674 0.34650258
0.024726317 0.2325610 0.14434823 0.2028226 0.2449242 0.3227787 0.49252151
I have read this data in R and have used following commands to plot it:
d1<-read.table("Tagcount_APL_284perChrom.txt", header=T, fill=T)
plot(d1$chr1)
Now, the thing is, I don't want only one variable plotted but all of the variables plotted in same plot one after the other. I know I can produce the plots individually and then merge them using editor but I believe there are neater ways to do it in R.
Please help.
Thank you
Upvotes: 0
Views: 47
Reputation: 15441
d1 <- read.table(text = " chr1 chr2 chr3 chr4 chr5 chr6 chr7
0.036087058 0.1710794 0.07083756 0.9182151 0.1927984 0.0000000 0.12830954
0.004343812 0.1690745 0.14401409 0.4871753 0.2435876 0.1002418 0.70837558
0.045108822 0.7170632 0.14267753 0.2135151 0.6505695 0.7835569 0.07150584
0.000000000 0.2018202 0.19012533 0.5991120 0.5580128 0.6712861 0.23824141
0.000000000 0.2840185 0.16105520 0.6181579 0.7912422 0.2766674 0.34650258
0.024726317 0.2325610 0.14434823 0.2028226 0.2449242 0.3227787 0.49252151",
header = TRUE)
matplot(d1, type = "l")
# change type to "p" for points.
# check ?matplot for how to change colure and point shapes, axis options etc.
EDIT
oh you mean like this
par(mfrow = c(2,4))
apply(d1, 1, plot)
Personally I would turn this data into long format (using melt) and plot using ggplot2
i.e.
library(ggpolot2)
library(plyr)
newd1 <- melt(d1)
ggplot(newd1 ... blah blah
Upvotes: 1