Phyloseq for GPA vs RA vs control

gene_x 0 like s 25 view s

Tags: R

http://xgenes.com/course/phyloseq2/

---
title: "Phyloseq microbiome"
author: ""
date: '`r format(Sys.time(), "%d %m %Y")`'
header-includes:
- \usepackage{color, fancyvrb}
output:
rmdformats::readthedown:
    highlight: kate
    number_sections : yes
pdf_document:
    toc: yes
    toc_depth: 2
    number_sections : yes
---
```{r, echo=FALSE, warning=FALSE}
## Global options
# IMPORTANT NOTE: needs before "mkdir figures"
# gunzip table_mc1300.biom.gz
#rmarkdown::render('Phyloseq.Rmd',output_file='Phyloseq.html')
#tmp/course/scripts.html, tmp/course/Phyloseq_GPA_RA.html, crs/urls
```

```{r load-packages, include=FALSE}
library(knitr)
library(rmdformats)
library(readxl)
library(dplyr)
library(kableExtra)
options(max.print="75")
knitr::opts_chunk$set(fig.width=8,
                    fig.height=6,
                    eval=TRUE,
                    cache=TRUE,
                    echo=TRUE,
                    prompt=FALSE,
                    tidy=TRUE,
                    comment=NA,
                    message=FALSE,
                    warning=FALSE)
opts_knit$set(width=85)
```

