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).
You can install bambu from github:
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:
library(bambu)
test.bam <- system.file("extdata", "SGNex_A549_directRNA_replicate5_run1_chr9_1_1000000.bam",
package = "bambu")
fa.file <- system.file("extdata", "Homo_sapiens.GRCh38.dna_sm.primary_assembly_chr9_1_1000000.fa",
package = "bambu")
gtf.file <- system.file("extdata", "Homo_sapiens.GRCh38.91_chr9_1_1000000.gtf", package = "bambu")
bambuAnnotations <- prepareAnnotations(gtf.file)
se <- bambu(reads = test.bam, annotations = bambuAnnotations, genome = fa.file)
##>
|
| | 0%
|
|======================================================================| 100%
##>
##>
|
| | 0%
|
|======================================================================| 100%
##>
##>
|
| | 0%
|
|======================================================================| 100%
##>
##>
|
| | 0%
|
|======================================================================| 100%
##>
##>
|
| | 0%
|
|======================================================================| 100%
##>
##>
|
| | 0%
|
|======================================================================| 100%
bambu returns a SummarizedExperiment object which can be accessed as follows:
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.
bambu takes genomic alignments saved in bam files. Here we use bam-files from the NanoporeRNASeq package, which contains reads aligned to the first half of the human chromosome 22 using minimap2.
library(bambu)
library(NanoporeRNASeq)
data("SGNexSamples")
SGNexSamples
##> DataFrame with 6 rows and 6 columns
##> sample_id Platform cellLine protocol cancer_type
##> <character> <character> <character> <character> <character>
##> 1 K562_directcDNA_repl.. MinION K562 directcDNA Leukocyte
##> 2 K562_directcDNA_repl.. GridION K562 directcDNA Leukocyte
##> 3 K562_directRNA_repli.. GridION K562 directRNA Leukocyte
##> 4 MCF7_directcDNA_repl.. MinION MCF7 directcDNA Breast
##> 5 MCF7_directcDNA_repl.. GridION MCF7 directcDNA Breast
##> 6 MCF7_directRNA_repli.. GridION MCF7 directRNA Breast
##> fileNames
##> <character>
##> 1 NanoporeRNASeq/versi..
##> 2 NanoporeRNASeq/versi..
##> 3 NanoporeRNASeq/versi..
##> 4 NanoporeRNASeq/versi..
##> 5 NanoporeRNASeq/versi..
##> 6 NanoporeRNASeq/versi..
library(ExperimentHub)
NanoporeData <- query(ExperimentHub(), c("NanoporeRNA", "GRCh38", "BAM"))
bamFiles <- Rsamtools::BamFileList(NanoporeData[["EH3808"]], NanoporeData[["EH3809"]],
NanoporeData[["EH3810"]], NanoporeData[["EH3811"]], NanoporeData[["EH3812"]],
NanoporeData[["EH3813"]])
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.
# get path to fasta file
genomeSequenceData <- query(ExperimentHub(), c("NanoporeRNA", "GRCh38", "FASTA"))
genomeSequence <- genomeSequenceData[["EH7260"]]
As an option, users can also choose to use a BSgenome 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:
gtf.file <- system.file("extdata", "Homo_sapiens.GRCh38.91_chr9_1_1000000.gtf", package = "bambu")
annotation <- prepareAnnotations(gtf.file)
The annotation object can also be created from a TxDb object:
txdb <- system.file("extdata", "Homo_sapiens.GRCh38.91_chr9_1_1000000.gtf", package = "bambu")
annotation <- prepareAnnotations(txdb)
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.
data("HsChr22BambuAnnotation")
HsChr22BambuAnnotation
##> GRangesList object of length 1500:
##> $ENST00000043402
##> GRanges object with 2 ranges and 2 metadata columns:
##> seqnames ranges strand | exon_rank exon_endRank
##> <Rle> <IRanges> <Rle> | <integer> <integer>
##> [1] 22 20241415-20243110 - | 2 1
##> [2] 22 20268071-20268531 - | 1 2
##> -------
##> seqinfo: 1 sequence from an unspecified genome; no seqlengths
##>
##> $ENST00000086933
##> GRanges object with 3 ranges and 2 metadata columns:
##> seqnames ranges strand | exon_rank exon_endRank
##> <Rle> <IRanges> <Rle> | <integer> <integer>
##> [1] 22 19148576-19149095 - | 3 1
##> [2] 22 19149663-19149916 - | 2 2
##> [3] 22 19150025-19150283 - | 1 3
##> -------
##> seqinfo: 1 sequence from an unspecified genome; no seqlengths
##>
##> $ENST00000155674
##> GRanges object with 8 ranges and 2 metadata columns:
##> seqnames ranges strand | exon_rank exon_endRank
##> <Rle> <IRanges> <Rle> | <integer> <integer>
##> [1] 22 17137511-17138357 - | 8 1
##> [2] 22 17138550-17138738 - | 7 2
##> [3] 22 17141059-17141233 - | 6 3
##> [4] 22 17143098-17143131 - | 5 4
##> [5] 22 17145024-17145117 - | 4 5
##> [6] 22 17148448-17148560 - | 3 6
##> [7] 22 17149542-17149745 - | 2 7
##> [8] 22 17165209-17165287 - | 1 8
##> -------
##> seqinfo: 1 sequence from an unspecified genome; no seqlengths
##>
##> ...
##> <1497 more elements>
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.
se <- bambu(reads = bamFiles, annotations = HsChr22BambuAnnotation, genome = genomeSequence,
ncore = 1)
se
##> class: RangedSummarizedExperiment
##> dim: 1511 6
##> metadata(0):
##> assays(6): counts CPM ... uniqueCounts theta
##> rownames(1511): tx.1 tx.2 ... ENST00000641933 ENST00000641967
##> rowData names(6): TXNAME GENEID ... readCount txNDR
##> colnames(6): 21ce5934bf7470_3844 21ce597a36eb_3846 ...
##> 21ce596d274518_3852 21ce591fdf695a_3854
##> colData names(3): name d_rate nGeneFordRate
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)
seUnextended <- bambu(reads = bamFiles, annotations = HsChr22BambuAnnotation, genome = genomeSequence,
discovery = FALSE)
seUnextended
##> class: RangedSummarizedExperiment
##> dim: 1500 6
##> metadata(0):
##> assays(6): counts CPM ... uniqueCounts theta
##> rownames(1500): ENST00000043402 ENST00000086933 ... ENST00000641933
##> ENST00000641967
##> rowData names(3): TXNAME GENEID eqClass
##> colnames(6): 21ce5934bf7470_3844 21ce597a36eb_3846 ...
##> 21ce596d274518_3852 21ce591fdf695a_3854
##> colData names(3): name d_rate nGeneFordRate
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]
{#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
seGene <- transcriptToGeneExpression(se)
seGene
##> class: RangedSummarizedExperiment
##> dim: 574 6
##> metadata(0):
##> assays(2): counts CPM
##> rownames(574): ENSG00000015475 ENSG00000040608 ... gene.43 gene.45
##> rowData names(2): GENEID newGeneClass
##> colnames(6): 21ce5934bf7470_3844 21ce597a36eb_3846 ...
##> 21ce596d274518_3852 21ce591fdf695a_3854
##> colData names(4): name d_rate nGeneFordRate condition
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.
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:
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
summary(deGeneRes)
##>
##> out of 260 with nonzero total read count
##> adjusted p-value < 0.1
##> LFC > 0 (up) : 19, 7.3%
##> LFC < 0 (down) : 22, 8.5%
##> outliers [1] : 0, 0%
##> low counts [2] : 0, 0%
##> (mean count < 0)
##> [1] see 'cooksCutoff' argument of ?results
##> [2] see 'independentFiltering' argument of ?results
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.
We used DEXSeq to detect alternative used isoforms.
library(DEXSeq)
dxd <- DEXSeqDataSet(countData = round(assays(se)$counts), sampleData = as.data.frame(colData(se)),
design = ~sample + exon + condition:exon, featureID = rowData(se)$TXNAME, groupID = rowData(se)$GENEID)
dxr <- DEXSeq(dxd)
head(dxr)
##>
##> LRT p-value: full vs reduced
##>
##> DataFrame with 6 rows and 12 columns
##> groupID featureID exonBaseMean dispersion
##> <character> <character> <numeric> <numeric>
##> gene.30:tx.1 gene.30 tx.1 9.059656 NA
##> gene.35:tx.2 gene.35 tx.2 1.046280 NA
##> gene.12:tx.3 gene.12 tx.3 1.054917 NA
##> ENSG00000184702:tx.4 ENSG00000184702 tx.4 32.603977 0.904929
##> ENSG00000183506:tx.5 ENSG00000183506 tx.5 14.804874 1.399618
##> gene.45:tx.6 gene.45 tx.6 0.767463 NA
##> stat pvalue padj K562 MCF7
##> <numeric> <numeric> <numeric> <numeric> <numeric>
##> gene.30:tx.1 NA NA NA NA NA
##> gene.35:tx.2 NA NA NA NA NA
##> gene.12:tx.3 NA NA NA NA NA
##> ENSG00000184702:tx.4 1.86587 0.171949 0.591465 1.31079 1.64896
##> ENSG00000183506:tx.5 1.32103 0.250408 0.631580 1.06310 1.20895
##> gene.45:tx.6 NA NA NA NA NA
##> log2fold_MCF7_K562 genomicData countData
##> <numeric> <GRangesList> <matrix>
##> gene.30:tx.1 NA 36:48:5:...
##> gene.35:tx.2 NA 9:5:0:...
##> gene.12:tx.3 NA 8:3:2:...
##> ENSG00000184702:tx.4 1.16294 24:132:88:...
##> ENSG00000183506:tx.5 0.52293 43:61:24:...
##> gene.45:tx.6 NA 5:5:0:...
We can visualize the MA-plot
For larger sample numbers we recommend to write the processed data to a file. This can be done by providing the readClass.outputDir:
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
The default estimation automatically does bias correction for expression estimates. However, you can choose to perform the quantification without bias correction.
bambu allows parallel computation.
See our page for details to customize other conditions.
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.
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.
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