r - 如何在 R 中的 lapply 中输入变量作为图表的 ggtitle 的一部分?
问题描述
我有一个 lapply 函数,它将我的绘图函数应用于 qList 列表中的每个元素(每个元素都是一个数据表)。每个元素也已经是疾病的名称。
volcanoList <- lapply(unique(qList),
function(x) volcanoGraph(x))
火山图函数是以下标准 ggplot 函数:
volcanoGraph <- function(dataSetOrdered) {
ggplot(dataSetOrdered) +
geom_point(aes(x=MeanDiff, y=-log10(qColumn), colour=threshold)) +
geom_text_repel(aes(x = MeanDiff, y = -log10(qColumn), label=
ifelse(geneLabels %in% 1:10 == T | minDiff %in% 1:10 == T | maxDiff %in%
1:10 == T, geneMutCount,""))) +
xlab("WT - Mutation Mean Difference") +
ylab("-log10 adjusted q-value") +
#scale_y_continuous(limits = c(0,50)) +
theme(legend.position = "none",
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = rel(1.25)))
}
截至目前,它没有附加 ggtitle,因为我不知道如何根据每个元素对应的疾病(基于元素名称)为每个元素制作标题。作为预期的输出,我想为每个图标记标题:“图(在此处插入元素名称)”。
解决方案
推荐阅读
- apache - 并发 apache 请求导致 net::ERR_CONTENT_LENGTH_MISMATCH
- sql - 在 SQL 中的当前记录之前加入一条记录
- typescript - vue 3 composition api props function 无法调用可能是“未定义”的对象
- r - ML:在 R 中保存 preproc 模型
- c# - 更改 System.Type 在 Serilog 中的序列化方式
- sass - 在 SASS 中使用负值的最佳实践
- c# - 如何在滑动视图中获取当前项目
- apache-kafka - 枚举字段的向后兼容性
- python - 使用rich.console 会自动格式化一些数字,如何防止这种情况发生?
- python - 在 Python 中用小数四舍五入