# Data
Import raw data and assign sample key:
```{r, echo=TRUE, warning=FALSE}
map_corrected <- read.csv("../map_corrected.txt", sep="\t", row.names=1)
knitr::kable(map_corrected) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
```
# Prerequisites to be installed
* R : https://pbil.univ-lyon1.fr/CRAN/
* R studio : https://www.rstudio.com/products/rstudio/download/#download
```R
install.packages("dplyr")     # To manipulate dataframes
install.packages("readxl")    # To read Excel files into R
install.packages("ggplot2")   # for high quality graphics
install.packages("heatmaply")
source("https://bioconductor.org/biocLite.R")
biocLite("phyloseq")
```
```{r libraries, echo=TRUE, message=FALSE}
library("readxl") # necessary to import the data from Excel file
library("ggplot2") # graphics
library("picante")
library("microbiome") # data analysis and visualisation
library("phyloseq") # also the basis of data object. Data analysis and visualisation
library("ggpubr") # publication quality figures, based on ggplot2
library("dplyr") # data handling, filter and reformat data frames
library("RColorBrewer") # nice color options
library("heatmaply")
library(vegan)
library(gplots)
```
# Read the data and create phyloseq objects
Three tables are needed
* OTU
* Taxonomy
* Samples
```{r, echo=TRUE, warning=FALSE}
    #Change your working directory to where the files are located
    ps.ng.tax <- import_biom("./table_mc1300.biom", "../clustering/rep_set.tre")
    sample <- read.csv("../map_corrected.txt", sep="\t", row.names=1)
    SAM = sample_data(sample, errorIfNULL = T)
    #rownames(SAM) <-
    #c("1","2","3","5","6","7","8","9","10","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","46","47","48","49","50","51","52","53","55")
    ps.ng.tax <- merge_phyloseq(ps.ng.tax, SAM)
    print(ps.ng.tax)
    colnames(tax_table(ps.ng.tax)) <- c("Domain","Phylum","Class","Order","Family","Genus","Species")
    saveRDS(ps.ng.tax, "./ps.ng.tax.rds")
```
Visualize data
```{r, echo=TRUE, warning=FALSE}
sample_names(ps.ng.tax)
rank_names(ps.ng.tax)
sample_variables(ps.ng.tax)
```
Normalize number of reads in each sample using median sequencing depth.
```{r, echo=TRUE, warning=FALSE}
# RAREFACTION
#set.seed(9242)  # This will help in reproducing the filtering and nomalisation.
#ps.ng.tax <- rarefy_even_depth(ps.ng.tax, sample.size = 42369)
#total <- 42369
# NORMALIZE number of reads in each sample using median sequencing depth.
total = median(sample_sums(ps.ng.tax))
#> total
#[1] 42369
standf = function(x, t=total) round(t * (x / sum(x)))
ps.ng.tax = transform_sample_counts(ps.ng.tax, standf)
ps.ng.tax_rel <- microbiome::transform(ps.ng.tax, "compositional")
saveRDS(ps.ng.tax, "./ps.ng.tax.rds")
hmp.meta <- meta(ps.ng.tax)
hmp.meta$sam_name <- rownames(hmp.meta)
```
# Heatmaps
We consider the most abundant OTUs for heatmaps. For example one can only take OTUs that represent at least 1% of reads in at least one sample. Remember we normalized all the sampples to median number of reads (total).  We are left with only 168 OTUS which makes the reading much more easy.
```{r, echo=TRUE, warning=FALSE}
# Custom function to plot a heatmap with the specified sample order
ps.ng.tax_abund <- phyloseq::filter_taxa(ps.ng.tax, function(x) sum(x > total*0.01) > 0, TRUE)
kable(otu_table(ps.ng.tax_abund)) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
# Calculate the relative abundance for each sample
ps.ng.tax_abund_rel <- transform_sample_counts(ps.ng.tax_abund, function(x) x / sum(x))
datamat_ = as.data.frame(otu_table(ps.ng.tax_abund))
#datamat <- datamat_[c("8","9","10","12","13","14",    "21","22","23","24","25","26","27","28",    "33","34","35","36","37","38","39","51",    "47","48","49","50","52","53","55")]
#--take all columns--
datamat <- datamat_
hr <- hclust(as.dist(1-cor(t(datamat), method="pearson")), method="complete")
hc <- hclust(as.dist(1-cor(datamat, method="spearman")), method="complete")
mycl = cutree(hr, h=max(hr$height)/1.08)
mycol = c("YELLOW", "DARKBLUE", "DARKORANGE", "DARKMAGENTA", "DARKCYAN", "DARKRED",  "MAROON", "DARKGREEN", "LIGHTBLUE", "PINK", "MAGENTA", "LIGHTCYAN","LIGHTGREEN", "BLUE", "ORANGE", "CYAN", "RED", "GREEN");
mycol = mycol[as.vector(mycl)]
sampleCols <- rep('GREY',ncol(datamat))
#Colors: '#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#cab2d6', '#6a3d9a'
#Control (19)
sampleCols[colnames(datamat)=='kg001'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg002'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg003'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg004'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg005'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg007'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg009'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg015'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg016'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg019'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg020'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg021'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg022'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg023'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg025'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg026'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg027'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg028'] <- '#1f78b4'
sampleCols[colnames(datamat)=='kg029'] <- '#1f78b4'
#GPA (21)
sampleCols[colnames(datamat)=='micro1'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro3'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro4'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro6'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro7'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro12'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro13'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro16'] <- '#33a02c'
sampleCols[colnames(datamat)=='micro17'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw001'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw004'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw005'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw006'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw007'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw009'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw010'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw013'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw014'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw015'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw017'] <- '#33a02c'
sampleCols[colnames(datamat)=='mw021'] <- '#33a02c'
# RA (20)
sampleCols[colnames(datamat)=='ra002'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra003'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra004'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra005'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra006'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra007'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra008'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra009'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra010'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra013'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra014'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra015'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra017'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra018'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra019'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra020'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra022'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra023'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra024'] <- '#e31a1c'
sampleCols[colnames(datamat)=='ra025'] <- '#e31a1c'

library(RColorBrewer)
custom_palette <- colorRampPalette(brewer.pal(9, "Blues"))
heatmap_colors <- custom_palette(100)
png("figures/heatmap.png", width=1200, height=2400)
heatmap.2(as.matrix(datamat),Rowv=as.dendrogram(hr),Colv = NA, dendrogram = 'row',
            scale='row',trace='none',col=heatmap_colors, cexRow=1.2, cexCol=1.5,
            RowSideColors = mycol, ColSideColors = sampleCols, srtCol=15, labRow=row.names(datamat), key=TRUE, margins=c(10, 15), lhei=c(0.7, 15), lwid=c(1,8))
dev.off()
```

```{r, echo=TRUE, warning=FALSE, fig.cap="Heatmap", out.width = '100%', fig.align= "center"}
knitr::include_graphics("./figures/heatmap.png")
```

