library(knitr)
knitr::opts_chunk$set(
    warning=FALSE,
    message=FALSE
)

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.

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 

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,
        cores = 1, 

        # This is ONLY for speeding up the Vignette execution
        draws_after_tail = 1
    )

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()


stemangiola/ppcseq documentation built on Sept. 21, 2023, 7:19 a.m.