1 Introduction

Many eukaryotic genes give rise to multiple RNA isoforms, increasing the protein-coding capacity of the genome and extending the range of post-transcriptional regulation possibilities. High-throughput sequencing is often used to deduce repertoires of transcripts expressed in specific biological samples by aligning the data to genomic sequences and assembling the alignments into transcript architectures. This typically outputs Gene Transfer Format (GTF) files describing newly identified transcripts as sets of exonic coordinates, but lacking the information about their coding sequences (CDSs; also known as ORFs) and possible biological functions.

To this end, we developed a package for functional annotation of custom-assembled transcriptomes in R (factR). factR predicts CDSs for novel RNA isoforms using a reference-guided process and then determines domain organisation of the protein products and possible susceptibility of transcripts to nonsense-mediated decay (NMD; a pathway destabilizing mRNAs with premature translation termination codons). factR also provides supporting tools for matching new transcripts to “official” gene IDs, visualizing transcript architectures and annotating alternatively spliced segments.

2 Getting started

2.1 Installing factR

To install factR, enter the following commands in your R environment:

2.2 Materials needed

2.2.1 Custom-assembled transcriptome

factR requires a custom transcriptome file in the GTF format as an input, and we provide the following three sample custom transcriptome files that can be used to test factR tools:

  1. bulk_merged_sample.gtf.gz assembled using the HISAT2-StringtTie2 pipeline (Pertea et al. 2016) from bulk RNA-seq data for mouse embryonic stem cells treated with the NMD inhibitor cycloheximide (CHX) or left untreated as a control.
  2. sc_merged_sample.gtf.gz assembled using the HISAT2-StringtTie2 pipeline from single-cell RNA-seq data for glutamatergic neurons, GABAergic neurons, astrocytes or endothelial cells from the mouse visual cortex (Tasic et al. 2018). A simplified version of this GTF containing the first 500 genes on chr15 is available as part of factR.
  3. lr_merged_sample.gtf.gz assembled using minimap2 (Li 2018) and StringtTie2 (Kovaka et al. 2019) from brain-specific long-read Oxford Nanopore RNA sequencing data (Sessegolo et al. 2019).

Method to download the above GTF files is described in the “Importing and inspecting GTF data” section below.
Users may alternatively prepare their own GTF files making sure that these contain both gene_id and transcript_id attributes.

2.2.2 Reference transcriptome

Several factR functions require reference transcriptome files (GTF or GFF3) as a guide. Such files can be accessed from within the R environment using e.g.  the R package AnnotationHub or downloaded from an external database such as GENCODE or Ensembl. Both possibilities are described in the “Updating gene info” section below.

2.2.3 Genome

factR needs genomic DNA sequence to predict CDSs. Users may obtain genome files using e.g. BSgenome or AnnotationHub or download them from an external database such as GENCODE or Ensembl. We describe this in more detail in the “Constructing CDS information” section below.

3 Using factR

Load factR to the R environment as follows:

3.1 Importing and inspecting GTF data

factR handles transcriptome information in the form of GenomicRanges objects containing genomic interval data and relevant metadata. To create such an object from a GTF file, we use the importGTF function:

The imported GTF file is stored as a GenomicRanges object.

Contents of the object can be examined using head:

In addition to genomic coordinates (seqnames and ranges), a typical GTF file contains metadata describing the feature type (e.g. transcript or exon), transcript IDs and some information on their parental genes.

Use the following command to calculate the total number of transcripts in the input transcriptome:

Note that none of the transcripts in the custom.gtf object contain CDS information:

3.2 Plotting transcript structures

Users may visualize specific sets of transcripts using viewTranscripts. For example, the following will plot transcripts from the Zfr gene encoding a conserved zinc finger-containing RNA-binding protein with known neuronal functions :

StringTie2, a popular transcript assembler used to generate our custom GTF, typically assigns arbitrary names to newly identified transcripts (e.g. “MSTRG.x.y”) and uses the same prefix for their gene IDs (e.g. “MSTRG.x”). Incidentally, this is why the output above contains 10 previously known Zfr transcripts but lacks any novel entries.

3.3 Updating gene info

factR can update gene metadata in custom transcriptome objects using a reference annotation as guide. Below, we describe two alternative ways to obtain mouse reference transcriptome data from GENCODE.

  1. Using AnnotationHub package
  1. Downloading from a GENCODE database (ref.gtf generated from this method will be used for the remaining of the workflow)

When choosing a reference, users should consider using one with the same chromosome naming style (e.g. “chr1” or “1”). Alternatively, the styles can be matched using the matchChromosomes function (see help(matchChromosomes) for more detail).

Once the ref.gtf object is ready, novel transcripts in custom.gtf can be assigned to “official” gene IDs, whenever possible, using matchGeneInfo. By default, this function matches the query (custom.gtf) to the reference (ref.gtf) by finding overlapping coordinates:

