Differential Analysis

library(LorMe)

What we can get in Differential Analysis from LorMe?

LorMe provides three types of differential analysis, including DESeq, Indicator species, and Ranked sum test. Corresponding visualizations include Volcano plot (for DESeq and Indicator species analysis), Manhattan plot (for DESeq and Indicator species analysis), and Differential bar plot (for Ranked sum test).

All differential analyses are based on an encapsulated object (How to encapsulate)?

DESeq analysis

data("Two_group")
### DESeq analysis 
deseq_results <- Deseq_analysis(
  taxobj = Two_group,
  taxlevel = "Genus",
  cutoff = 1, #The log2 fold change cutoff for considering differential taxa
  control_name = "Control" #The name of the control group
  )
head(deseq_results,5)
##     baseMean log2FoldChange     lfcSE       stat    pvalue      padj  tag GenusID      Domain
## 1   5.333105     -1.2716641 0.9658908 -1.3165714 0.1879823 0.4542467 None  Genus1 d__Bacteria
## 2 297.307888      0.1050121 0.2344629  0.4478839 0.6542370 0.8307772 None  Genus2 d__Bacteria
## 3   1.286183     -2.4695795 2.9925539 -0.8252414 0.4092345 0.9990000 None  Genus3 d__Bacteria
## 4  22.622790      1.0533794 0.9776246  1.0774887 0.2812620 0.5829264 None  Genus4 d__Bacteria
## 5   0.526103     -1.9332492 2.8504589 -0.6782239 0.4976298 0.9990000 None  Genus5 d__Bacteria
##                      Phylum                     Class                           Order
## 1     d__Bacteria;p__norank    c__Candidatus Babeliae        o__Candidatus Babeliales
## 2 d__Bacteria;p__Unassigned d__Bacteria;c__Unassigned       d__Bacteria;o__Unassigned
## 3          p__Acidobacteria         c__Acidobacteriia c__Acidobacteriia;o__Unassigned
## 4          p__Acidobacteria         c__Acidobacteriia             o__Acidobacteriales
## 5          p__Acidobacteria         c__Acidobacteriia             o__Acidobacteriales
##                            Family                              Genus
## 1       f__Candidatus Babeliaceae               g__Candidatus Babela
## 2       d__Bacteria;f__Unassigned          d__Bacteria;g__Unassigned
## 3 c__Acidobacteriia;f__Unassigned    c__Acidobacteriia;g__Unassigned
## 4            f__Acidobacteriaceae f__Acidobacteriaceae;g__Unassigned
## 5            f__Acidobacteriaceae                      g__Acidicapsa

Indicator analysis

### Indicator analysis
indicator_results <- indicator_analysis(
  taxobj = Two_group,
  taxlevel = "Genus"
  )
## Calculating.......
head(indicator_results,5)
##   s.Control s.Treatment index       stat      padj GenusID      Domain
## 1         1           0     1 0.36853195 0.1708292  Genus1 d__Bacteria
## 2         1           0     1 0.02746601 0.9230769  Genus2 d__Bacteria
## 3         1           0     1 0.34188577 0.4315684  Genus3 d__Bacteria
## 4         0           1     2 0.37776299 0.1368631  Genus4 d__Bacteria
## 5         1           0     1 0.39067031 0.1918082  Genus5 d__Bacteria
##                      Phylum                     Class                           Order
## 1     d__Bacteria;p__norank    c__Candidatus Babeliae        o__Candidatus Babeliales
## 2 d__Bacteria;p__Unassigned d__Bacteria;c__Unassigned       d__Bacteria;o__Unassigned
## 3          p__Acidobacteria         c__Acidobacteriia c__Acidobacteriia;o__Unassigned
## 4          p__Acidobacteria         c__Acidobacteriia             o__Acidobacteriales
## 5          p__Acidobacteria         c__Acidobacteriia             o__Acidobacteriales
##                            Family                              Genus  tag     baseMean
## 1       f__Candidatus Babeliaceae               g__Candidatus Babela None 0.0002413849
## 2       d__Bacteria;f__Unassigned          d__Bacteria;g__Unassigned None 0.0130394158
## 3 c__Acidobacteriia;f__Unassigned    c__Acidobacteriia;g__Unassigned None 0.0001407605
## 4            f__Acidobacteriaceae f__Acidobacteriaceae;g__Unassigned None 0.0009565555
## 5            f__Acidobacteriaceae                      g__Acidicapsa None 0.0000238882

Volcano plot

#### Define color based on treatment column
mycolor <- Two_group$configuration$treat_col

#### Create volcano plot for DESeq results
volcano_plot <- volcano_plot(
  inputframe = deseq_results,
  cutoff = 1,
  aes_col = mycolor
  )
print(volcano_plot$FC_FDR)  # Fold Change and FDR values

print(volcano_plot$Mean_FC)  # Mean Fold Change values

#### Create volcano plot for indicator results
volcano_plot <- volcano_plot(
  inputframe = indicator_results,
  cutoff = 1,
  aes_col = mycolor
  )
print(volcano_plot$FC_FDR)  # Fold Change and FDR values

print(volcano_plot$Mean_FC)  # Mean Fold Change values

Manhattan Plot