\pagebreak
# Taxonomic summary
## Bar plots in phylum level
```{r, echo=TRUE, warning=FALSE}
library(ggplot2)
geom.text.size = 6
theme.size = 8 #(14/5) * geom.text.size
ps.ng.tax_most = phyloseq::filter_taxa(ps.ng.tax_rel, function(x) mean(x) > 0.001, TRUE)
ps.ng.tax_most_ = transform_sample_counts(ps.ng.tax_most, function(x) x / sum(x))
```

```{r, echo=FALSE, warning=FALSE}
##--Creating 100% stacked bar plots with less abundant taxa in a sub-category #901--
##https://github.com/joey711/phyloseq/issues/901
##ps.ng.tax_most_df <- psmelt(ps.ng.tax_most_)  #5986x19
#glom <- tax_glom(ps.ng.tax_most_, taxrank = 'Phylum')
#tax_table(glom) # should list # taxa as # phyla
#data <- psmelt(glom) # create dataframe from phyloseq object
#data$Phylum <- as.character(data$Phylum) #convert to character
##simple way to rename phyla with < 1% abundance
#data$Phylum[data$Abundance < 0.001] <- "< 0.1% abund."
#
#library(plyr)
#medians <- ddply(data, ~Phylum, function(x) c(median=median(x$Abundance)))
#remainder <- medians[medians$median <= 0.001,]$Phylum
#data[data$Phylum %in% remainder,]$Phylum <- "Phyla < 0.1% abund."
#data$Phylum[data$Abundance < 0.001] <- "Phyla < 0.1% abund."
##--> data are not used!
#
##in class level
#glom <- tax_glom(ps.ng.tax_most_, taxrank = 'Class')
#tax_table(glom) # should list # taxa as # phyla
#data <- psmelt(glom) # create dataframe from phyloseq object
#data$Class <- as.character(data$Class) #convert to character
#
##simple way to rename phyla with < 1% abundance
#data$Class[data$Abundance < 0.001] <- "< 0.1% abund."
#Count = length(unique(data$Class))
#
##unique(data$Class)
##data$Class <- factor(data$Class, levels = c("Bacilli", "Bacteroidia", "Verrucomicrobiae", "Clostridia", "Gammaproteobacteria", "Alphaproteobacteria", "Actinobacteria", "Negativicutes", "Erysipelotrichia", "Methanobacteria", "< 0.1% abund."))
##------- Creating 100% stacked bar plots END --------
library(stringr)
#FITTING_1:

#ps.ng.tax_most_
#OTU Table:          [63 taxa and 60 samples]
# tax_table(ps.ng.tax_most_)[1,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Domain"], "__")[[1]][2]
# ... ...
# tax_table(ps.ng.tax_most_)[63,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[167,"Species"], "__")[[1]][2]
#for id in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63; do
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Domain\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Domain\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Phylum\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Phylum\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Class\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Class\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Order\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Order\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Family\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Family\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Genus\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Genus\"], \"__\")[[1]][2]"
#  echo "tax_table(ps.ng.tax_most_)[${id},\"Species\"] <- str_split(tax_table(ps.ng.tax_most_)[${id},\"Species\"], \"__\")[[1]][2]"
#done

tax_table(ps.ng.tax_most_)[1,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[1,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[1,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[2,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[2,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[3,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[3,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[4,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[4,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[5,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[5,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[6,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[6,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[7,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[7,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[8,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[8,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[9,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[9,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[10,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[10,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[11,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[11,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[12,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[12,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[13,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[13,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[14,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[14,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[15,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[15,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[16,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[16,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[17,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[17,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[18,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[18,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[19,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[19,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[20,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[20,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[21,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[21,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[22,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[22,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[23,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[23,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[24,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[24,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[25,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[25,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[26,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[26,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[27,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[27,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[28,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[28,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[29,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[29,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[30,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[30,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[31,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[31,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[32,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[32,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[33,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[33,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[34,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[34,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[35,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[35,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[36,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[36,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[37,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[37,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[38,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[38,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[39,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[39,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[40,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[40,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[41,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[41,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[42,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[42,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[43,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[43,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[44,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[44,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[45,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[45,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[46,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[46,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[47,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[47,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[48,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[48,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[49,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[49,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[50,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[50,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[51,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[51,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[52,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[52,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[53,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[53,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[54,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[54,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[55,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[55,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[56,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[56,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[57,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[57,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[58,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[58,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[59,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[59,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[60,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[60,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[61,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[61,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[62,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[62,"Species"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Domain"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Phylum"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Class"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Order"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Family"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Genus"], "__")[[1]][2]
tax_table(ps.ng.tax_most_)[63,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[63,"Species"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Domain"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Domain"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Phylum"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Phylum"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Class"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Class"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Order"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Order"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Family"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Family"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Genus"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Genus"], "__")[[1]][2]
#tax_table(ps.ng.tax_most_)[64,"Species"] <- str_split(tax_table(ps.ng.tax_most_)[64,"Species"], "__")[[1]][2]
```

