# heavy-SIP

#### Nick Youngblut

#### 2018-05-14

# Introduction

## heavy-SIP method workflow:

Prior to the development of these HTS-SIP analysis methods, DNA- and RNA-SIP experiments that utilized Sanger or high throughput sequencing were usually analyzed with standard statistical processes (e.g. t-tests), in order to identify incorporators. Previous work suggests that these methods generally have low senstivity and/or high false positive rates when applied to sequence data. Here, these analysis methods will be referred to “heavy-SIP” methods. While the work of Youngblut et al., (https://doi.org/10.3389/fmicb.2018.00570) suggests that HR-SIP analysis methods (eg., MW-HR-SIP) should be used for processing HTS-SIP datasets, the HTSSIP R package provides heavy-SIP methods so researchers have the option of using these methods and making their own comparisons to HR-SIP methods.

heavy-SIP is performed with the `heavy_SIP()` function, which consists of multiple possible tests. See `?heavy_SIP` for more details. This vignette demonstrates the use of `heavy_SIP()`.

# Initialization

First, let’s load some packages including `HTSSIP`.

    library(dplyr)
    library(ggplot2)
    library(HTSSIP)

    # adjusted P-value cutoff
    padj_cutoff = 0.1

# Unreplicated dataset

For unreplicated datasets (no experiment replicates of controls or treatments), the options are limited on how to identify incorporators.

## Parsing the dataset

We will be using a dataset that is already parsed. See HTSSIP introduction vignette for a description on why dataset parsing (all treatment-control comparisons) is needed.

    physeq_S2D2_l

    ## $`(Substrate=='12C-Con' & Day=='3') | (Substrate=='13C-Cel' & Day == '3')`
    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 1072 taxa and 46 samples ]
    ## sample_data() Sample Data:       [ 46 samples by 17 sample variables ]
    ## tax_table()   Taxonomy Table:    [ 1072 taxa by 8 taxonomic ranks ]
    ## phy_tree()    Phylogenetic Tree: [ 1072 tips and 1071 internal nodes ]
    ##
    ## $`(Substrate=='12C-Con' & Day=='14') | (Substrate=='13C-Cel' & Day == '14')`
    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 1072 taxa and 46 samples ]
    ## sample_data() Sample Data:       [ 46 samples by 17 sample variables ]
    ## tax_table()   Taxonomy Table:    [ 1072 taxa by 8 taxonomic ranks ]
    ## phy_tree()    Phylogenetic Tree: [ 1072 tips and 1071 internal nodes ]
    ##
    ## $`(Substrate=='12C-Con' & Day=='14') | (Substrate=='13C-Glu' & Day == '14')`
    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 1072 taxa and 47 samples ]
    ## sample_data() Sample Data:       [ 47 samples by 17 sample variables ]
    ## tax_table()   Taxonomy Table:    [ 1072 taxa by 8 taxonomic ranks ]
    ## phy_tree()    Phylogenetic Tree: [ 1072 tips and 1071 internal nodes ]
    ##
    ## $`(Substrate=='12C-Con' & Day=='3') | (Substrate=='13C-Glu' & Day == '3')`
    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 1072 taxa and 46 samples ]
    ## sample_data() Sample Data:       [ 46 samples by 17 sample variables ]
    ## tax_table()   Taxonomy Table:    [ 1072 taxa by 8 taxonomic ranks ]
    ## phy_tree()    Phylogenetic Tree: [ 1072 tips and 1071 internal nodes ]

# One treatment-control comparison

First, we’ll just focus on 1 treatment-control comparison. Let’s get the individual phyloseq object.

    physeq = physeq_S2D2_l[[1]]
    physeq

    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 1072 taxa and 46 samples ]
    ## sample_data() Sample Data:       [ 46 samples by 17 sample variables ]
    ## tax_table()   Taxonomy Table:    [ 1072 taxa by 8 taxonomic ranks ]
    ## phy_tree()    Phylogenetic Tree: [ 1072 tips and 1071 internal nodes ]

Let’s check that the samples belong to either a 13C-treatment or 12C-control.

    physeq %>% sample_data %>% .$Substrate %>% table

    ## .
    ## 12C-Con 13C-Cel
    ##      23      23

