2

我正在分析一组多变量数据,首先将其与对照进行比较,然后比较不同的治疗方法。数据可以在这里找到。

为了与控件进行比较,我使用的是ggpubr

ggbarplot(s1, x = "media", y = c("Ca", "Cu", "Fe", "K", "Mg", "Mn", "Na", "P", "Zn"), combine =T, add = "mean_sd",order = "TAP", "TMP", "Ca", "Mg", "N", "P", "S", "Cu", "Fe", "Mn", "Zn"), ggtheme = theme_minimal())
        + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"))
        + labs(x = "Media", y = "Relative content (% of control)", title = unique(s1$strain), size=6) + stat_compare_means(label.x.npc = 0.1, label.y = 1.15*max(s1[,5:13],na.rm=T), size=3)
        + stat_compare_means(ref.group = "TAP", label = "p.signif", hide.ns=T, label.y = 1.05*max(s1[,5:13], na.rm=T), size = 3)

但是,当我进行成对比较时,我会分别进行每个分析

tri.to.squ <- function(x)
{
  rn<-row.names(x)
  cn<-colnames(x)
  an<-unique(c(cn,rn))
  myval <- x[!is.na(x)]
  mymat <- matrix(1,nrow=length(an),ncol=length(an),dimnames=list(an,an))
  for(ext in 1:length(cn))
  {
    for(int in 1:length(rn))
    {
      if(is.na(x[row.names(x)==rn[int],colnames(x)==cn[ext]])) next
      mymat[row.names(mymat)==rn[int],colnames(mymat)==cn[ext]] <- x[row.names(x)==rn[int],colnames(x)==cn[ext]]
      mymat[row.names(mymat)==cn[ext],colnames(mymat)==rn[int]] <- x[row.names(x)==rn[int],colnames(x)==cn[ext]]
    }

  }
  return(mymat)
}

pairwise.ca <- pairwise.wilcox.test(s1$Ca, s1$media, p.adjust.method = "none")
mymat <- tri.to.squ(pairwise.ca$p.value)
myletters <- multcompLetters(mymat, compare="<", threshold=0.05, Letters = letters)
Ca <- ggbarplot(s1, x = "media", y = "Ca", add = "mean_sd", ggtheme = theme_minimal())
        + labs(x = "Media", y = "Relative Ca content (% of control)", title = unique(s1$strain), size=6)
        + annotate("text", c(1:11),y =1.1*max(s1$Ca, na.rm=T), size = 2.5, label = myletters$Letters[])

然后我aggregate把所有的图表都放在一张里。但是,我想将成对比较添加到组合图中(如第一个代码中所示)。

有没有办法将 cld 添加到组合图中?

4

0 回答 0