```{r, echo=TRUE, warning=FALSE}
plot_bar(ps.ng.tax_most_, fill="Phylum") + geom_bar(aes(), stat="identity", position="stack") +
scale_fill_manual(values = c("darkblue", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "lightskyblue", "darkgreen", "deeppink", "khaki2", "firebrick", "brown1", "darkorange1", "cyan1", "royalblue4", "darksalmon", "darkblue","royalblue4", "dodgerblue3", "steelblue1", "lightskyblue", "darkseagreen", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "brown1", "darkorange1", "cyan1", "darkgrey")) + theme(axis.text = element_text(size = 5, colour="black")) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=2))

ps.ng.tax_most_copied <- data.table::copy(ps.ng.tax_most_)
```

## Bar plots in class level
```{r, echo=TRUE, warning=FALSE}
plot_bar(ps.ng.tax_most_copied, fill="Class") + geom_bar(aes(), stat="identity", position="stack") +
scale_fill_manual(values = c("darkblue", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "lightskyblue", "darkgreen", "deeppink", "khaki2", "firebrick", "brown1", "darkorange1", "cyan1", "royalblue4", "darksalmon", "darkblue","royalblue4", "dodgerblue3", "steelblue1", "lightskyblue", "darkseagreen", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "brown1", "darkorange1", "cyan1", "darkgrey")) + theme(axis.text = element_text(size = 5, colour="black")) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=3))
```

## Bar plots in order level
```{r, echo=TRUE, warning=FALSE}
plot_bar(ps.ng.tax_most_copied, fill="Order") + geom_bar(aes(), stat="identity", position="stack") +
scale_fill_manual(values = c("darkblue", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "lightskyblue", "darkgreen", "deeppink", "khaki2", "firebrick", "brown1", "darkorange1", "cyan1", "royalblue4", "darksalmon", "darkblue","royalblue4", "dodgerblue3", "steelblue1", "lightskyblue", "darkseagreen", "darkgoldenrod1", "darkseagreen", "darkorchid", "darkolivegreen1", "brown1", "darkorange1", "cyan1", "darkgrey")) + theme(axis.text = element_text(size = 5, colour="black")) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=4))
```

## Bar plots in family level
```{r, echo=TRUE, warning=FALSE}
plot_bar(ps.ng.tax_most_copied, fill="Family") + geom_bar(aes(), stat="identity", position="stack") +
scale_fill_manual(values = c("#FF0000", "#000000", "#0000FF", "#C0C0C0", "#FFFFFF", "#FFFF00", "#00FFFF", "#FFA500", "#00FF00", "#808080", "#FF00FF", "#800080", "#FDD017", "#0000A0", "#3BB9FF", "#008000", "#800000", "#ADD8E6", "#F778A1", "#800517", "#736F6E", "#F52887", "#C11B17", "#5CB3FF", "#A52A2A", "#FF8040", "#2B60DE", "#736AFF", "#1589FF", "#98AFC7", "#8D38C9", "#307D7E", "#F6358A", "#151B54", "#6D7B8D", "#FDEEF4", "#FF0080", "#F88017", "#2554C7", "#FFF8C6", "#D4A017", "#306EFF", "#151B8D", "#9E7BFF", "#EAC117", "#E0FFFF", "#15317E", "#6C2DC7", "#FBB917", "#FCDFFF", "#15317E", "#254117", "#FAAFBE", "#357EC7")) + theme(axis.text = element_text(size = 5, colour="black")) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=8))
```


