# Probabilistic Outlier Identification for RNA Sequencing Generalized Linear Models

Stefano Mangiola

#### 2021-10-26

#### Package

ppcseq 1.2.0

# 1 Introduction

Relative transcript abundance has proven to be a valuable tool for understanding the function of genes in biological systems. For the differential analysis of transcript abundance using RNA sequencing data, the negative binomial model is by far the most frequently adopted. However, common methods that are based on a negative binomial model are not robust to extreme outliers, which we found to be abundant in public datasets. So far, no rigorous and probabilistic methods for detection of outliers have been developed for RNA sequencing data, leaving the identification mostly to visual inspection. Recent advances in Bayesian computation allow large-scale comparison of observed data against its theoretical distribution given in a statistical model. Here we propose ppcseq, a key quality-control tool for identifying transcripts that include outlier data points in differential expression analysis, which do not follow a negative binomial distribution. Applying ppcseq to analyse several publicly available datasets using popular tools, we show that from 3 to 10 percent of differentially abundant transcripts across algorithms and datasets had statistics inflated by the presence of outliers.

# 2 Installation and use

The input data set is a tidy representation of a differential gene transcript abundance analysis

    library(dplyr)
    library(ppcseq)

To install:

Before install, for linux systems, in order to exploit multi-threading, from R write:

    fileConn<-file("~/.R/Makevars")
    writeLines(c( "CXX14FLAGS += -O3","CXX14FLAGS += -DSTAN_THREADS", "CXX14FLAGS += -pthread"), fileConn)
    close(fileConn)

Multi-threading allows the sampling or variational bayes to share the computation on multiple cores.

Then, install with

    if(!requireNamespace("BiocManager", quietly = TRUE))
      install.packages("BiocManager")
    BiocManager::install("ppcseq")

You can get the test dataset with

    data("counts")
    counts

    ## # A tibble: 394,821 x 9
    ##    sample  symbol   logCPM    LR   PValue        FDR value       W Label
    ##    <chr>   <chr>     <dbl> <dbl>    <dbl>      <dbl> <int>   <dbl> <chr>
    ##  1 10922PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   160 -0.129  High
    ##  2 10935PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   150 -0.127  High
    ##  3 10973PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   146 -0.426  High
    ##  4 10976PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   347 -0.0164 High
    ##  5 10985PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   175 -0.135  High
    ##  6 11026PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   244  0.125  High
    ##  7 11045PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   399 -0.0892 High
    ##  8 11082PP SLC16A12   1.39  41.1 1.46e-10 0.00000274   100  0.261  Neoadjuvant
    ##  9 11086PP SLC16A12   1.39  41.1 1.46e-10 0.00000274    37 -0.132  Neoadjuvant
    ## 10 11103PP SLC16A12   1.39  41.1 1.46e-10 0.00000274    73  0.146  Neoadjuvant
    ## # ... with 394,811 more rows

You can identify anrtefactual calls from your differential transcribt anundance analysis, due to outliers.

    # Import libraries

    if(Sys.info()[['sysname']] == "Linux")
    counts.ppc =
        counts %>%
        mutate(is_significant = FDR < 0.0001) %>%
        identify_outliers(
            formula = ~ Label,
            .sample = sample,
            .transcript = symbol,
            .abundance = value,
            .significance = PValue,
            .do_check = is_significant,
            percent_false_positive_genes = 5,
            approximate_posterior_inference = FALSE
        )

The new posterior predictive check has been added to the original data frame

    if(Sys.info()[['sysname']] == "Linux")
    counts.ppc

The new data frame contains plots for each gene

We can visualise the top five differentially transcribed genes

    if(Sys.info()[['sysname']] == "Linux")
    counts.ppc_plots =
        counts.ppc %>%
        plot_credible_intervals()

    if(Sys.info()[['sysname']] == "Linux")
    counts.ppc_plots %>%
        pull(plot) %>%
        .[seq_len(1)]

    sessionInfo()

    ## R version 4.1.1 (2021-08-10)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ## Running under: Windows Server x64 (build 17763)
    ##
    ## Matrix products: default
    ##
    ## locale:
    ## [1] LC_COLLATE=C
    ## [2] LC_CTYPE=English_United States.1252
    ## [3] LC_MONETARY=English_United States.1252
    ## [4] LC_NUMERIC=C
    ## [5] LC_TIME=English_United States.1252
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] ppcseq_1.2.0     dplyr_1.0.7      knitr_1.36       BiocStyle_2.22.0
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] httr_1.4.2            sass_0.4.0            edgeR_3.36.0
    ##  [4] tidyr_1.1.4           foreach_1.5.1         jsonlite_1.7.2
    ##  [7] bslib_0.3.1           RcppParallel_5.1.4    StanHeaders_2.21.0-7
    ## [10] assertthat_0.2.1      posterior_1.1.0       distributional_0.2.2
    ## [13] BiocManager_1.30.16   stats4_4.1.1          ggdist_3.0.0
    ## [16] tensorA_0.36.2        yaml_2.2.1            globals_0.14.0
    ## [19] pillar_1.6.4          backports_1.2.1       lattice_0.20-45
    ## [22] glue_1.4.2            limma_3.50.0          arrayhelpers_1.1-0
    ## [25] digest_0.6.28         checkmate_2.0.0       colorspace_2.0-2
    ## [28] Matrix_1.3-4          htmltools_0.5.2       pkgconfig_2.0.3
    ## [31] rstan_2.21.2          listenv_0.8.0         svUnit_1.0.6
    ## [34] bookdown_0.24         purrr_0.3.4           scales_1.1.1
    ## [37] processx_3.5.2        tibble_3.1.5          generics_0.1.1
    ## [40] farver_2.1.0          ggplot2_3.3.5         ellipsis_0.3.2
    ## [43] furrr_0.2.3           withr_2.4.2           cli_3.0.1
    ## [46] magrittr_2.0.1        crayon_1.4.1          evaluate_0.14
    ## [49] ps_1.6.0              parallelly_1.28.1     future_1.22.1
    ## [52] fansi_0.5.0           doParallel_1.0.16     benchmarkme_1.0.7
    ## [55] pkgbuild_1.2.0        tools_4.1.1           loo_2.4.1
    ## [58] prettyunits_1.1.1     lifecycle_1.0.1       matrixStats_0.61.0
    ## [61] stringr_1.4.0         V8_3.4.2              munsell_0.5.0
    ## [64] locfit_1.5-9.4        callr_3.7.0           compiler_4.1.1
    ## [67] jquerylib_0.1.4       tidybayes_3.0.1       rlang_0.4.12
    ## [70] grid_4.1.1            iterators_1.0.13      rmarkdown_2.11
    ## [73] gtable_0.3.0          codetools_0.2-18      inline_0.3.19
    ## [76] abind_1.4-5           DBI_1.1.1             curl_4.3.2
    ## [79] benchmarkmeData_1.0.4 R6_2.5.1              gridExtra_2.3
    ## [82] rstantools_2.1.1      fastmap_1.1.0         utf8_1.2.2
    ## [85] stringi_1.7.5         parallel_4.1.1        Rcpp_1.0.7
    ## [88] vctrs_0.3.8           tidyselect_1.1.1      xfun_0.27
    ## [91] coda_0.19-4