У меня есть два data.frames (показано ниже)
originalData <- structure(list(Channel = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L
), Intensity = c(0.008, 0.01, 0, 0, 0, 0.003, 0.002, 0.006, 0.011,
0, 0.008, 0, 0, 0, 0, 0.017, 0.006, 0, 0, 0, 0.002, 0.002, 0,
0.002, 0.004, 0.008, 0, 0.001, 0.001, 0, 0.013, 0.007, 0, 0,
0.001, 0.002, 0.001, 0.004, 0, 0, 0.009, 0, 0.001, 0.001, 0,
0.011, 0.174, 0.013, 0, 0.227, 0.003, 0.003, 0.003, 0.253, 0,
0.009, 0, 0.002, 0.001, 0.001, 0.012, 0.003, 0.008, 0, 0, 0.003,
0.001, 0, 0, 0.005, 0.01, 0, 0.001, 0, 0, 0.015, 0.248, 0, 0.004,
0.243, 0.004, 0.004, 0.006, 0.185, 0.003, 0.008, 0, 0.002, 0.001,
0, 0.01, 0.203, 0.017, 0, 0.223, 0.004, 0.003, 0.008, 0.21, 0.007,
0.006, 0, 0.001, 0.002, 0.003, 0.199, 0.017, 0, 0.204, 0.01,
0.229, 0.201, 0.006, 0.003, 0.21, 0.195, 0.241, 0, 0.001, 0.219,
0.007, 0.222, 0.01, 0.006, 0.248, 0.003, 0.003, 0.007, 0.281,
0, 0.007, 0.006, 0.002, 0.001, 0, 0.226, 0.01, 0.012, 0.28, 0.002,
0.24, 0.271, 0.005, 0.007, 0.277, 0.254, 0.268, 0.001, 0, 0.27,
0.227, 0.004, 0, 0.289, 0.005, 0.255, 0.237, 0.009, 0.013, 0.257,
0.238, 0.237, 0, 0.001, 0.252, 0.02, 0.017, 0.242, 0.009, 0.008,
0.008, 0.007, 0.213, 0.009, 0.006, 0.012, 0.003, 0.216, 0.223,
0.005, 0.172, 0.01, 0.009, 0.191, 0.002, 0.227, 0.251, 0.001,
0.005, 0.215, 0.2, 0.236, 0, 0, 0.239, 0.019, 0.023, 0.211, 0.008,
0.012, 0.005, 0.006, 0.291, 0, 0.009, 0.012, 0, 0.277, 0.298,
0.004, 0.019, 0.022, 0.208, 0.01, 0.008, 0.005, 0.004, 0.204,
0.009, 0.002, 0.011, 0, 0.223, 0.209, 0.002, 0.022, 0.025, 0.27,
0, 0.012, 0.007, 0.006, 0.237, 0.011, 0.004, 0.012, 0.01, 0.273,
0.259, 0.003), PSM = c(11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L,
37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L,
22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L,
1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L,
10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L,
11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L,
51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L,
41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L,
38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L,
24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L,
7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L,
50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L,
47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L,
52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L,
45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L, 37L, 38L,
39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L, 22L, 24L,
37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L, 1L, 7L,
22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L, 11L, 47L, 10L, 50L,
1L, 7L, 22L, 24L, 37L, 38L, 39L, 41L, 45L, 51L, 52L), Prote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9H7Z6",
"Q9H9L4", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9H7Z6", "Q9H7Z6", "Q9P2N6",
"Q9P2N6", "Q9H9L4", "Q9H7Z6", "Q9P2N6", "Q9H9L4", "Q9P2N6", "Q9P2N6",
"Q9H7Z6", "Q9H9L4", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9H7Z6", "Q9H7Z6",
"Q9P2N6")), row.names = c(NA, -240L), class = "data.frame")
dataToAddLine <- structure(list(Channel = c(1L, 3L, 2L, 4L, 5L, 7L, 6L, 8L, 9L,
11L, 10L, 12L, 13L, 15L, 14L, 16L, 1L, 3L, 2L, 4L, 5L, 7L, 6L,
8L, 9L, 11L, 10L, 12L, 13L, 15L, 14L, 16L, 1L, 3L, 2L, 4L, 5L,
7L, 6L, 8L, 9L, 11L, 10L, 12L, 13L, 15L, 14L, 16L), Intensity = c(0.001,
0.001, 0.001, 0.001, 0.024, 0.018, 0.034, 0.027, 0.001, 0.025,
0.018, 0.001, 0.21, 0.216, 0.207, 0.215, 0.046, 0.037, 0.034,
0.019, 0.104, 0.108, 0.106, 0.108, 0.054, 0.05, 0.049, 0.044,
0.057, 0.062, 0.058, 0.062, 0.042, 0.043, 0.041, 0.04, 0.043,
0.043, 0.044, 0.043, 0.111, 0.115, 0.114, 0.113, 0.054, 0.053,
0.048, 0.052), ProteinName = c("Q9H7Z6", "Q9H7Z6", "Q9H7Z6",
"Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6",
"Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H7Z6", "Q9H9L4",
"Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4",
"Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4", "Q9H9L4",
"Q9H9L4", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6",
"Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6", "Q9P2N6",
"Q9P2N6", "Q9P2N6", "Q9P2N6")), class = "data.frame", row.names = c(NA,
-48L))
Я могу использовать первый data.frame для генерации графика ниже
ggplot (originalData, aes (Channel, Intensity, group = PSM)) + geom_line () +
facet_wrap (~ProteinName) +
stat_summary(aes(y = Intensity), fun.y=mean, colour="red", geom="line",group=1, size = 1) +
theme(axis.text.x = element_text(angle = 90))
Данные имеют три аспекта: помечены c («Q9H9L4», «Q9P2N6», «Q9H7Z6»). Я хотел бы использовать второй data.frame (dataToAddLine), чтобы добавить строку к каждому из трех аспектов. Обратите внимание, что этот второй data.frame имеет те же имена, которые задают фасеты координат оси x и y, что и первый data.frame