### Indicator analysis ###
manhattan_object <- manhattan(
  inputframe = deseq_results, # Also available for 'indicator_results'
  taxlevel = "Phylum", #X-axis
  control_name = "Control",
  mode="most", #Three mode optional:'all','most','select' 
  top_n = 8, # Number to display for mode 'most'
  palette = "Plan7", #palette , optional
  rmprefix = "p__" #removed prefix, optional
  )
print(manhattan_object$manhattan)  # Tradition Manhattan plot

print(manhattan_object$manhattan_circle)  # Circular Manhattan plot

head(manhattan_object$sourcedata,5)  # Source data for plot
##       baseMean log2FoldChange     lfcSE       stat       pvalue         padj       tag GenusID
## 3    1.2861831      -2.469580 2.9925539 -0.8252414 4.092345e-01 9.990000e-01      None  Genus3
## 4   22.6227900       1.053379 0.9776246  1.0774887 2.812620e-01 5.829264e-01      None  Genus4
## 5    0.5261030      -1.933249 2.8504589 -0.6782239 4.976298e-01 9.990000e-01      None  Genus5
## 6    0.6379474      -2.772522 3.0056543 -0.9224356 3.563014e-01 9.990000e-01      None  Genus6
## 7 1272.6655729       2.218375 0.3710889  5.9780159 2.258717e-09 9.034868e-07 Treatment  Genus7
##        Domain        Phylum             Class                           Order
## 3 d__Bacteria Acidobacteria c__Acidobacteriia c__Acidobacteriia;o__Unassigned
## 4 d__Bacteria Acidobacteria c__Acidobacteriia             o__Acidobacteriales
## 5 d__Bacteria Acidobacteria c__Acidobacteriia             o__Acidobacteriales
## 6 d__Bacteria Acidobacteria c__Acidobacteriia             o__Acidobacteriales
## 7 d__Bacteria Acidobacteria c__Acidobacteriia             o__Acidobacteriales
##                            Family                              Genus
## 3 c__Acidobacteriia;f__Unassigned    c__Acidobacteriia;g__Unassigned
## 4            f__Acidobacteriaceae f__Acidobacteriaceae;g__Unassigned
## 5            f__Acidobacteriaceae                      g__Acidicapsa
## 6            f__Acidobacteriaceae                  g__Acidobacterium
## 7            f__Acidobacteriaceae           g__Candidatus Koribacter
print(manhattan_object$aes_color)  # Aesthetic color for plot
## [1] "#BC3C29" "#0072B5" "#E18727" "#20854E" "#7876B1" "#6F99AD" "#FFDC91" "#EE4C97"

Differential bar plot

diff_results <- differential_bar(
  taxobj = Two_group,
  taxlevel = "Genus",
  rel_threshold = 0.005, #Threshold filtering taxa for differential analysis, by default
  anno_row = "ID", # Displaying mode in y axis test, 'ID' or 'taxonomy', optional
  aes_col = mycolor, # color for aesthetics, optional
  limit_num = 10 # Number to limit displaying results, optional
  )
print(diff_results$Barplot)  # Print Barplot

head(diff_results$Barplot_sourcedata,5 )  # Show source data of barplot
##    GenusID Treatment        Mean
## 1   Genus7   Control 0.020461903
## 2 Genus155   Control 0.009611433
## 3 Genus308   Control 0.013227588
## 4 Genus350   Control 0.007938770
## 5 Genus613   Control 0.008715115
print(diff_results$Differenceplot)  # Print Differential errorbar plot

head(diff_results$Differenceplot_sourcedata, 5)  # Show source data of Differential errorbar plot
##     GenusID      p.value     estimate      conf.low    conf.high     Control   Treatment
## 2    Genus7 7.159511e-03 -0.063861857 -0.1045566547 -0.023167059 0.020461903 0.084323760
## 12 Genus155 3.302801e-05  0.004979139  0.0032029236  0.006755355 0.009611433 0.004632294
## 18 Genus308 2.821716e-03  0.006847143  0.0027929155  0.010901370 0.013227588 0.006380445
## 20 Genus350 3.230310e-03  0.004254209  0.0016807496  0.006827668 0.007938770 0.003684562
## 25 Genus613 2.633742e-03  0.002337949  0.0009648777  0.003711020 0.008715115 0.006377166
##            padj      Domain            Phylum                  Class               Order
## 2  0.0342065516 d__Bacteria  p__Acidobacteria      c__Acidobacteriia o__Acidobacteriales
## 12 0.0007101022 d__Bacteria p__Actinobacteria       c__Actinomycetia o__Streptomycetales
## 18 0.0198433353 d__Bacteria    p__Chloroflexi        c__Chloroflexia   o__Chloroflexales
## 20 0.0198433353 d__Bacteria     p__Firmicutes             c__Bacilli       o__Bacillales
## 25 0.0198433353 d__Bacteria p__Proteobacteria c__Alphaproteobacteria o__Hyphomicrobiales
##                  Family                    Genus       tag
## 2  f__Acidobacteriaceae g__Candidatus Koribacter Treatment
## 12 f__Streptomycetaceae          g__Streptomyces   Control
## 18    f__Roseiflexaceae           g__Kouleothrix   Control
## 20       f__Bacillaceae              g__Bacillus   Control
## 25 f__Hyphomicrobiaceae    g__Methyloceanibacter   Control
require(patchwork)
diff_results$Barplot|diff_results$Differenceplot