Since this dataset is an unreplicated comparison between treatment & control, we are just going to use the ‘binary’ method, which will call incorporators if they are present in the “heavy” gradient fractions of the treatment and not present in the “heavy” fractions of the control. Note that the “heavy” fractions are user-defined.

    df_res = heavy_SIP(physeq, ex="Substrate=='12C-Con'",
                       comparison='H-v-H', hypo_test='binary')
    df_res %>% head(n=3)

    ##         statistic  p padj
    ## OTU.514         0 NA   NA
    ## OTU.729         0 NA   NA
    ## OTU.322         0 NA   NA

Since no real statistical test, the “statistic” is just 0 (not an incorporator) or 1 (an incorporator). Also, the “p” and “padj” columns are thus “NA”.

How many “incorporators”?

    df_res$statistic %>% table

    ## .
    ##   0   1
    ## 980  65

# Replicated dataset

Experimental replicates allows us to use tradional hypothesis testing (e.g., t-tests) for determining significantly differ OTU abundances between treatment and controls. Note that there is a reason why more suffisticated statistical methods have been developed for assessing differentially abundant features in high throughput sequencing datasets (e.g., DESeq2, EdgeR, or MetagenomeSeq). The traditional methods don’t account for many challenging aspects of identifying statistically different abundances in sequence data such as i) a high number of multiple hypotheses ii) zero-inflation iii) compositional data (relative abundances; the sum-to-one constraint).

With that said, let’s try out these heavy-SIP methods on a replicated dataset, with 3 experimental replicates of the control and treatment (total gradients = 6)

    physeq_rep3

    ## phyloseq-class experiment-level object
    ## otu_table()   OTU Table:         [ 6 taxa and 144 samples ]
    ## sample_data() Sample Data:       [ 144 samples by 5 sample variables ]

    physeq_rep3 %>% sample_data %>% head(n=3)

    ##                             Gradient Buoyant_density Fraction Treatment
    ## 12C-Con_rep1_1.668185_1 12C-Con_rep1        1.668185        1   12C-Con
    ## 12C-Con_rep1_1.680254_2 12C-Con_rep1        1.680254        2   12C-Con
    ## 12C-Con_rep1_1.679431_3 12C-Con_rep1        1.679431        3   12C-Con
    ##                         Replicate
    ## 12C-Con_rep1_1.668185_1         1
    ## 12C-Con_rep1_1.680254_2         1
    ## 12C-Con_rep1_1.679431_3         1

## t-tests

To compare “heavy” fractions in the treatment versus “heavy” fractions in the control, we will use the “H-v-H” comparison method. See `?heavy_SIP` for details on other possible comparisons.

    df_res = heavy_SIP(physeq_rep3, ex="Treatment=='12C-Con'",
                       comparison='H-v-H', hypo_test='t-test')
    df_res %>% head(n=3)

    ##         statistic         p      padj
    ## OTU.1 -0.09563691 0.5336654 0.5641843
    ## OTU.2 -0.18450596 0.5641843 0.5641843
    ## OTU.3  1.14859160 0.2280138 0.3519149

“padj” is p-values adjusted with the Benjamini Hochberg method.

How many incorporators?

    df_res %>%
      filter(padj < padj_cutoff) %>%
      nrow

    ## [1] 0

No incorporators. Obviously, the sensitivity of this method is pretty low. What’s the distribution of p-values?

    df_res$p %>% summary

    ##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    ##  0.1619  0.2180  0.2313  0.3228  0.4589  0.5642

## Mann Whitney U test

Does anything change when we use a nonparametric test? Here, we will use the Mann Whitney U test (a nonparametric t-test).

    df_res = heavy_SIP(physeq_rep3, ex="Treatment=='12C-Con'",
                       comparison='H-v-H', hypo_test='wilcox')
    df_res %>% head(n=3)

    ##       statistic         p      padj
    ## OTU.1         2 0.6666667 0.6666667
    ## OTU.2         2 0.6666667 0.6666667
    ## OTU.3         4 0.1666667 0.2500000

What’s the p-value and adjusted-pvalue distribution?

    df_res$p %>% summary %>% print

    ##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    ##  0.1667  0.1667  0.1667  0.3333  0.5417  0.6667

    df_res$padj %>% summary %>% print

    ##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    ##  0.2500  0.2500  0.2500  0.3889  0.5625  0.6667

