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:
我在R中读过这些数据,并使用以下命令绘制它:
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.
现在,问题是,我不想只绘制一个变量,而是将所有变量一个接一个地绘制在同一个图中。我知道我可以单独制作这些图,然后使用编辑器将它们合并,但我相信在R中有更简洁的方法。
Please help.
请帮忙。
Thank you
谢谢
1 个解决方案
#1
1
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
我个人会将这些数据转换为长格式(使用融化)并使用ggplot2进行绘图
i.e.
即
library(ggpolot2)
library(plyr)
newd1 <- melt(d1)
ggplot(newd1 ... blah blah
#1
1
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
我个人会将这些数据转换为长格式(使用融化)并使用ggplot2进行绘图
i.e.
即
library(ggpolot2)
library(plyr)
newd1 <- melt(d1)
ggplot(newd1 ... blah blah