r - 在不使用 ggplot 的情况下标记图 R 中的特定数据点
问题描述
这是我的示例数据:
genes logFC PValue
1 Arhgap8 -5.492152 2.479473e-99
2 Asns -2.519970 2.731718e-93
3 Bmp4 -1.663583 4.767201e-72
4 Casp1 -1.650139 2.212689e-25
5 Ctgf -1.272772 1.000103e-61
6 Eya4 -2.328052 2.077364e-68
到目前为止我的情节代码:
plot(sample$logFC,-log10(as.numeric(sample$PValue)),pch = 20,xlab = 'Log2 FoldChange',ylab = '-Log10 p-value',col = 'blue',xlim = c(-10,8),ylim = c(0,300),cex.lab=1.5, cex.axis=1.5)
points(sample$logFC,-log10(as.numeric(sample$PValue)),col = "dark green")
with(subset(sample,genes=='Arhgap8'),points(logFC,-log10(as.numeric(PValue)),pch = 20, col="orange"))
我试过使用下面的命令,包括文本;但它没有显示标签。
with(subset(sample,genes=='Arhgap8'),points(logFC,-log10(as.numeric(PValue)),pch = 20, col="violet"),text(sample,labels = sample$genes,cex = 0.9,pos = 4))
解决方案
with
用于运行命令的正确方法是
with(subset(sample, genes=='Arhgap8'), {
points(logFC, -log10(as.numeric(PValue)), pch = 20, col="violet")
text(logFC, -log10(as.numeric(PValue)), labels = genes, cex = 0.9, pos = 4)
})
当您使用 传递更多参数时with()
,它们会被默默地忽略。例如
with(iris, mean(Sepal.Length), stop("not run"))
推荐阅读
- python - 根据数据框Python中的列数在一张图上绘制多个直方图
- sql-server - 从存储过程中引用另一个 SQL Server 实例时遇到问题 (SQL Server 2016)
- javascript - 使用 Javascript 显示更改的 div 宽度
- css - 如何在 Reactjs 中导出具有样式的无状态功能组件
- git - Windows ssh 代理转发和 cap\git 部署问题
- networking - 我可以为我的 GKE 集群分配什么有效的 cidr?
- ruby-on-rails - rails 5.2 如何在控制器中获取表单数据值
- git - git合并后打字稿更改未编译
- c - getenv 返回受污染的字符串内容
- php - Wordpress:突出显示活动/选定的菜单项 CSS/PHP