User guide to the dearseq R package

Marine Gauthier, Denis Agniel, Boris Hejblum

2020-04-05

1 Overview of dearseq

dearseq is an R package that performs Differential Expression Analysis of RNA-seq data, while guaranteeing a sound control of false positives (Gauthier et al., 2019). It relies on variance component score test accounting for data heteroscedasticity through precision weights, not unlike voom (Law et al., 2014). It can perform either

In addition, dearseq can deal with various and complex experimental designs such as:

More details are provided in this bioRxiv preprint 635714.

2 Using dearseq for a gene-wise analysis

2.1 Getting started using dear_seq()

2 inputs are required to run dear_seq():

Both can be supplied in the formed of a SummarizedExperiment object for instance. A third optional input is the covariates that will be adjusted on (such as age for instance).

2.2 An example analysis

Tuberculosis (TB) is a disease caused by a bacterium called Mycobacterium tuberculosis. Bacteria typically infect the lungs, but they can also affect other parts of the body. Tuberculosis can remain in a quiescent state in the body. It is called latent tuberculosis infection (LTBI). It is an infection without clinical signs, bacteriological and radiological disease.

Berry et al. first identified a whole blood 393 transcript signature for active TB using microarray analysis. Then, Singhania et al. found a 373-genes signature of active tuberculosis using RNA-Seq, confirming microarray results, that discriminates active tuberculosis from latently infected and healthy individuals.

We sought to investigate how many of the 373 genes Singhania et al. found using edgeR might actually be false positives. As a quick example, we propose a partial re-analysis (see Gauthier et al. for the complete analysis) of the Singhania et al. dataset: we proceed to the Differential Expression Analysis (DEA) of the Active TB group against the Control one, omitting LTBI/Control and ActiveTB/LTBI comparisons. We focused on the Berry London dataset.

It results in 54 patients of whom 21 are active TB patients, 21 are latent TB patients and 12 are healthy control particiants.

For more details, check the article from Berry et al., 2010 here.

2.2.1 Data preparation

Data from Singhania et al. inverstigating active TB are publicly available on GEO website with GEO access number ‘GSE107995’. Thanks to the GEOquery package to get the data files from GEO website (see appendix for more details on GEOquery)

2.2.1.2 Gene expression matrix

This matrix contains the gene expression (in cells) for each gene (in rows) of each sample (in columns) gathered from RNA-seq measurements. The gene expression could already be normalized, or not (e.g. raw counts or pseudo-counts straight from the alignment). In the latter case, the gene expression is normalized then into log(counts) per million (i.e. log-cpm).

The gene expression matrix (called London) is including in the package dearseq. It was extracted from one of the GEO supplementary files (namely the “GSE107991_edgeR_normalized_Berry_London.xlsx” file).

NB: These expression data have already been already normalized using edgeR

We have nrow(London) genes in rows and ncol(London) samples in columns * rownames are Ensembl IDs ENSGxxxxxxxxxxx for each gene (saved in genes) * colnames are the name of each sample Berry_London_Samplex * each data-cell contains the normalized gene expression

The vector genes contains all the gene identifiers.

2.2.2 Identifying differentially expressed genes (DEG) from dearseq variance component score test

The main arguments to the dear_seq() function are:

  • exprmat: a numeric matrix containing the raw RNA-seq counts or preprocessed expressions
  • covariates: a numeric matrix containing the model covariates that needs to be adjusted. Usually, its first column is the intercept (full of 1s).
  • variables2test: a numeric design matrix containing the variables of interest (with whom the expression association is tested)
  • which_test: a character string indicating which method to use to approximate the variance component score test, either “permutation” or “asymptotic”.
  • preprocessed: a logical flag indicating whether the expression data have already been preprocessed (e.g. log2 transformed). Default is FALSE, in which case y is assumed to contain raw counts and is normalized into log(counts) per million.

We use the permutation test because of the relatively small sample size (\(n=33\)).

