Analysing Long Read RNA-Seq data with bambu

Ying Chen, Andre Sim, Yuk Kei Wan, Jonathan Göke

Introduction

Bambu is a method for transcript discovery and quantification from long read RNA-Seq data. Bambu uses aligned reads and genome reference annotations as input, and will return abundance estimates for all known transcripts and for newly discovered transcripts. Bambu uses the information from the reference annotations to correct misalignment at splice junctions, then reduces the aligned reads to read equivalent classes, and uses this information to identify novel transcripts across all samples of interest. Reads are then assigned to transcripts, and expression estimates are obtained using an expectation maximisation algorithm. Here, we present an example workflow for analysing Nanopore long read RNA-Sequencing data from two human cancer cell lines from the Singapore Nanopore Expression Project (SG-NEx).

Quick start: Transcript discovery and quantification with bambu

Installation

You can install bambu from github:

General Usage

The default mode to run bambu is using a set of aligned reads (bam files), reference genome annotations (gtf file, TxDb object, or bambuAnnotation object), and reference genome sequence (fasta file or BSgenome). bambu will return a summarizedExperiment object with the genomic coordinates for annotated and new transcripts and transcript expression estimates. We highly recommend to use the same annotations that were used for genome alignment. If you have a gtf file and fasta file you can run bambu with the following options:

bambu returns a SummarizedExperiment object which can be accessed as follows:

A complete workflow to identify and quantify transcript expression from

