我找到了许多类似的答案,但是我无法将它们与我的例子联系起来。请指出正确的帖子(如果已经存在)。在此示例中,我具有来自两个不同重复样本的三个不同基因(称为系列)。
我正在尝试以相同的颜色绘制不同的线型并结合点的每个基因。如果我跳过geom_line()
,此代码几乎可以工作。但是我不明白错误消息:
library(dplyr)
library(ggplot2)
combined %>%
ggplot(combined, aes(x=Time, y=Count)) +
geom_point(data=combined %>%
filter(str_detect(gene, "asmbl")), aes(color=Series)) +
geom_line(data=combined %>%
filter(str_detect(gene, "asmbl")), aes(color=Series, group=Series)) +
geom_point(data=combined %>%
filter(str_detect(gene, "Sarc4_g23851T")), aes(color=gene)) +
geom_point(data=combined %>%
filter(str_detect(gene, "Sarc4_g23850T")), aes(color=gene))
数据:
combined <- structure(list(gene = c("align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "align_id:186820|asmbl_31839",
"align_id:186820|asmbl_31839", "Sarc4_g23851T", "Sarc4_g23851T",
"Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T",
"Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T",
"Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T",
"Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T", "Sarc4_g23851T",
"Sarc4_g23851T", "Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T",
"Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T",
"Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T",
"Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T",
"Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T", "Sarc4_g23850T"
), Time = c("12", "18", "24", "30", "36", "42", "48", "54", "60",
"66", "12", "18", "24", "30", "36", "42", "54", "60", "66", "12",
"18", "24", "30", "36", "42", "48", "54", "60", "66", "12", "18",
"24", "30", "36", "42", "54", "60", "66", "12", "18", "24", "30",
"36", "42", "48", "54", "60", "66", "12", "18", "24", "30", "36",
"42", "54", "60", "66"), Count = c(36.5856, 29.1905, 9.5834,
18.1533, 15.9757, 141.075, 164.396, 286.494, 313.51, 297.194,
31.524, 22.48, 22.8498, 13.5205, 55.9709, 229.88, 401.08, 533.74,
584.868, 23.6579, 28.139, 28.0263, 30.5701, 33.4486, 33.3998,
33.2913, 29.0451, 26.0574, 22.2455, 24.2018, 22.9098, 28.4843,
27.5675, 26.5617, 24.9472, 27.3172, 22.1812, 19.7493, 7.02732,
7.83637, 5.9542, 5.6151, 7.51841, 7.36599, 7.39079, 6.70167,
4.81567, 3.46868, 7.14292, 5.1345, 5.30578, 5.16931, 4.71502,
5.60258, 5.87787, 4.24783, 3.81306), Series = c("BT", "BT", "BT",
"BT", "BT", "BT", "BT", "BT", "BT", "BT", "CT", "CT", "CT", "CT",
"CT", "CT", "CT", "CT", "CT", "BT", "BT", "BT", "BT", "BT", "BT",
"BT", "BT", "BT", "BT", "CT", "CT", "CT", "CT", "CT", "CT", "CT",
"CT", "CT", "BT", "BT", "BT", "BT", "BT", "BT", "BT", "BT", "BT",
"BT", "CT", "CT", "CT", "CT", "CT", "CT", "CT", "CT", "CT")), row.names = c(NA,
-57L), class = c("tbl_df", "tbl", "data.frame"))