\pagebreak
# Alpha diversity
Plot Chao1 richness estimator, Observed OTUs, Shannon index, and Phylogenetic diversity.
Regroup together samples from the same group.
```{r, echo=FALSE, warning=FALSE}
# using rarefied data
#FITTING_2 (under CONSOLE):
#gunzip table_even4753.biom.gz
#alpha_diversity.py -i table_even42369.biom --metrics chao1,observed_otus,shannon,PD_whole_tree -o adiv_even.txt -t ../clustering/rep_set.tre
#alpha_diversity.py -i table_mc1300.biom --metrics chao1,observed_otus,shannon,PD_whole_tree -o adiv_even.txt -t ../clustering/rep_set.tre
```



```{r, echo=TRUE, warning=FALSE}
hmp.div_qiime <- read.csv("adiv_even.txt", sep="\t")
colnames(hmp.div_qiime) <- c("sam_name", "chao1", "observed_otus", "shannon", "PD_whole_tree")
row.names(hmp.div_qiime) <- hmp.div_qiime$sam_name
div.df <- merge(hmp.div_qiime, hmp.meta, by = "sam_name")
div.df2 <- div.df[, c("SampleType", "chao1", "shannon", "observed_otus", "PD_whole_tree")]
colnames(div.df2) <- c("Group", "Chao-1", "Shannon", "OTU", "Phylogenetic Diversity")
options(max.print=999999)
knitr::kable(div.df2) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
#https://uc-r.github.io/t_test
#We can perform the test with t.test and transform our data and we can also perform the nonparametric test with the wilcox.test function.
stat.test.Shannon <- compare_means(
Shannon ~ Group, data = div.df2,
method = "t.test"
)
knitr::kable(stat.test.Shannon) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
div_df_melt <- reshape2::melt(div.df2)
#head(div_df_melt)
#https://plot.ly/r/box-plots/#horizontal-boxplot
#http://www.sthda.com/english/wiki/print.php?id=177
#https://rpkgs.datanovia.com/ggpubr/reference/as_ggplot.html
#http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/82-ggplot2-easy-way-to-change-graphical-parameters/
#https://plot.ly/r/box-plots/#horizontal-boxplot
#library("gridExtra")
#par(mfrow=c(4,1))
p <- ggboxplot(div_df_melt, x = "Group", y = "value",
            facet.by = "variable",
            scales = "free",
            width = 0.5,
            fill = "gray", legend= "right")
#ggpar(p, xlab = FALSE, ylab = FALSE)

lev <- levels(factor(div_df_melt$Group)) # get the variables
#Using my_stat_compare_means (see https://stackoverflow.com/questions/47839988/indicating-significance-with-ggplot2-in-a-boxplot-with-multiple-groups)
L.pairs <- combn(seq_along(lev), 2, simplify = FALSE, FUN = function(i) lev[i]) #%>% filter(p.signif != "ns")
my_stat_compare_means  <- function (mapping = NULL, data = NULL, method = NULL, paired = FALSE,
    method.args = list(), ref.group = NULL, comparisons = NULL,
    hide.ns = FALSE, label.sep = ", ", label = NULL, label.x.npc = "left",
    label.y.npc = "top", label.x = NULL, label.y = NULL, tip.length = 0.03,
    symnum.args = list(), geom = "text", position = "identity",
    na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)
{
    if (!is.null(comparisons)) {
        method.info <- ggpubr:::.method_info(method)
        method <- method.info$method
        method.args <- ggpubr:::.add_item(method.args, paired = paired)
        if (method == "wilcox.test")
            method.args$exact <- FALSE
        pms <- list(...)
        size <- ifelse(is.null(pms$size), 0.3, pms$size)
        color <- ifelse(is.null(pms$color), "black", pms$color)
        map_signif_level <- FALSE
        if (is.null(label))
            label <- "p.format"
        if (ggpubr:::.is_p.signif_in_mapping(mapping) | (label %in% "p.signif")) {
            if (ggpubr:::.is_empty(symnum.args)) {
                map_signif_level <- c(`****` = 1e-04, `***` = 0.001,
                `**` = 0.01, `*` = 0.05, ns = 1)
            } else {
            map_signif_level <- symnum.args
            }
            if (hide.ns)
                names(map_signif_level)[5] <- " "
        }
        step_increase <- ifelse(is.null(label.y), 0.12, 0)
        ggsignif::geom_signif(comparisons = comparisons, y_position = label.y,
            test = method, test.args = method.args, step_increase = step_increase,
            size = size, color = color, map_signif_level = map_signif_level,
            tip_length = tip.length, data = data)
    } else {
        mapping <- ggpubr:::.update_mapping(mapping, label)
        layer(stat = StatCompareMeans, data = data, mapping = mapping,
            geom = geom, position = position, show.legend = show.legend,
            inherit.aes = inherit.aes, params = list(label.x.npc = label.x.npc,
                label.y.npc = label.y.npc, label.x = label.x,
                label.y = label.y, label.sep = label.sep, method = method,
                method.args = method.args, paired = paired, ref.group = ref.group,
                symnum.args = symnum.args, hide.ns = hide.ns,
                na.rm = na.rm, ...))
    }
}

#FITTING_3: #> Using lev ("control", "GPA", "RA") for definition of the following comparisons.
  #comparisons = L.pairs,
  #symnum.args <- list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05), symbols = c("****", "***", "**", "*")),
p3 <- p +
stat_compare_means(
  method="t.test",
  comparisons = list(c("GPA", "control"), c("RA", "control"), c("GPA", "RA")),
  label = "p.signif",
  symnum.args <- list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1), symbols = c("****", "***", "**", "*", "ns"))
)
#stat_pvalue_manual
#print(p2)
#https://stackoverflow.com/questions/20500706/saving-multiple-ggplots-from-ls-into-one-and-separate-files-in-r
#FITTING_4: mkdir figures
ggsave("./figures/alpha_diversity_SampleType.png", device="png", height = 10, width = 12)
ggsave("./figures/alpha_diversity_SampleType.svg", device="svg", height = 10, width = 12)
```