res_dearseq is a list containing:

  • the input values for which_test, nperm and preprocessed
  • the gene-wise p-values (raw and adjusted - default is correction for multiple testing with the Benjamini-Hochberg procedure)

NB: We excluded the LTBI patients to focus on the comparison between Active TB versus Control patients.

3 Using dearseq for gene-set analysis

Here we will use a subsample of the RNA-seq data from Baduel et al. (2016) studying Arabidopsis Arenosa physiology, that is included in the dearseq package.

We investigates 2 gene sets that were derived in a data-driven manner By Baduel et al. (2016).

library(dearseq)
library(SummarizedExperiment)
library(BiocSet)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:matrixStats':
#> 
#>     count
#> The following objects are masked from 'package:GenomicRanges':
#> 
#>     intersect, setdiff, union
#> The following object is masked from 'package:GenomeInfoDb':
#> 
#>     intersect
#> The following objects are masked from 'package:IRanges':
#> 
#>     collapse, desc, intersect, setdiff, slice, union
#> The following objects are masked from 'package:S4Vectors':
#> 
#>     first, intersect, rename, setdiff, setequal, union
#> The following object is masked from 'package:Biobase':
#> 
#>     combine
#> The following objects are masked from 'package:BiocGenerics':
#> 
#>     combine, intersect, setdiff, union
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
data("baduel_5gs")
se2 <- SummarizedExperiment(assay = log2(expr_norm_corr + 1), colData = design)
genes_non0var_ind <- which(matrixStats::rowVars(expr_norm_corr) != 0)

KAvsTBG <- dearseq::dgsa_seq(object = se2[genes_non0var_ind, ], covariates = c("Vernalized", 
    "AgeWeeks", "Vernalized_Population", "AgeWeeks_Population"), variables2test = "PopulationKA", 
    genesets = baduel_gmt$genesets[c(3, 5)], which_test = "permutation", which_weights = "loclin", 
    n_perm = 1000, preprocessed = TRUE, verbose = FALSE, parallel_comp = FALSE)
KAvsTBG$pvals
#>               rawPval    adjPval
#> VR_TBG     0.93006993 0.93006993
#> DE_KAvsTBG 0.01198801 0.02397602

Cold <- dearseq::dgsa_seq(object = se2[genes_non0var_ind, ], covariates = c("AgeWeeks", 
    "PopulationKA", "AgeWeeks_Population"), variables2test = c("Vernalized", "Vernalized_Population"), 
    genesets = baduel_gmt$genesets[c(3, 5)], which_test = "permutation", which_weights = "loclin", 
    n_perm = 1000, preprocessed = TRUE, verbose = FALSE, parallel_comp = FALSE)
Cold$pvals
#>               rawPval    adjPval
#> VR_TBG     0.01898102 0.03796204
#> DE_KAvsTBG 0.04395604 0.04395604

4 Bibliography

Agniel D & Hejblum BP (2017). Variance component score test for time-course gene set analysis of longitudinal RNA-seq data. Biostatistics 18(4):589-604. DOI: 10.1093/biostatistics/kxx005.

Baduel P, Arnold B, Weisman CM, Hunter B & Bomblies K (2016). Habitat-Associated Life History and Stress-Tolerance Variation in Arabidopsis Arenosa. Plant Physiology, 171(1):437-51. DOI: 10.1104/pp.15.01875.

Berry MP, Graham CM, McNab FW, Xu Z, Bloch SAA, Oni T, Wilkinson KA, Banchereau R, Skinner J, Wilkinson RJ, Quinn C, Blankenship D, Dhawan R, Cush JJ, Mejias A, Ramilo O, Kon OM, Pascual V, Banchereau J, Chaussabel D & O’Garra A (2010). An interferon-inducible neutrophil-driven blood transcriptional signature in human tuberculosis. Nature 466:973–977. DOI: 10.1038/nature09247

Gauthier M, Agniel D, Thiébaut R & Hejblum BP (2019). dearseq: a variance component score test for RNA-Seq differential analysis that effectively controls the false discovery rate. bioRxiv 635714. DOI: 10.1101/635714v1.