Nanopore RNA-Seq data {#complete-workflow} To demonstrate the usage of Bambu, we used long-read RNA-Seq data generated using Oxford Nanopore Sequencing from the NanoporeRNASeq package, which consists of 6 samples from two human cell lines (K562 and MCF7) that were generated by the SG-NEx project. Each of these cell lines has three replicates, with 1 direct RNA sequencing run and 2 cDNA sequencing runs. Reads are aligned to chromosome 22 (Grch38) and stored as bam files. In this workflow, we will demonstrate how to apply bambu to these bam files to identify novel transcripts and estimates transcript expression, visualize the results, and identify differentially expressed genes and transcripts.

Input data

Genome sequence (fasta file/ BSGenome object)

bambu additionally requires a genome sequence, which is used to correct splicing junctions in read alignments. Ideally, we recommend to use the same genome seqeunce file that was used for alignment to be used for bambu.

As an option, users can also choose to use a BSgenome object:

Genome annotations (bambu annotations object/ gtf file / TxDb object)

{#annotations}
bambu also requires a reference transcript annotations object, which is used to correct read alignments, to identify for transcripts and genes (and the type for novel transcripts), and for quantification. The annotation object can be created from a gtf file:

The annotation object can also be created from a TxDb object:

The annotation object can be stored and used again for re-running bambu. Here we will used the annotation object from the NanoporeRNASeq package that wasis prepared from a gtf file using the function in by function in bambu.

Transcript discovery and quantification

Running bambu

Next we apply bambu on the input data (bam files, annotations, genomeSequence). Bambu will perform isoform discovery to extend the provided annotation, and then quantify the transcript expression from these extended annotation using an Expectation-Maximisation algorithm. Here we will use 1 core, which can be changed to process multiple files in parallel.

For the downstream analysis, we will add the condition of interest to the object that describes the samples. Here we are interested in a comparison of the 2 cell lines:

Optionally, users can choose to apply bambu to do quantification only (without isoform discovery)

Visualise results

bambu provides functions to visualise and explore the results. When multiple samples are used, we can visualise the correlation and clustering of all samples with a heatmap:

Additionally, we can also visualise the correlation with a 2-dimmensional PCA plot.

In addition to visualising the correlation between samples, bambu also provide a function to visualise the extended annotation and expression estimation for individual genes. Here we look at gene ENSG00000099968 and visualise the transcript coordinates for annotated and novel isoforms and expression levels for these isoforms across all samples.

##> [[1]]
##> TableGrob (3 x 1) "arrange": 3 grobs
##>   z     cells    name                grob
##> 1 1 (2-2,1-1) arrange      gtable[layout]
##> 2 2 (3-3,1-1) arrange      gtable[layout]
##> 3 3 (1-1,1-1) arrange text[GRID.text.250]

Obtain gene expression estimates from transcript expression

{#gene-expression} Gene expression can be calculated from the transcript expression estimates returned by bambu using the function. Looking at the output, we can see there are novel genes identified as well

We can again use the function to visualise the gene expression data across the 6 samples with a heatmap or PCA plot. As expected, samples from the same cell line showed higher correlation than across the cell lines.

Save data (gtf/text)

bambu includes a function to write the extended annotations, the transcript and the gene expression estimates that include any newly discovered genes and transcripts to text files.

bambu also includes a function that only exports the extended annotations to gtf file:

Identifying differentially expressed genes

One of the most common tasks when analysing RNA-Seq data is the analysis of differential gene expression across a condition of intertest. Here we use DESeq2 to find the differentially expressed genes between MCF7 and K562 cell lines. Similar to using results from Salmon, estimates from bambu will first be rounded.

library(DESeq2)
dds <- DESeqDataSetFromMatrix(round(assays(seGene)$counts), colData = colData(se),
    design = ~condition)
dds.deseq <- DESeq(dds)
deGeneRes <- DESeq2::results(dds.deseq, independentFiltering = FALSE)
head(deGeneRes[order(deGeneRes$padj), ])
##> log2 fold change (MLE): condition MCF7 vs K562 
##> Wald test p-value: condition MCF7 vs K562 
##> DataFrame with 6 rows and 6 columns
##>                  baseMean log2FoldChange     lfcSE      stat
##>                 <numeric>      <numeric> <numeric> <numeric>
##> ENSG00000185686  500.6470       -7.15159  0.500364 -14.29278
##> ENSG00000283633   95.7518       -9.10519  1.246517  -7.30451
##> ENSG00000197077   26.9189        9.17563  1.320390   6.94918
##> ENSG00000240972 2443.3934        2.47082  0.357369   6.91392
##> ENSG00000099977  235.8601        1.92963  0.306609   6.29347
##> ENSG00000169635   43.5245       -3.36897  0.569649  -5.91411
##>                                                                pvalue
##>                                                             <numeric>
##> ENSG00000185686 0.000000000000000000000000000000000000000000000242728
##> ENSG00000283633 0.000000000000278275679947602694397391918138592006762
##> ENSG00000197077 0.000000000003674139901044544811771829869715655608568
##> ENSG00000240972 0.000000000004714473225560826484330951067763324359265
##> ENSG00000099977 0.000000000310450546572332925146307722118438170155752
##> ENSG00000169635 0.000000003336692881462437529443458496432317605950857
##>                                                                padj
##>                                                           <numeric>
##> ENSG00000185686 0.0000000000000000000000000000000000000000000631093
##> ENSG00000283633 0.0000000000361758383931883483531512278605162501177
##> ENSG00000197077 0.0000000003064407596614537449075252608477826568589
##> ENSG00000240972 0.0000000003064407596614537449075252608477826568589
##> ENSG00000099977 0.0000000161434284217613106600419295823603538231339
##> ENSG00000169635 0.0000001445900248633722995599947686029551618958067

A quick summary of differentially expressed genes

We can also visualise the MA-plot for differentially used isoforms using . However, visualizing the MA-plots using the original log-fold change results will be affected by the noise associated with log2 fold changes from low count genes without requiring arbitrary filtering thresholds. As recommended in the [DESeq2tutorial] (http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/ DESeq2.html#alternative-shrinkage-estimators). we applied the same shrinkage to effect sizes to improve the visualization.

Identifying differential transcript usage

We used DEXSeq to detect alternative used isoforms.

We can visualize the MA-plot

Running bambu with large number of samples

For larger sample numbers we recommend to write the processed data to a file. This can be done by providing the readClass.outputDir:

se <- bambu(reads = bamFiles, rcOutDir = "./bambu/", annotations = annotaiton, genome = genomeSequence)

Bambu parameters

Advanced Options

For transcript discovery we recommend to adjust the parameters according to the number of replicates and the sequencing throughput. The most relevant parameters are explained here. You can use any combination of these parameters. ### More stringent filtering thresholds imposed on potential novel transcripts

Quantification without bias correction

The default estimation automatically does bias correction for expression estimates. However, you can choose to perform the quantification without bias correction.

Parallel computation

bambu allows parallel computation.

See our page for details to customize other conditions.

Getting help

Questions and issues can be raised at the Bioconductor support site (once bambu is available through bioconductor): https://support.bioconductor.org. Please tag your your posts with bambu.

Alternatively, issues can be raised at the bambu Github repository:https://github.com/GoekeLab/bambu.

Citing bambu

A manuscript describing bambu is currently in preparation. If you use bambu for your research, please cite using the following doi: 10.5281/zenodo.3900025.

Session Information

sessionInfo()
##> R version 4.1.2 (2021-11-01)
##> Platform: x86_64-pc-linux-gnu (64-bit)
##> Running under: Ubuntu 20.04.3 LTS
##> 
##> Matrix products: default
##> BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
##> LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
##> 
##> locale:
##>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##>  [3] LC_TIME=en_GB              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    stats     graphics  grDevices utils     datasets  methods  
##> [8] base     
##> 
##> other attached packages:
##>  [1] DEXSeq_1.40.0                         
##>  [2] RColorBrewer_1.1-2                    
##>  [3] AnnotationDbi_1.56.2                  
##>  [4] BiocParallel_1.28.3                   
##>  [5] apeglm_1.16.0                         
##>  [6] DESeq2_1.34.0                         
##>  [7] ggplot2_3.3.5                         
##>  [8] BSgenome.Hsapiens.NCBI.GRCh38_1.3.1000
##>  [9] Rsamtools_2.10.0                      
##> [10] NanoporeRNASeq_1.4.0                  
##> [11] ExperimentHub_2.2.1                   
##> [12] AnnotationHub_3.2.1                   
##> [13] BiocFileCache_2.2.1                   
##> [14] dbplyr_2.1.1                          
##> [15] bambu_2.0.6                           
##> [16] BSgenome_1.62.0                       
##> [17] rtracklayer_1.54.0                    
##> [18] Biostrings_2.62.0                     
##> [19] XVector_0.34.0                        
##> [20] SummarizedExperiment_1.24.0           
##> [21] Biobase_2.54.0                        
##> [22] GenomicRanges_1.46.1                  
##> [23] GenomeInfoDb_1.30.1                   
##> [24] IRanges_2.28.0                        
##> [25] S4Vectors_0.32.3                      
##> [26] BiocGenerics_0.40.0                   
##> [27] MatrixGenerics_1.6.0                  
##> [28] matrixStats_0.61.0                    
##> 
##> loaded via a namespace (and not attached):
##>   [1] utf8_1.2.2                    tidyselect_1.1.2             
##>   [3] RSQLite_2.2.10                htmlwidgets_1.5.4            
##>   [5] grid_4.1.2                    munsell_0.5.0                
##>   [7] codetools_0.2-18              statmod_1.4.36               
##>   [9] xgboost_1.5.2.1               withr_2.4.3                  
##>  [11] colorspace_2.0-3              filelock_1.0.2               
##>  [13] OrganismDbi_1.36.0            highr_0.9                    
##>  [15] knitr_1.37                    rstudioapi_0.13              
##>  [17] labeling_0.4.2                bbmle_1.0.24                 
##>  [19] GenomeInfoDbData_1.2.7        hwriter_1.3.2                
##>  [21] bit64_4.0.5                   farver_2.1.0                 
##>  [23] coda_0.19-4                   vctrs_0.3.8                  
##>  [25] generics_0.1.2                xfun_0.29                    
##>  [27] biovizBase_1.42.0             R6_2.5.1                     
##>  [29] doParallel_1.0.17             clue_0.3-60                  
##>  [31] locfit_1.5-9.4                AnnotationFilter_1.18.0      
##>  [33] bitops_1.0-7                  cachem_1.0.6                 
##>  [35] reshape_0.8.8                 DelayedArray_0.20.0          
##>  [37] assertthat_0.2.1              promises_1.2.0.1             
##>  [39] BiocIO_1.4.0                  scales_1.1.1                 
##>  [41] nnet_7.3-17                   gtable_0.3.0                 
##>  [43] ggbio_1.42.0                  ensembldb_2.18.3             
##>  [45] rlang_1.0.1                   genefilter_1.76.0            
##>  [47] GlobalOptions_0.1.2           splines_4.1.2                
##>  [49] lazyeval_0.2.2                dichromat_2.0-0              
##>  [51] checkmate_2.0.0               BiocManager_1.30.16          
##>  [53] yaml_2.3.5                    reshape2_1.4.4               
##>  [55] GenomicFeatures_1.46.4        backports_1.4.1              
##>  [57] httpuv_1.6.5                  Hmisc_4.6-0                  
##>  [59] RBGL_1.70.0                   tools_4.1.2                  
##>  [61] ellipsis_0.3.2                jquerylib_0.1.4              
##>  [63] Rcpp_1.0.8                    plyr_1.8.6                   
##>  [65] base64enc_0.1-3               progress_1.2.2               
##>  [67] zlibbioc_1.40.0               purrr_0.3.4                  
##>  [69] RCurl_1.98-1.6                prettyunits_1.1.1            
##>  [71] rpart_4.1.16                  GetoptLong_1.0.5             
##>  [73] cluster_2.1.2                 magrittr_2.0.2               
##>  [75] data.table_1.14.2             magick_2.7.3                 
##>  [77] circlize_0.4.14               mvtnorm_1.1-3                
##>  [79] ProtGenerics_1.26.0           hms_1.1.1                    
##>  [81] mime_0.12                     evaluate_0.15                
##>  [83] xtable_1.8-4                  XML_3.99-0.9                 
##>  [85] emdbook_1.3.12                jpeg_0.1-9                   
##>  [87] gridExtra_2.3                 shape_1.4.6                  
##>  [89] bdsmatrix_1.3-4               compiler_4.1.2               
##>  [91] biomaRt_2.50.3                tibble_3.1.6                 
##>  [93] crayon_1.5.0                  htmltools_0.5.2              
##>  [95] later_1.3.0                   Formula_1.2-4                
##>  [97] tidyr_1.2.0                   geneplotter_1.72.0           
##>  [99] DBI_1.1.2                     formatR_1.11                 
##> [101] ComplexHeatmap_2.10.0         MASS_7.3-55                  
##> [103] rappdirs_0.3.3                Matrix_1.4-0                 
##> [105] cli_3.2.0                     parallel_4.1.2               
##> [107] pkgconfig_2.0.3               GenomicAlignments_1.30.0     
##> [109] numDeriv_2016.8-1.1           foreign_0.8-82               
##> [111] xml2_1.3.3                    foreach_1.5.2                
##> [113] annotate_1.72.0               bslib_0.3.1                  
##> [115] stringr_1.4.0                 VariantAnnotation_1.40.0     
##> [117] digest_0.6.29                 graph_1.72.0                 
##> [119] rmarkdown_2.11                htmlTable_2.4.0              
##> [121] restfulr_0.0.13               curl_4.3.2                   
##> [123] shiny_1.7.1                   rjson_0.2.21                 
##> [125] lifecycle_1.0.1               jsonlite_1.8.0               
##> [127] fansi_1.0.2                   pillar_1.7.0                 
##> [129] lattice_0.20-45               GGally_2.1.2                 
##> [131] KEGGREST_1.34.0               fastmap_1.1.0                
##> [133] httr_1.4.2                    survival_3.2-13              
##> [135] interactiveDisplayBase_1.32.0 glue_1.6.1                   
##> [137] png_0.1-7                     iterators_1.0.14             
##> [139] BiocVersion_3.14.0            bit_4.0.4                    
##> [141] stringi_1.7.6                 sass_0.4.0                   
##> [143] blob_1.2.2                    latticeExtra_0.6-29          
##> [145] memoise_2.0.1                 dplyr_1.0.8