Package install

Packages <- c("tidyverse", "car", "dunn.test","onewaytests","FSA")
lapply(Packages, library, character.only = TRUE)

Data import

d1<- read.csv("/Users/koho0/Desktop/fig1_female mTor ratio.csv")

Data structure

str(d1)
## 'data.frame':    14 obs. of  3 variables:
##  $ subject: int  1 2 3 4 5 6 7 8 9 10 ...
##  $ group  : Factor w/ 3 levels "rapamycin+sevoflurane",..: 2 2 2 2 3 3 3 3 3 1 ...
##  $ ratio  : num  0.739 0.823 1.049 1.39 2.365 ...

Explorative data analysis with graphics

Easystat function developed by S. Park (available at https://rpubs.com/goodlebang)

easystat=function(d1){
  d1=data.frame(d1) # dataframe으로 전환
  d1[,2]=as.factor(d1[,2]) # 2행을 factor변수로 변환
  lmd=lm(d1[,3]~d1[,2],data=d1) # 선형모형
  swd=shapiro.test(lmd$resid) # 정규성 검정
  if (swd$p.value<0.05){      # p-value가 0.05보다 작다면(정규성 가정 위반)
    cat("1. Normality assumption test by Shapiro_Wilk test is", "\n",
        "p =", paste(format(round(swd$p.value,3), nsamll=3)), "\n",
        "Normality assumption was rejected", "\n")   #
    kwd=kruskal.test(d1[,3]~d1[,2],data=d1)             # 비모수 검정인 KW test 시행
    if (kwd$p.value<0.05){                           # KW test결과가 유의하게 나온 경우
      cat("2. The result of Kruskall_Wallis test:","\n",
          "p =", paste(format(round(kwd$p.value,3), nsmall=3)), "\n",
           "A statistically significant difference exist between groups")
      DT = dunnTest(d1[,3] ~ d1[,2],data=d1,method="bh") 
      DT
    } else {                                        #
      cat( "2. The result of Kruskall_Wallis test:","\n",
           "p =", paste(format(round(kwd$p.value,3), nsmall=3)), "\n",
           "A statistically significant difference do not exist between groups")
    }
  } 
  else {                      # 정규성 가정을 만족하는 경우
    cat("1. Normality assumption test by Shapiro_Wilk test is", "\n",
        "p =", paste(format(round(swd$p.value,3), nsamll=3)), "\n",
        "Normality assumption was not rejected", "\n")     # 
    bnt=bartlett.test(d1[,3]~d1[,2],data=d1)                  # 등분산성 검정
    if (bnt$p.value<0.05) {                                # 등분산성 가정을 만족하지 않은 경우
      cat("2. Equal variance test by Bartlett test is", "\n",   # 만족하지 못했다고 출력
          "p =", paste(format(round(bnt$p.value,3), nsmall=3)), "\n",
          "Equal variance assumption was rejected","\n")
      wtd=oneway.test(d1[,3]~d1[,2], data=d1, na.action=na.omit, var.equal=FALSE)          # 등분산성 가정을 만족하지 못했기 때문에 Welch anova 시행
      if (wtd$p.value<0.05) {                              # welch anova가 유의하게 나온경우
        cat("3. The result of Welch ANOVA is", "\n",
            "p =", paste(format(round(wtd$p.value,3), nsmall=3)), "\n",
            "A statistically significant difference exist between groups")
        md2=aov(d1[,3]~d1[,2])
      summary(md2)
      library(moonBook)
        paov=comma(summary(md2)[[1]][[1, "Pr(>F)"]])
        TukeyHSD(md2)
      } 
      else {                                             # Welch anova가 유의하지 않은 경우
        cat("3. The result of Welch ANOVA is",  "\n",   # 
            "p =", paste(format(round(wtd$p.value,3), nsmall=3)), "\n",
            "A statistically significant difference do not exist between groups")
      }
    } else {                                               #
      cat("2. Equal variance test by Bartlett test is", "\n",   # 등분산 가정을 만족했다고 출력
          "p =", paste(format(round(bnt$p.value,3), nsmall=3)), "\n",
          "Equal variance assumption was not rejected","\n")
      md2=aov(d1[,3]~d1[,2],data=d1)
      summary(md2)
      library(moonBook)
        paov=comma(summary(md2)[[1]][[1, "Pr(>F)"]])# anova

      if(paov<0.05) {                               # 결과가 유의한 경우
        cat("3. The result of anova is",  "\n",
            "p =", paste(round(as.numeric(paov),3)), "\n",
            "A statistically significant difference exist between groups")
     TukeyHSD(md2) } 
        
        else{                                              # 결과가 유의하지 않은 경우
        cat("3. The result of anova is", "\n",
            "p =",paste(sprintf("%.4f",as.numeric(paov))), "\n",
         
                       "A statistically significant difference do not exist between groups")
          }
    }
  }
}

Statistical Result

easystat(d1)
## 1. Normality assumption test by Shapiro_Wilk test is 
##  p = 0.991 
##  Normality assumption was not rejected 
## 2. Equal variance test by Bartlett test is 
##  p = 0.761 
##  Equal variance assumption was not rejected 
## 3. The result of anova is 
##  p = 0.0001 
##  A statistically significant difference do not exist between groups