To tune the performance of matchGeneInfo, we provide additional arguments specifying the name of columns containing “primary” and potentially “secondary” gene IDs from the query (custom.gtf). For further information, see help(matchGeneInfo).

Note that custom.gtf updated by matchGeneInfo now contains 10 known and 7 newly Zfr assembled transcripts:

3.4 Shortlisting novel transcripts

As seen in the above example, custom transcriptomes typically combine both new and previously annotated transcripts. To select only newly predicted transcripts, run the following:

This will subset custom.gtf transcripts with distinct exonic coordinates compared to ref.gtf and will store these transcripts in the custom_new.gtf object. Some custom-built transcripts may differ from their reference counterparts by having different start or/and end coordinates, with otherwise similar exon-intron structure. To shortlist novel transcripts with distinct intronic coordinates only, simply set the “refine.by” argument to “intron”:

We will use the custom_new.gtf object in the rest of the workflow.

3.5 Constructing CDS information

Functional annotation of newly assembled transcripts in factR begins by deducing their protein-coding sequences (CDSs). To search for putative CDSs, factR requires a genome sequence file, which can be obtained using R packages or downloaded from online databases (e.g. UCSC, GENCODE or Ensembl). Three alternative ways to retrieve mouse genomic sequence are described below.

  1. Using BSgenome (Mmusculus generated from this method will be used for the remaining of the workflow) This package supports most sequenced genomes. Mouse mm10 sequence can be downloaded as follows:

and loaded into R environment:

  1. Using AnnotationHub
  1. Downloading from a database (e.g. GENCODE)

Once the genome sequence object is ready, factR can predict CDSs using its buildCDS() function and reference transcriptome data as a guide. buildCDS() first generates a database of previously annotated ATGs and uses this information to search for a potential translation start sites in query transcripts. buildCDS() then deduces the CDS and appends its coordinates to the custom transcriptome object. Let’s run this function for our novel transcripts:

Note that the novel Zfr transcripts have been updated with information about likely CDSs (dark blue) and untranslated regions (light blue) :

We can display exonic regions and CDSs more clearly (at the expense of loosing their bona fide genomic coordinates) by setting rescale_intron argument to TRUE.

For comparison, here is the CDS situation in the reference Zfr transcripts:

3.7 Predicting protein domains

factR can also inspect domain structure of protein products encoded by newly identified mRNA isoforms using its predictDomains() function. This requires connection to the online PFAM database and may require a substantial amount of time and stable internet connection to query multiple transcripts simultaneously. To quickly explore functionality of the predictDomains() tool, users may prefer to begin with a relatively small subset of transcripts. For example, the following will predict domain structure for all transcripts of the Zfr gene:

The domain architectures for the set of query proteins can be additionally plotted by switching the argument “plot” to TRUE:

If you want to predict domains for all new transcripts and do not mind waiting for some time depending on the connection speed and the PFAM server load, run the following:

3.8 Export output objects

Annotated custom_new_CDS.gtf object can be exported to a GTF file as follows:

Finally, to export NMDprediction.out and domains.out data frames as tab-delimited text files, run the following:

4 Citing factR

Please cite factR if you find it useful:

5 Session Information

This workflow was conducted on:

sessionInfo()  
#> R version 4.2.1 (2022-06-23)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.16-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] forcats_0.5.2                      stringr_1.4.1                     
#>  [3] dplyr_1.0.10                       purrr_0.3.5                       
#>  [5] readr_2.1.3                        tidyr_1.2.1                       
#>  [7] tibble_3.1.8                       ggplot2_3.3.6                     
#>  [9] tidyverse_1.3.2                    GenomicFeatures_1.50.0            
#> [11] AnnotationDbi_1.60.0               Biobase_2.58.0                    
#> [13] BSgenome.Mmusculus.UCSC.mm10_1.4.3 BSgenome_1.66.0                   
#> [15] rtracklayer_1.58.0                 GenomicRanges_1.50.0              
#> [17] Biostrings_2.66.0                  GenomeInfoDb_1.34.0               
#> [19] XVector_0.38.0                     IRanges_2.32.0                    
#> [21] S4Vectors_0.36.0                   AnnotationHub_3.6.0               
#> [23] BiocFileCache_2.6.0                dbplyr_2.2.1                      
#> [25] BiocGenerics_0.44.0                factR_1.0.0                       
#> 
#> loaded via a namespace (and not attached):
#>   [1] googledrive_2.0.0             colorspace_2.0-3             
#>   [3] rjson_0.2.21                  ellipsis_0.3.2               
#>   [5] fs_1.5.2                      farver_2.1.1                 
#>   [7] bit64_4.0.5                   interactiveDisplayBase_1.36.0
#>   [9] fansi_1.0.3                   lubridate_1.8.0              
#>  [11] xml2_1.3.3                    codetools_0.2-18             
#>  [13] cachem_1.0.6                  knitr_1.40                   
#>  [15] jsonlite_1.8.3                wiggleplotr_1.22.0           
#>  [17] Rsamtools_2.14.0              broom_1.0.1                  
#>  [19] png_0.1-7                     shiny_1.7.3                  
#>  [21] BiocManager_1.30.19           compiler_4.2.1               
#>  [23] httr_1.4.4                    backports_1.4.1              
#>  [25] assertthat_0.2.1              Matrix_1.5-1                 
#>  [27] fastmap_1.1.0                 gargle_1.2.1                 
#>  [29] cli_3.4.1                     later_1.3.0                  
#>  [31] htmltools_0.5.3               prettyunits_1.1.1            
#>  [33] tools_4.2.1                   gtable_0.3.1                 
#>  [35] glue_1.6.2                    GenomeInfoDbData_1.2.9       
#>  [37] rappdirs_0.3.3                Rcpp_1.0.9                   
#>  [39] cellranger_1.1.0              jquerylib_0.1.4              
#>  [41] vctrs_0.5.0                   xfun_0.34                    
#>  [43] rvest_1.0.3                   mime_0.12                    
#>  [45] lifecycle_1.0.3               restfulr_0.0.15              
#>  [47] XML_3.99-0.12                 googlesheets4_1.0.1          
#>  [49] zlibbioc_1.44.0               scales_1.2.1                 
#>  [51] hms_1.1.2                     promises_1.2.0.1             
#>  [53] MatrixGenerics_1.10.0         parallel_4.2.1               
#>  [55] SummarizedExperiment_1.28.0   yaml_2.3.6                   
#>  [57] curl_4.3.3                    pbapply_1.5-0                
#>  [59] memoise_2.0.1                 sass_0.4.2                   
#>  [61] biomaRt_2.54.0                stringi_1.7.8                
#>  [63] RSQLite_2.2.18                highr_0.9                    
#>  [65] BiocVersion_3.16.0            BiocIO_1.8.0                 
#>  [67] filelock_1.0.2                BiocParallel_1.32.0          
#>  [69] rlang_1.0.6                   pkgconfig_2.0.3              
#>  [71] matrixStats_0.62.0            bitops_1.0-7                 
#>  [73] evaluate_0.17                 lattice_0.20-45              
#>  [75] labeling_0.4.2                patchwork_1.1.2              
#>  [77] GenomicAlignments_1.34.0      bit_4.0.4                    
#>  [79] tidyselect_1.2.0              magrittr_2.0.3               
#>  [81] R6_2.5.1                      generics_0.1.3               
#>  [83] DelayedArray_0.24.0           DBI_1.1.3                    
#>  [85] withr_2.5.0                   pillar_1.8.1                 
#>  [87] haven_2.5.1                   KEGGREST_1.38.0              
#>  [89] RCurl_1.98-1.9                modelr_0.1.9                 
#>  [91] crayon_1.5.2                  utf8_1.2.2                   
#>  [93] tzdb_0.3.0                    rmarkdown_2.17               
#>  [95] progress_1.2.2                readxl_1.4.1                 
#>  [97] grid_4.2.1                    data.table_1.14.4            
#>  [99] blob_1.2.3                    reprex_2.0.2                 
#>  [ reached getOption("max.print") -- omitted 5 entries ]

References

Kovaka, Sam, Aleksey V. Zimin, Geo M. Pertea, Roham Razaghi, Steven L. Salzberg, and Mihaela Pertea. 2019. “Transcriptome Assembly from Long-Read Rna-Seq Alignments with Stringtie2.” Genome Biology 20 (1): 278. https://doi.org/10.1186/s13059-019-1910-1.

Li, Heng. 2018. “Minimap2: Pairwise Alignment for Nucleotide Sequences.” Bioinformatics 34 (18): 3094–3100. https://doi.org/10.1093/bioinformatics/bty191.

Pertea, Mihaela, Daehwan Kim, Geo M. Pertea, Jeffrey T. Leek, and Steven L. Salzberg. 2016. “Transcript-Level Expression Analysis of Rna-Seq Experiments with Hisat, Stringtie and Ballgown.” Nature Protocols 11 (9): 1650–67. https://doi.org/10.1038/nprot.2016.095.

Sessegolo, Camille, Corinne Cruaud, Corinne Da Silva, Audric Cologne, Marion Dubarry, Thomas Derrien, Vincent Lacroix, and Jean-Marc Aury. 2019. “Transcriptome Profiling of Mouse Samples Using Nanopore Sequencing of cDNA and Rna Molecules.” Scientific Reports 9 (1): 14908. https://doi.org/10.1038/s41598-019-51470-9.

Tasic, Bosiljka, Zizhen Yao, Lucas T. Graybuck, Kimberly A. Smith, Thuc Nghi Nguyen, Darren Bertagnolli, Jeff Goldy, et al. 2018. “Shared and Distinct Transcriptomic Cell Types Across Neocortical Areas.” Nature 563 (7729): 72–78. https://doi.org/10.1038/s41586-018-0654-5.