Again, no incorporators. The change in abundances must be pretty dramatic for heavy-SIP methods to ID incorporators, especially when there’s many multiple hypotheses.

# Session info

    sessionInfo()

    ## R version 3.4.3 (2017-11-30)
    ## Platform: x86_64-pc-linux-gnu (64-bit)
    ## Running under: Ubuntu 16.04.3 LTS
    ##
    ## Matrix products: default
    ## BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
    ## LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0
    ##
    ## locale:
    ##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    ##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
    ##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    ##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    ## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] bindrcpp_0.2    phyloseq_1.20.0 HTSSIP_1.4.0    ggplot2_2.2.1
    ## [5] tidyr_0.7.2     dplyr_0.7.4
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] nlme_3.1-131               bitops_1.0-6
    ##   [3] matrixStats_0.52.2         bit64_0.9-7
    ##   [5] doParallel_1.0.11          RColorBrewer_1.1-2
    ##   [7] rprojroot_1.2              GenomeInfoDb_1.12.3
    ##   [9] tools_3.4.3                backports_1.1.1
    ##  [11] R6_2.2.2                   coenocliner_0.2-2
    ##  [13] vegan_2.4-4                rpart_4.1-11
    ##  [15] Hmisc_4.0-3                DBI_0.7
    ##  [17] lazyeval_0.2.0             BiocGenerics_0.22.1
    ##  [19] mgcv_1.8-22                colorspace_1.3-2
    ##  [21] permute_0.9-4              ade4_1.7-8
    ##  [23] nnet_7.3-12                tidyselect_0.2.2
    ##  [25] gridExtra_2.3              DESeq2_1.16.1
    ##  [27] bit_1.1-12                 compiler_3.4.3
    ##  [29] Biobase_2.36.2             htmlTable_1.9
    ##  [31] DelayedArray_0.2.7         labeling_0.3
    ##  [33] scales_0.5.0               checkmate_1.8.5
    ##  [35] genefilter_1.58.1          stringr_1.2.0
    ##  [37] digest_0.6.12              foreign_0.8-69
    ##  [39] rmarkdown_1.6              XVector_0.16.0
    ##  [41] base64enc_0.1-3            pkgconfig_2.0.1
    ##  [43] htmltools_0.3.6            htmlwidgets_0.9
    ##  [45] rlang_0.1.2                RSQLite_2.0
    ##  [47] bindr_0.1                  jsonlite_1.5
    ##  [49] BiocParallel_1.10.1        acepack_1.4.1
    ##  [51] RCurl_1.95-4.8             magrittr_1.5
    ##  [53] GenomeInfoDbData_0.99.0    Formula_1.2-2
    ##  [55] biomformat_1.4.0           Matrix_1.2-11
    ##  [57] Rcpp_0.12.16               munsell_0.4.3
    ##  [59] S4Vectors_0.14.7           ape_4.1
    ##  [61] stringi_1.1.5              yaml_2.1.14
    ##  [63] MASS_7.3-47                SummarizedExperiment_1.6.5
    ##  [65] zlibbioc_1.22.0            rhdf5_2.20.0
    ##  [67] plyr_1.8.4                 blob_1.1.0
    ##  [69] grid_3.4.3                 parallel_3.4.3
    ##  [71] lattice_0.20-35            Biostrings_2.44.2
    ##  [73] splines_3.4.3              multtest_2.32.0
    ##  [75] annotate_1.54.0            locfit_1.5-9.1
    ##  [77] knitr_1.17                 igraph_1.1.2
    ##  [79] GenomicRanges_1.28.6       geneplotter_1.54.0
    ##  [81] reshape2_1.4.2             codetools_0.2-15
    ##  [83] stats4_3.4.3               XML_3.98-1.9
    ##  [85] glue_1.1.1                 evaluate_0.10.1
    ##  [87] latticeExtra_0.6-28        data.table_1.10.4-2
    ##  [89] foreach_1.4.3              gtable_0.2.0
    ##  [91] purrr_0.2.4                assertthat_0.2.0
    ##  [93] xtable_1.8-2               survival_2.41-3
    ##  [95] tibble_1.3.4               iterators_1.0.8
    ##  [97] memoise_1.1.0              AnnotationDbi_1.38.2
    ##  [99] IRanges_2.10.5             cluster_2.0.6