An introduction to the bambu package using NanoporeRNASeq data

Introduction

NanoporeRNASeq contains RNA-Seq data from the K562 and MCF7 cell lines that were generated by the SG-NEx project (https://github.com/GoekeLab/sg-nex-data). Each of these cell line has three replicates, with 1 direct RNA sequencing data and 2 cDNA sequencing data. The files contains reads aligned to the human genome (Grch38) chromosome 22 (1:25500000).

Accessing NanoporeRNASeq data

Load the NanoporeRNASeq package

library("NanoporeRNASeq")

List the samples

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..

List the available BamFile

library(ExperimentHub)
NanoporeData <- query(ExperimentHub(), c("NanoporeRNA", "GRCh38", "Bam"))
bamFiles <- Rsamtools::BamFileList(NanoporeData[["EH3808"]], NanoporeData[["EH3809"]],
    NanoporeData[["EH3810"]], NanoporeData[["EH3811"]], NanoporeData[["EH3812"]],
    NanoporeData[["EH3813"]])

Get the annotation GRangesList

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>

Visualizing gene of interest from a single bam file

We can visualize the one sample for a single gene ENST00000215832 (MAPK1)

library(ggbio)
range <- HsChr22BambuAnnotation$ENST00000215832
# plot mismatch track
library(BSgenome.Hsapiens.NCBI.GRCh38)
# plot annotation track
tx <- autoplot(range, aes(col = strand), group.selfish = TRUE)
# plot coverage track
coverage <- autoplot(bamFiles[[1]], aes(col = coverage), which = range)

# merge the tracks into one plot
tracks(annotation = tx, coverage = coverage, heights = c(1, 3)) + theme_minimal()

Running Bambu with NanoporeRNASeq data

Load the bambu package

library(bambu)
genomeSequenceData <- query(ExperimentHub(), c("NanoporeRNA", "GRCh38", "FASTA"))
genomeSequence <- genomeSequenceData[["EH7260"]]

Run bambu

Applying bambu to bamFiles

se <- bambu(reads = bamFiles, annotations = HsChr22BambuAnnotation, genome = genomeSequence)

bambu returns a SummarizedExperiment object

se
##> class: RangedSummarizedExperiment 
##> dim: 1541 6 
##> metadata(2): incompatibleCounts warnings
##> assays(4): counts CPM fullLengthCounts uniqueCounts
##> rownames(1541): BambuTx1 BambuTx2 ... ENST00000641933 ENST00000641967
##> rowData names(11): TXNAME GENEID ... txid eqClassById
##> colnames(6): 1bcf825b06e66b_3844 1bcf823ea8a513_3846 ...
##>   1bcf8233768b09_3852 1bcf822129a24c_3854
##> colData names(1): name

Visualizing gene examples

We can visualize the annotated and novel isoforms identified in this gene example using plot functions from bambu

plotBambu(se, type = "annotation", gene_id = "ENSG00000099968")

##> [[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.248]
sessionInfo()
##> R version 4.3.0 RC (2023-04-13 r84269)
##> Platform: x86_64-pc-linux-gnu (64-bit)
##> Running under: Ubuntu 22.04.2 LTS
##> 
##> Matrix products: default
##> BLAS:   /home/biocbuild/bbs-3.17-bioc/R/lib/libRblas.so 
##> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##> 
##> 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       
##> 
##> time zone: America/New_York
##> tzcode source: system (glibc)
##> 
##> attached base packages:
##> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
##> [8] base     
##> 
##> other attached packages:
##>  [1] bambu_3.2.0                           
##>  [2] SummarizedExperiment_1.30.0           
##>  [3] Biobase_2.60.0                        
##>  [4] MatrixGenerics_1.12.0                 
##>  [5] matrixStats_0.63.0                    
##>  [6] BSgenome.Hsapiens.NCBI.GRCh38_1.3.1000
##>  [7] BSgenome_1.68.0                       
##>  [8] rtracklayer_1.60.0                    
##>  [9] ggbio_1.48.0                          
##> [10] ggplot2_3.4.2                         
##> [11] Rsamtools_2.16.0                      
##> [12] Biostrings_2.68.0                     
##> [13] XVector_0.40.0                        
##> [14] GenomicRanges_1.52.0                  
##> [15] GenomeInfoDb_1.36.0                   
##> [16] IRanges_2.34.0                        
##> [17] S4Vectors_0.38.0                      
##> [18] NanoporeRNASeq_1.10.0                 
##> [19] ExperimentHub_2.8.0                   
##> [20] AnnotationHub_3.8.0                   
##> [21] BiocFileCache_2.8.0                   
##> [22] dbplyr_2.3.2                          
##> [23] BiocGenerics_0.46.0                   
##> 
##> loaded via a namespace (and not attached):
##>   [1] RColorBrewer_1.1-3            rstudioapi_0.14              
##>   [3] jsonlite_1.8.4                magrittr_2.0.3               
##>   [5] GenomicFeatures_1.52.0        farver_2.1.1                 
##>   [7] rmarkdown_2.21                BiocIO_1.10.0                
##>   [9] zlibbioc_1.46.0               vctrs_0.6.2                  
##>  [11] memoise_2.0.1                 RCurl_1.98-1.12              
##>  [13] base64enc_0.1-3               htmltools_0.5.5              
##>  [15] progress_1.2.2                curl_5.0.0                   
##>  [17] xgboost_1.7.5.1               Formula_1.2-5                
##>  [19] sass_0.4.5                    bslib_0.4.2                  
##>  [21] htmlwidgets_1.6.2             plyr_1.8.8                   
##>  [23] cachem_1.0.7                  GenomicAlignments_1.36.0     
##>  [25] mime_0.12                     lifecycle_1.0.3              
##>  [27] pkgconfig_2.0.3               Matrix_1.5-4                 
##>  [29] R6_2.5.1                      fastmap_1.1.1                
##>  [31] GenomeInfoDbData_1.2.10       shiny_1.7.4                  
##>  [33] digest_0.6.31                 colorspace_2.1-0             
##>  [35] GGally_2.1.2                  reshape_0.8.9                
##>  [37] OrganismDbi_1.42.0            AnnotationDbi_1.62.0         
##>  [39] Hmisc_5.0-1                   RSQLite_2.3.1                
##>  [41] labeling_0.4.2                filelock_1.0.2               
##>  [43] fansi_1.0.4                   httr_1.4.5                   
##>  [45] compiler_4.3.0                bit64_4.0.5                  
##>  [47] withr_2.5.0                   htmlTable_2.4.1              
##>  [49] backports_1.4.1               BiocParallel_1.34.0          
##>  [51] DBI_1.1.3                     highr_0.10                   
##>  [53] biomaRt_2.56.0                rappdirs_0.3.3               
##>  [55] DelayedArray_0.26.0           rjson_0.2.21                 
##>  [57] tools_4.3.0                   foreign_0.8-84               
##>  [59] interactiveDisplayBase_1.38.0 httpuv_1.6.9                 
##>  [61] nnet_7.3-18                   glue_1.6.2                   
##>  [63] restfulr_0.0.15               promises_1.2.0.1             
##>  [65] grid_4.3.0                    checkmate_2.1.0              
##>  [67] cluster_2.1.4                 reshape2_1.4.4               
##>  [69] generics_0.1.3                gtable_0.3.3                 
##>  [71] tidyr_1.3.0                   ensembldb_2.24.0             
##>  [73] data.table_1.14.8             hms_1.1.3                    
##>  [75] xml2_1.3.3                    utf8_1.2.3                   
##>  [77] BiocVersion_3.17.1            pillar_1.9.0                 
##>  [79] stringr_1.5.0                 later_1.3.0                  
##>  [81] dplyr_1.1.2                   lattice_0.21-8               
##>  [83] bit_4.0.5                     biovizBase_1.48.0            
##>  [85] RBGL_1.76.0                   tidyselect_1.2.0             
##>  [87] knitr_1.42                    gridExtra_2.3                
##>  [89] ProtGenerics_1.32.0           xfun_0.39                    
##>  [91] stringi_1.7.12                lazyeval_0.2.2               
##>  [93] yaml_2.3.7                    evaluate_0.20                
##>  [95] codetools_0.2-19              tibble_3.2.1                 
##>  [97] graph_1.78.0                  BiocManager_1.30.20          
##>  [99] cli_3.6.1                     rpart_4.1.19                 
##> [101] xtable_1.8-4                  munsell_0.5.0                
##> [103] jquerylib_0.1.4               dichromat_2.0-0.1            
##> [105] Rcpp_1.0.10                   png_0.1-8                    
##> [107] XML_3.99-0.14                 parallel_4.3.0               
##> [109] ellipsis_0.3.2                blob_1.2.4                   
##> [111] prettyunits_1.1.1             AnnotationFilter_1.24.0      
##> [113] bitops_1.0-7                  VariantAnnotation_1.46.0     
##> [115] scales_1.2.1                  purrr_1.0.1                  
##> [117] crayon_1.5.2                  rlang_1.1.0                  
##> [119] KEGGREST_1.40.0               formatR_1.14