# Selected alpha diversity
```{r, echo=TRUE, warning=FALSE, fig.cap="Alpha diversity", out.width = '100%', fig.align= "center"}
knitr::include_graphics("./figures/alpha_diversity_SampleType.png")
#FITTING_5: Preparing the file selected_alpha_diversities.txt
#selected_alpha_diversities<-read.csv("selected_alpha_diversities.txt",sep="\t")
#knitr::kable(selected_alpha_diversities) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
```


# Beta diversity (weighted_unifrac)
```{r, echo=TRUE, warning=FALSE, fig.cap="Beta diversity", out.width = '100%', fig.align= "center"}
# The tests of significance were performed using a two-sided Student's two-sample t-test.
# Alternative hypothesis: Group 1 mean != Group 2 mean
# The nonparametric p-values were calculated using 999 Monte Carlo permutations.
# The nonparametric p-values contain the correct number of significant digits.
# Entries marked with "N/A" could not be calculated because at least one of the groups
# of distances was empty, both groups each contained only a single distance, or
# the test could not be performed (e.g. no variance in groups with the same mean).
# PREPARING_FILES: cp bdiv_even1300_SampleType/weighted_unifrac_boxplots/SampleType_Stats.txt bdiv_even1300_SampleType/weighted_unifrac_boxplots/SampleType_Stats_.txt and delete all headers, add # before "Group 1".
#                  cp bdiv_even1300_SampleType/unweighted_unifrac_boxplots/SampleType_Stats.txt bdiv_even1300_SampleType/unweighted_unifrac_boxplots/SampleType_Stats_.txt and delete all headers, add # before "Group 1".
#file:///home/jhuang/DATA/Data_Marius_16S/core_diversity_e42369/bdiv_even42369_Group/unweighted_unifrac_boxplots/Group_Stats.txt
weighted_unifrac_stats<-read.csv(file="bdiv_even1300_SampleType/weighted_unifrac_boxplots/SampleType_Stats_.txt", sep="\t")
knitr::kable(weighted_unifrac_stats) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
#BUG:How to generate the plot?  knitr::include_graphics("./figures/PCoA_weighted_unifrac.png")
```

# Beta diversity (unweighted_unifrac)
```{r, echo=TRUE, warning=FALSE, fig.cap="Beta diversity", out.width = '100%', fig.align= "center"}
#file:///home/jhuang/DATA/Data_Marius_16S/core_diversity_e42369/bdiv_even42369_Group/unweighted_unifrac_boxplots/Group_Stats.txt
unweighted_unifrac_stats<-read.csv(file="bdiv_even1300_SampleType/unweighted_unifrac_boxplots/SampleType_Stats_.txt", sep="\t")
knitr::kable(unweighted_unifrac_stats) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
#BUG:How to generate the plot?  knitr::include_graphics("./figures/PCoA_unweighted_unifrac.png")
```