Singhania A, Verma R, Graham CM, Lee J, Tran T, Richardson M, Lecine P, Leissner P, Berry MPR, Wilkinson RJ, Kaiser K, Rodrigue M, Woltmann G, Haldar P, O’Garra A, (2018). A modular transcriptional signature identifies phenotypic heterogeneity of human tuberculosis infection. Nature communications 9(1):2308. DOI: 10.1038/s41467-018-04579-w

5 Appendix

5.1 GEOquery package

In case the data you want to analyze is publicly available through Gene Expression Omnibus (GEO), you can access it with the GEOquery package, that can be installed with the following commands:

5.2 readxl

The readxl package allows to easily imports data from Excel format and can be similarly installed with the following commands:

More details can be found on Bioconductor and in Davis S, Meltzer P, (2007) GEOquery: a bridge between the Gene Expression Omnibus (GEO) and Bioconductor Bioinformatics 14:1846-1847.

5.3 Session Info

#> R version 4.0.0 alpha (2020-03-31 r78116)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
#> 
#> 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] stats4    parallel  stats     graphics  grDevices utils     datasets 
#> [8] methods   base     
#> 
#> other attached packages:
#>  [1] BiocSet_1.1.2               dplyr_0.8.5                
#>  [3] SummarizedExperiment_1.17.5 DelayedArray_0.13.9        
#>  [5] matrixStats_0.56.0          GenomicRanges_1.39.3       
#>  [7] GenomeInfoDb_1.23.16        IRanges_2.21.8             
#>  [9] S4Vectors_0.25.15           dearseq_0.99.12            
#> [11] readxl_1.3.1                GEOquery_2.55.1            
#> [13] Biobase_2.47.3              BiocGenerics_0.33.3        
#> 
#> loaded via a namespace (and not attached):
#>  [1] httr_1.4.1               tidyr_1.0.2              bit64_0.9-7             
#>  [4] assertthat_0.2.1         statmod_1.4.34           blob_1.2.1              
#>  [7] Rsamtools_2.3.7          GenomeInfoDbData_1.2.2   cellranger_1.1.0        
#> [10] yaml_2.2.1               pillar_1.4.3             RSQLite_2.2.0           
#> [13] lattice_0.20-41          glue_1.4.0               limma_3.43.5            
#> [16] digest_0.6.25            XVector_0.27.2           colorspace_1.4-1        
#> [19] plyr_1.8.6               htmltools_0.4.0          Matrix_1.2-18           
#> [22] XML_3.99-0.3             pkgconfig_2.0.3          zlibbioc_1.33.1         
#> [25] purrr_0.3.3              scales_1.1.0             BiocParallel_1.21.2     
#> [28] tibble_3.0.0             KEGGREST_1.27.1          ggplot2_3.3.0           
#> [31] ellipsis_0.3.0           pbapply_1.4-2            cli_2.0.2               
#> [34] magrittr_1.5             crayon_1.3.4             memoise_1.1.0           
#> [37] evaluate_0.14            fansi_0.4.1              xml2_1.3.0              
#> [40] tools_4.0.0              hms_0.5.3                formatR_1.7             
#> [43] lifecycle_0.2.0          stringr_1.4.0            munsell_0.5.0           
#> [46] AnnotationDbi_1.49.1     Biostrings_2.55.7        compiler_4.0.0          
#> [49] rlang_0.4.5              grid_4.0.0               RCurl_1.98-1.1          
#> [52] CompQuadForm_1.4.3       bitops_1.0-6             rmarkdown_2.1           
#> [55] gtable_0.3.0             DBI_1.1.0                curl_4.3                
#> [58] R6_2.4.1                 GenomicAlignments_1.23.2 rtracklayer_1.47.0      
#> [61] knitr_1.28               bit_1.1-15.2             KernSmooth_2.23-16      
#> [64] readr_1.3.1              stringi_1.4.6            Rcpp_1.0.4              
#> [67] vctrs_0.2.4              png_0.1-7                tidyselect_1.0.0        
#> [70] xfun_0.12