R ggplot geom_栏:如何按第二个元数据表中指定的组着色

R ggplot geom_栏:如何按第二个元数据表中指定的组着色,r,ggplot2,R,Ggplot2,我将此功能包含在软件包中: plot\u是否可以按样本名称将元数据连接到正在打印的单元格数据集,以便可以按数据集中的组织类型变量进行着色? plot_abundance <- function(exp, r = 0.6){ cell <- imsig(exp, r) cell$samples <- row.names(cell) cell$samples <- factor(cell$samples, levels = cell$samples) plot

我将此功能包含在软件包中:


plot\u是否可以按样本名称将元数据连接到正在打印的
单元格
数据集,以便可以按数据集中的组织类型变量进行着色?
plot_abundance <- function(exp, r = 0.6){
  cell <- imsig(exp, r)
  cell$samples <- row.names(cell)
  cell$samples <- factor(cell$samples, levels = cell$samples)
  plots = lapply(1:(ncol(cell)-1), function(x) ggplot(cell, aes(x = cell$samples, y =         cell[,x]))
                 + geom_bar(stat = "identity") + theme_classic() +
                   theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.title.y=element_blank())+
                   ggtitle(colnames(cell)[x]))
  do.call(grid.arrange,  plots)
}