次のようなRスクリプトがあります。
library(ggplot2)
df <- read.table("path/to/file.txt", header=TRUE)
df$seq <- 1:nrow(df)
p1 <- qplot(x=ref_PA,y=RMSD,data=df) + geom_line()
print(p1)
次に、次のようなデータをプロットします。
問題は、ドットがx軸に表示される順序で接続されていることですseq
.データフレームで生成された列を介してドットを接続する方法はありますか( df
)
私のデータフレームのサンプルは次のようになります。
> head(df)
ref_pdb next_pdb RMSD ref_PA next_PA delta_PA seq
1 1qiv 1lin 0.5879 1337 1388 51 1
2 1lin 1a29 0.3970 1388 1362 26 2
3 1a29 3ewt 1.1926 1362 1380 18 3
4 3ewt 3ewv 1.2140 1380 1412 32 4
5 3ewv 3gof2 1.6565 1412 1418 6 5
6 3gof2 3gof1 0.3080 1418 1419 1 6
皆さんが再現可能な例を愛していることは知っているので、ここに私のデータフレームとseq
列があります:
structure(list(ref_pdb = structure(c(13L, 8L, 1L, 42L, 43L, 45L,
44L, 15L, 14L, 20L, 16L, 17L, 18L, 10L, 9L, 30L, 28L, 21L, 23L,
22L, 33L, 46L, 49L, 4L, 32L, 40L, 24L, 25L, 38L, 7L, 31L, 29L,
27L, 26L, 39L, 6L, 19L, 11L, 47L, 48L, 41L, 2L, 36L, 37L, 50L,
3L, 12L, 5L, 34L, 35L, 51L, 52L), .Label = c("1a29", "1cll",
"1clm", "1cm1", "1exr", "1ggz", "1iq5", "1lin", "1mxe1", "1mxe2",
"1ooj", "1osa", "1qiv", "1qiw1", "1qiw2", "1qs71", "1qs72", "1qtx",
"1rfj", "1vrk", "1wrz", "1yr5", "1zuz", "2f3y", "2f3z", "2ix71",
"2ix72", "2k0j", "2k61", "2l7l", "2lgf", "2o5g", "2o60", "2r281",
"2r282", "2v01", "2v02", "2vay", "2ygg", "3bxl", "3cln", "3ewt",
"3ewv", "3gof1", "3gof2", "3gp2", "3sjq1", "3sjq2", "3sui", "4cln",
"4g27", "4g28"), class = "factor"), next_pdb = structure(c(9L,
1L, 42L, 43L, 45L, 44L, 15L, 14L, 20L, 16L, 17L, 18L, 11L, 10L,
30L, 28L, 21L, 23L, 22L, 33L, 46L, 49L, 4L, 32L, 40L, 24L, 25L,
38L, 8L, 31L, 29L, 27L, 26L, 39L, 7L, 19L, 12L, 47L, 48L, 41L,
2L, 36L, 37L, 50L, 3L, 13L, 5L, 34L, 35L, 51L, 52L, 6L), .Label = c("1a29",
"1cll", "1clm", "1cm1", "1exr", "1g4y", "1ggz", "1iq5", "1lin",
"1mxe1", "1mxe2", "1ooj", "1osa", "1qiw1", "1qiw2", "1qs71",
"1qs72", "1qtx", "1rfj", "1vrk", "1wrz", "1yr5", "1zuz", "2f3y",
"2f3z", "2ix71", "2ix72", "2k0j", "2k61", "2l7l", "2lgf", "2o5g",
"2o60", "2r281", "2r282", "2v01", "2v02", "2vay", "2ygg", "3bxl",
"3cln", "3ewt", "3ewv", "3gof1", "3gof2", "3gp2", "3sjq1", "3sjq2",
"3sui", "4cln", "4g27", "4g28"), class = "factor"), RMSD = c(0.5879,
0.397, 1.1926, 1.214, 1.6565, 0.308, 1.736, 1.2785, 1.8785, 0.8899,
0.7611, 1.7691, 1.9543, 0.3456, 1.6468, 1.9575, 1.2693, 0.6397,
0.8545, 2.1215, 2.0911, 1.4976, 2.312, 2.3692, 2.6759, 2.0306,
0.4719, 0.7809, 1.6036, 2.2123, 3.8186, 9.2451, 2.4978, 14.0809,
2.1417, 2.1248, 1.6743, 1.2079, 0.2223, 1.2878, 0.2746, 0.5786,
0.5356, 0.6444, 0.7692, 0.3618, 0.4772, 2.1024, 1.1866, 22.9332,
0.2094, 0.8705), ref_PA = c(1337, 1388, 1362, 1380, 1412, 1418,
1419, 1384, 1425, 1493, 1423, 1426, 1508, 1436, 1438, 1476, 1484,
1512, 1466, 1504, 1507, 1456, 1441, 1413, 1510, 1432, 1499, 1463,
1432, 1465, 1475, 1469, 1499, 1486, 1647, 1635, 1634, 1571, 1637,
1638, 1623, 1627, 1596, 1602, 1641, 1631, 1677, 1652, 1577, 1603,
1649, 1645), next_PA = c(1388, 1362, 1380, 1412, 1418, 1419,
1384, 1425, 1493, 1423, 1426, 1508, 1436, 1438, 1476, 1484, 1512,
1466, 1504, 1507, 1456, 1441, 1413, 1510, 1432, 1499, 1463, 1432,
1465, 1475, 1469, 1499, 1486, 1647, 1635, 1634, 1571, 1637, 1638,
1623, 1627, 1596, 1602, 1641, 1631, 1677, 1652, 1577, 1603, 1649,
1645, 1653), delta_PA = c(51, 26, 18, 32, 6, 1, 35, 41, 68, 70,
3, 82, 72, 2, 38, 8, 28, 46, 38, 3, 51, 15, 28, 97, 78, 67, 36,
31, 33, 10, 6, 30, 13, 161, 12, 1, 63, 66, 1, 15, 4, 31, 6, 39,
10, 46, 25, 75, 26, 46, 4, 8), seq = 1:52), .Names = c("ref_pdb",
"next_pdb", "RMSD", "ref_PA", "next_PA", "delta_PA", "seq"), row.names = c(NA,
-52L), class = "data.frame")