【发布时间】:2022-08-19 16:11:58
【问题描述】:
考虑以下示例,其中制作了一个散点图,并且只有“重要”点被着色和标记。
genes <- read.table(\"https://gist.githubusercontent.com/stephenturner/806e31fce55a8b7175af/raw/1a507c4c3f9f1baaa3a69187223ff3d3050628d4/results.txt\", header = TRUE)
genes$Significant <- ifelse(genes$padj < 0.05, \"FDR < 0.05\", \"Not Sig\")
ggplot(genes, aes(x = log2FoldChange, y = -log10(pvalue))) +
geom_point(aes(color = Significant)) +
scale_color_manual(values = c(\"red\", \"grey\")) +
theme_bw(base_size = 12) + theme(legend.position = \"bottom\") +
geom_text_repel(
data = subset(genes, padj < 0.05),
aes(label = Gene),
size = 5,
box.padding = unit(0.35, \"lines\"),
point.padding = unit(0.3, \"lines\")
)
现在想象一下,标签实际上是首字母缩略词,并且它们有一个真正的全长名称(例如,\"DOK6\" 是 \"Duo Ocarino Kayne 6\" 的首字母缩写词)。是否可以在图中添加一个图例,其中键是图中使用的标签,条目是标签的全长名称?