# Differential abundance analysis
Differential abundance analysis aims to find the differences in the abundance of each taxa between two groups of samples, assigning a significance value to each comparison.
## GPA vs control
```{r, echo=TRUE, warning=FALSE}
library("DESeq2")
#ALTERNATIVE using ps.ng.tax_most_copied: ps.ng.tax (40594) vs. ps.ng.tax_most_copied (166)
ps.ng.tax_sel <- ps.ng.tax
#FITTING5: correct the id of the group members, see FITTING6
otu_table(ps.ng.tax_sel) <- otu_table(ps.ng.tax)[,c("micro1", "micro3", "micro4", "micro6", "micro7", "micro12", "micro13", "micro16", "micro17", "mw001", "mw004", "mw005", "mw006", "mw007", "mw009", "mw010", "mw013", "mw014", "mw015", "mw017", "mw021",    "kg001", "kg002", "kg003", "kg004", "kg005", "kg007", "kg009", "kg015", "kg016", "kg019", "kg020", "kg021", "kg022", "kg023", "kg025", "kg026", "kg027", "kg028", "kg029")]
diagdds = phyloseq_to_deseq2(ps.ng.tax_sel, ~SampleType)
diagdds$SampleType <- relevel(diagdds$SampleType, "control")

## Filter out rows where all values are zero --> from 631 to 551
#keep <- rowSums(counts(diagdds) > 0) > 0 #
#diagdds <- diagdds[keep,]

# The poscounts method uses a modified geometric mean that excludes zero values from the calculation, which should prevent the error.
#counts(diagdds) <- as.matrix(round(counts(diagdds) + 1))
diagdds <- estimateSizeFactors(diagdds, type = "poscounts")
diagdds = DESeq(diagdds, test="Wald", fitType="parametric")
resultsNames(diagdds)
res = results(diagdds, cooksCutoff = FALSE)
alpha = 0.05
sigtab = res[which(res$padj < alpha), ]
sigtab = cbind(as(sigtab, "data.frame"), as(tax_table(ps.ng.tax_sel)[rownames(sigtab), ], "matrix"))
sigtab <- sigtab[rownames(sigtab) %in% rownames(tax_table(ps.ng.tax_most_copied)), ]
kable(sigtab) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
#rownames(sigtab) %in% rownames(tax_table(ps.ng.tax_most_copied))
write.xlsx(sigtab, file = "sigtab_GPA_vs_control.xlsx")
#subv %in% v
### returns a vector TRUE FALSE
#is.element(subv, v)
### returns a vector TRUE FALSE
library("ggplot2")
theme_set(theme_bw())
scale_fill_discrete <- function(palname = "Set1", ...) {
    scale_fill_brewer(palette = palname, ...)
}
x = tapply(sigtab$log2FoldChange, sigtab$Order, function(x) max(x))
x = sort(x)
sigtab$Order = factor(as.character(sigtab$Order), levels=names(x))
x = tapply(sigtab$log2FoldChange, sigtab$Family, function(x) max(x))
x = sort(x)
sigtab$Family = factor(as.character(sigtab$Family), levels=names(x))
ggplot(sigtab, aes(x=log2FoldChange, y=Family, color=Order)) + geom_point(aes(size=padj)) + scale_size_continuous(name="padj",range=c(8,4))+
theme(axis.text.x = element_text(angle = -25, hjust = 0, vjust=0.5))
#Error in checkForExperimentalReplicates(object, modelMatrix) :
#  The design matrix has the same number of samples and coefficients to fit,
#  so estimation of dispersion is not possible. Treating samples
#  as replicates was deprecated in v1.20 and no longer supported since v1.22.
```

## RA vs control
```{r, echo=TRUE, warning=FALSE}
ps.ng.tax_sel <- ps.ng.tax
otu_table(ps.ng.tax_sel) <- otu_table(ps.ng.tax)[,c("ra002", "ra003", "ra004", "ra005", "ra006", "ra007", "ra008", "ra009", "ra010", "ra013", "ra014", "ra015", "ra017", "ra018", "ra019", "ra020", "ra022", "ra023", "ra024", "ra025",    "kg001", "kg002", "kg003", "kg004", "kg005", "kg007", "kg009", "kg015", "kg016", "kg019", "kg020", "kg021", "kg022", "kg023", "kg025", "kg026", "kg027", "kg028", "kg029")]
diagdds = phyloseq_to_deseq2(ps.ng.tax_sel, ~SampleType)
diagdds$SampleType <- relevel(diagdds$SampleType, "control")
diagdds <- estimateSizeFactors(diagdds, type = "poscounts")
diagdds = DESeq(diagdds, test="Wald", fitType="parametric")
resultsNames(diagdds)
res = results(diagdds, cooksCutoff = FALSE)
alpha = 2.0
sigtab = res[which(res$padj < alpha), ]
sigtab = cbind(as(sigtab, "data.frame"), as(tax_table(ps.ng.tax_sel)[rownames(sigtab), ], "matrix"))
sigtab <- sigtab[rownames(sigtab) %in% rownames(tax_table(ps.ng.tax_most_copied)), ]
kable(sigtab) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
library("ggplot2")
theme_set(theme_bw())
scale_fill_discrete <- function(palname = "Set1", ...) {
    scale_fill_brewer(palette = palname, ...)
}
x = tapply(sigtab$log2FoldChange, sigtab$Order, function(x) max(x))
x = sort(x)
sigtab$Order = factor(as.character(sigtab$Order), levels=names(x))
x = tapply(sigtab$log2FoldChange, sigtab$Family, function(x) max(x))
x = sort(x)
sigtab$Family = factor(as.character(sigtab$Family), levels=names(x))
ggplot(sigtab, aes(x=log2FoldChange, y=Family, color=Order)) + geom_point(aes(size=padj)) + scale_size_continuous(name="padj",range=c(8,4))+
theme(axis.text.x = element_text(angle = -25, hjust = 0, vjust=0.5))
```

## GPA vs RA
```{r, echo=TRUE, warning=FALSE}
ps.ng.tax_sel <- ps.ng.tax
otu_table(ps.ng.tax_sel) <- otu_table(ps.ng.tax)[,c("micro1", "micro3", "micro4", "micro6", "micro7", "micro12", "micro13", "micro16", "micro17", "mw001", "mw004", "mw005", "mw006", "mw007", "mw009", "mw010", "mw013", "mw014", "mw015", "mw017", "mw021",    "ra002", "ra003", "ra004", "ra005", "ra006", "ra007", "ra008", "ra009", "ra010", "ra013", "ra014", "ra015", "ra017", "ra018", "ra019", "ra020", "ra022", "ra023", "ra024", "ra025")]
diagdds = phyloseq_to_deseq2(ps.ng.tax_sel, ~SampleType)
diagdds$SampleType <- relevel(diagdds$SampleType, "RA")
diagdds <- estimateSizeFactors(diagdds, type = "poscounts")
diagdds = DESeq(diagdds, test="Wald", fitType="parametric")
resultsNames(diagdds)
res = results(diagdds, cooksCutoff = FALSE)
alpha = 0.05
sigtab = res[which(res$padj < alpha), ]
sigtab = cbind(as(sigtab, "data.frame"), as(tax_table(ps.ng.tax_sel)[rownames(sigtab), ], "matrix"))
sigtab <- sigtab[rownames(sigtab) %in% rownames(tax_table(ps.ng.tax_most_copied)), ]
kable(sigtab) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
library("ggplot2")
theme_set(theme_bw())
scale_fill_discrete <- function(palname = "Set1", ...) {
    scale_fill_brewer(palette = palname, ...)
}
x = tapply(sigtab$log2FoldChange, sigtab$Order, function(x) max(x))
x = sort(x)
sigtab$Order = factor(as.character(sigtab$Order), levels=names(x))
x = tapply(sigtab$log2FoldChange, sigtab$Family, function(x) max(x))
x = sort(x)
sigtab$Family = factor(as.character(sigtab$Family), levels=names(x))
ggplot(sigtab, aes(x=log2FoldChange, y=Family, color=Order)) + geom_point(aes(size=padj)) + scale_size_continuous(name="padj",range=c(8,4))+
theme(axis.text.x = element_text(angle = -25, hjust = 0, vjust=0.5))
```

like unlike

点赞本文的读者

还没有人对此文章表态


本文有评论

没有评论

看文章,发评论,不要沉默


© 2023 XGenes.com Impressum