diff --git a/.Rbuildignore b/.Rbuildignore
index 83390479..9564bfe0 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -2,3 +2,5 @@
^\.Rproj\.user$
^packrat/
^\.Rprofile$
+^doc$
+^Meta$
diff --git a/.gitignore b/.gitignore
index 6b9f0569..2126ec2e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,5 @@ vignettes/*.pdf
.Renviron
packrat/lib*/
.Rproj.user
+doc
+Meta
diff --git a/DESCRIPTION b/DESCRIPTION
index a7dbe59f..6e0dd559 100755
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,10 +1,10 @@
Package: bambu
Type: Package
Title: Reference-guided isoform reconstruction and quantification for long read RNA-Seq data
-Version: 0.9.0
-Authors@R: c(person("Jonathan Goeke", "Developer", role = "aut",
- email = "gokej@gis.a-star.edu.sg"),
- person("Ying Chen", "Developer", role = "cre",email = "chen_ying@gis.a-star.edu.sg"))
+Version: 0.1.0
+Authors@R: c(person("Ying Chen", "Developer", role = "cre",email = "chen_ying@gis.a-star.edu.sg"),
+ person("Jonathan Goeke", "Developer", role = "aut",
+ email = "gokej@gis.a-star.edu.sg"))
Description: Multi-sample transcript discovery and quantification using long read RNA-Seq data.
License: GPL-3
Encoding: UTF-8
diff --git a/R/abundance_quantification.R b/R/abundance_quantification.R
index fa1c506d..3ffb9813 100755
--- a/R/abundance_quantification.R
+++ b/R/abundance_quantification.R
@@ -2,26 +2,37 @@
#' @title transcript_abundance_quantification
#' @param method A string variable indicates the whether a one-step or two-step approach will be used. See \code{Details}
#' for details on one-step and two-step approach.
-#' @param read_classDT A \code{data.table} with columns
+#' @param readClassDt A \code{data.table} with columns
#' @importFrom BiocParallel bplapply
#' @noRd
-abundance_quantification <- function(read_classDT,ncore = 1,
- bias_correction = TRUE,
+abundance_quantification <- function(readClassDt,ncore = 1,
+ bias = TRUE,
maxiter = 20000,
- conv.control = 10^(-8)){
- gene_sidList <- unique(read_classDT$gene_sid)
-
- bpParameters <- BiocParallel::bpparam()
- bpParameters$workers <- ncore
-
+ conv = 10^(-8)){
+ gene_sidList <- unique(readClassDt$gene_sid)
+
+ if(ncore == 1){
+
+ emResultsList <- lapply(as.list(gene_sidList),
+ run_parallel,
+ conv = conv,
+ bias = bias,
+ maxiter = maxiter,
+ readClassDt = readClassDt)
+ }else{
+ bpParameters <- BiocParallel::bpparam()
+ bpParameters$workers <- ncore
+
+ emResultsList <- BiocParallel::bplapply(as.list(gene_sidList),
+ run_parallel,
+ conv = conv,
+ bias = bias,
+ maxiter = maxiter,
+ readClassDt = readClassDt,
+ BPPARAM=bpParameters)
+ }
+
- emResultsList <- BiocParallel::bplapply(as.list(gene_sidList),
- run_parallel,
- conv.control = conv.control,
- bias_correction = bias_correction,
- maxiter = maxiter,
- read_classDT = read_classDT,
- BPPARAM=bpParameters)
estimates <- list(do.call('rbind',lapply(1:length(emResultsList), function(x) emResultsList[[x]][[1]])),
@@ -30,8 +41,8 @@ abundance_quantification <- function(read_classDT,ncore = 1,
return(estimates)
}
-run_parallel <- function(g,conv.control,bias_correction,maxiter, read_classDT){
- tmp <- read_classDT[gene_sid==g]
+run_parallel <- function(g,conv,bias,maxiter, readClassDt){
+ tmp <- readClassDt[gene_sid==g]
if((nrow(tmp)==1)){
out <- list(data.table(tx_sid = tmp$tx_sid,
estimates = tmp$nobs,
@@ -58,12 +69,12 @@ run_parallel <- function(g,conv.control,bias_correction,maxiter, read_classDT){
est_output <- emWithL1(X = as.matrix(a_mat),
Y = n.obs,
lambda = lambda,
- d = bias_correction,
+ d = bias,
maxiter = maxiter,
- conv = conv.control)
+ conv = conv)
t_est <- as.numeric(t(est_output[["theta"]]))
- if(bias_correction){
+ if(bias){
b_est <- as.numeric(t(est_output[["b"]]))
}else{
b_est <- rep(0,ncol(a_mat))
diff --git a/R/annotationFunctions.R b/R/annotationFunctions.R
index 1f36447a..16db3f5e 100755
--- a/R/annotationFunctions.R
+++ b/R/annotationFunctions.R
@@ -34,39 +34,52 @@ prepareAnnotations <- function(txdb) {
}
-#' Prepare annotations from gtf
-#' @title prepare annotations from gtf file
-#' @param gtf.file A string variable indicates the path to a gtf file.
-#' @param organism as described in \code{\link{makeTxDbFromGFF}}.
-#' @param dataSource as described in \code{\link{makeTxDbFromGFF}}.
-#' @param taxonomyId as described in \code{\link{makeTxDbFromGFF}}.
-#' @param chrominfo as described in \code{\link{makeTxDbFromGFF}}.
-#' @param miRBaseBuild as described in \code{\link{makeTxDbFromGFF}}.
-#' @param metadata as described in \code{\link{makeTxDbFromGFF}}.
-#' @param dbxrefTag as described in \code{\link{makeTxDbFromGFF}}.
-#' @param ... see \code{\link{makeTxDbFromGFF}}.
-#' @return A \code{\link{GrangesList}} object
+#' Prepare annotation granges object from GTF file
+#' @title Prepare annotation granges object from GTF file into a GRangesList object
+#' @param file a GTF file
+#' @return grlist a \code{\link{GRangesList}} object, unlike \code\link{readFromGTF}},
+#' this function finds out the equivalence classes between the transcripts,
+#' with \code{\link{mcols}} data having three columns:
+#' \itemize{
+#' \item TXNAME specifying prefix for new gene Ids (genePrefix.number), defaults to empty
+#' \item GENEID indicating whether filter to remove read classes which are a subset of known transcripts(), defaults to TRUE
+#' \item eqClass specifying minimun read count to consider a read class valid in a sample, defaults to 2
+#' }
+#'
#' @export
-prepareAnnotationsFromGTF <- function(gtf.file, dataSource=NA,
- organism="Homo sapiens",
- taxonomyId=NA,
- chrominfo=NULL,
- miRBaseBuild=NA,
- metadata=NULL,
- dbxrefTag,...){
- return(prepareAnnotations(GenomicFeatures::makeTxDbFromGFF(gtf.file, format = "gtf",
- organism = organism,
- dataSource = dataSource,
- taxonomyId = taxonomyId,
- chrominfo = chrominfo,
- miRBaseBuild = miRBaseBuild,
- metadata = metadata,
- dbxrefTag = dbxrefTag
- )))
+prepareAnnotationsFromGTF <- function(file){
+ if (missing(file)){
+ stop('A GTF file is required.')
+ }else{
+ data <- read.delim(file,header=FALSE,comment.char='#')
+ colnames(data) <- c("seqname","source","type","start","end","score","strand","frame","attribute")
+ data <- data[data$type=='exon',]
+ data$strand[data$strand=='.'] <- '*'
+ data$GENEID = gsub('gene_id (.*?);.*','\\1',data$attribute)
+ data$TXNAME=gsub('.*transcript_id (.*?);.*', '\\1',data$attribute)
+ data$exon_rank=as.integer(gsub('.*exon_number (.*?);.*', '\\1',data$attribute))
+ geneData=unique(data[,c('TXNAME', 'GENEID')])
+ grlist <- makeGRangesListFromDataFrame(
+ data[,c('seqname', 'start','end','strand','exon_rank','TXNAME')],split.field='TXNAME',keep.extra.columns = TRUE)
+
+ unlistedExons <- unlist(grlist, use.names = FALSE)
+ partitioning <- PartitioningByEnd(cumsum(elementNROWS(grlist)), names=NULL)
+ txIdForReorder <- togroup(PartitioningByWidth(grlist))
+ unlistedExons <- unlistedExons[order(txIdForReorder, unlistedExons$exon_rank)] #'exonsByTx' is always sorted by exon rank, not by strand, make sure that this is the case here
+ unlistedExons$exon_endRank <- unlist(sapply(elementNROWS(grlist),seq,to=1), use.names=FALSE)
+ unlistedExons <- unlistedExons[order(txIdForReorder, start(unlistedExons))]
+ # mcols(unlistedExons) <- mcols(unlistedExons)[,c('exon_rank','exon_endRank')]
+ grlist <- relist(unlistedExons, partitioning)
+ minEqClasses <- getMinimumEqClassByTx(grlist)
+ mcols(grlist) <- DataFrame(geneData[(match(names(grlist), geneData$TXNAME)),])
+ mcols(grlist)$eqClass <- minEqClasses$eqClass[match(names(grlist),minEqClasses$queryTxId)]
+ }
+ return (grlist)
}
+
#' Get minimum equivalent class by Transcript
#' @param exonsByTranscripts exonsByTranscripts
#' @noRd
diff --git a/R/bambu.R b/R/bambu.R
index 1f20613e..3cd3e7d4 100755
--- a/R/bambu.R
+++ b/R/bambu.R
@@ -4,22 +4,14 @@
#' It also allows saving of read class files of alignments, extending provided annotations, and quantification based on extended annotations.
#' When multiple samples are provided, extended annotations will be combined across samples to allow comparison.
#' @param reads A string or a vector of strings specifying the paths of bam files for genomic alignments, or a \code{\link{BamFile}} object or a \code{\link{BamFileList}} object (see \code{\link{Rsamtools}}).
-#' @param readclass.file A string or a vector of strings specifying the read class files that are saved during previous run of \code{\link{bambu}}.
-#' @param outputReadClassDir A string variable specifying the path to where read class files will be saved.
+#' @param readClass.file A string or a vector of strings specifying the read class files that are saved during previous run of \code{\link{bambu}}.
+#' @param readClass.outputDir A string variable specifying the path to where read class files will be saved.
#' @param annotations A \code{\link{TxDb}} object or A GRangesList object obtained by \code{\link{prepareAnnotations}} or \code{\link{prepareAnnotationsFromGTF}}.
-#' @param extendAnnotations A logical variable indicating whether annotations are to be extended for quantification.
#' @param genomeSequence A fasta file or a BSGenome object.
-#' @param algo.control A list of controlling parameters for quantification algorithm estimation process:
-#' \itemize{
-#' \item ncore specifying number of cores used when parallel processing is used, defaults to 1.
-#' \item maxiter specifying maximum number of run interations, defaults to 10000.
-#' \item bias_correction specifying whether to correct for bias, defaults to FALSE.
-#' \item convcontrol specifying the covergence trheshold control, defaults to 0.0001.
-#' }
+#' @param ncore specifying number of cores used when parallel processing is used, defaults to 1.
#' @param yieldSize see \code{\link{Rsamtools}}.
-#' @param ir.control A list of controlling parameters for isoform reconstruction process:
+#' @param isoreParameters A list of controlling parameters for isoform reconstruction process:
#' \itemize{
-#' \item whether stranded, defaults to FALSE
#' \item prefix specifying prefix for new gene Ids (genePrefix.number), defaults to empty
#' \item remove.subsetTx indicating whether filter to remove read classes which are a subset of known transcripts(), defaults to TRUE
#' \item min.readCount specifying minimun read count to consider a read class valid in a sample, defaults to 2
@@ -28,6 +20,13 @@
#' \item min.exonDistance specifying minum distance to known transcript to be considered valid as new, defaults to 35
#' \item min.exonOverlap specifying minimum number of bases shared with annotation to be assigned to the same gene id, defaults 10 base pairs
#' }
+#' @param emParameters A list of controlling parameters for quantification algorithm estimation process:
+#' \itemize{
+#' \item maxiter specifying maximum number of run interations, defaults to 10000.
+#' \item bias specifying whether to correct for bias, defaults to FALSE.
+#' \item conv specifying the covergence trheshold control, defaults to 0.0001.
+#' }
+#' @param extendAnnotations A logical variable indicating whether annotations are to be extended for quantification.
#' @param verbose A logical variable indicating whether processing messages will be printed.
#' @details
#' @return A list of two SummarizedExperiment object for transcript expression and gene expression.
@@ -37,11 +36,16 @@
#' ## More stringent new gene/isoform discovery: new isoforms are identified with at least 5 read count in 1 sample
#' ## Increase EM convergence threshold to 10^(-6)
#' seOutput <- bambu(reads, annotationGrangesList,
-#' genomeSequence, ir.control = list(min.readCount=5),
-#' algo.control = list(convcontrol = 10^(-6))
+#' genomeSequence, isoreParameters = list(min.readCount=5),
+#' emParameters = list(conv = 10^(-6))
#' }
#' @export
-bambu <- function(reads = NULL, readclass.file = NULL, outputReadClassDir = NULL, annotations = NULL, genomeSequence = NULL, algo.control = NULL, yieldSize = NULL, ir.control = NULL, extendAnnotations = TRUE, stranded = FALSE, ncore = 1, verbose = FALSE){
+bambu <- function(reads = NULL, readClass.file = NULL, readClass.outputDir = NULL,
+ annotations = NULL, genomeSequence = NULL,
+ stranded = FALSE, ncore = 1,
+ yieldSize = NULL,
+ isoreParameters = NULL, emParameters = NULL,
+ extendAnnotations = TRUE, verbose = FALSE){
#===# Check annotation inputs #===#
@@ -62,63 +66,61 @@ bambu <- function(reads = NULL, readclass.file = NULL, outputReadClassDir = NULL
## When SE object from bambu.quantISORE is provided ##
- if(!is.null(reads) & (!is.null(readclass.file))){
+ if(!is.null(reads) & (!is.null(readClass.file))){
stop("At least bam file or path to readClass file needs to be provided.")
}
- #===# Check whether provided outputReadClassDir exists #===#
- if(!is.null(outputReadClassDir)) {
- if(!dir.exists(outputReadClassDir)) {
+ #===# Check whether provided readClass.outputDir exists #===#
+ if(!is.null(readClass.outputDir)) {
+ if(!dir.exists(readClass.outputDir)) {
stop("output folder does not exist")
}
}
#===# Check whether provided readclass files are all in rds format #===#
- if(!is.null(readclass.file)){
- if(!all(grepl(".rds", readclass.file))){
+ if(!is.null(readClass.file)){
+ if(!all(grepl(".rds", readClass.file))){
stop("Read class files should be provided in rds format.")
}
}
#===# set default controlling parameters for isoform reconstruction #===#
- ir.control.default <- list(stranded = FALSE,
- remove.subsetTx = TRUE, #
+ isoreParameters.default <- list(remove.subsetTx = TRUE, #
min.readCount = 2, #
min.readFractionByGene = 0.05, ##
min.sampleNumber = 1, #
min.exonDistance = 35, #
min.exonOverlap = 10, #
prefix='') ##
- if(!is.null(ir.control)){
- for(i in names(ir.control)) {
- ir.control.default[[i]] <- ir.control[[i]]
+ if(!is.null(isoreParameters)){
+ for(i in names(isoreParameters)) {
+ isoreParameters.default[[i]] <- isoreParameters[[i]]
}
}
- ir.control <- ir.control.default
+ isoreParameters <- isoreParameters.default
## check quantification parameters
- algo.control.default <- list(bias_correction = FALSE,
+ emParameters.default <- list(bias = FALSE,
maxiter = 10000,
- convcontrol = 10^(-4))
+ conv = 10^(-4))
- if(!is.null(algo.control)){
- for(i in names(algo.control)) {
- algo.control.default[[i]] <- algo.control[[i]]
+ if(!is.null(emParameters)){
+ for(i in names(emParameters)) {
+ emParameters.default[[i]] <- emParameters[[i]]
}
}
- algo.control <- algo.control.default
+ emParameters <- emParameters.default
rm.readClassSe <- FALSE # indicator to remove temporary read class files
bpParameters <- BiocParallel::bpparam()
#===# set parallel options: If more CPUs than samples available, use parallel computing on each sample, otherwise use parallel to distribute samples (more efficient)
- if(length(reads)<=(0.5*ncore)) {
- bpParameters$workers <- 1
- } else {
- bpParameters$workers <- ncore
+ bpParameters$workers <- ifelse(length(reads)==1, 1, ncore)
+ bpParameters$progressbar <- (!verbose)
+
+ if(bpParameters$workers>1){
ncore <- 1
}
-
if(!is.null(reads)){ # calculate readClass objects
#===# create BamFileList object from character #===#
@@ -148,45 +150,53 @@ bambu <- function(reads = NULL, readclass.file = NULL, outputReadClassDir = NULL
#===# When more than 10 samples are provided, files will be written to a temporary directory
- if(length(reads)>10 &(is.null(outputReadClassDir))){
- outputReadClassDir <- tempdir()
- warning(paste0("There are more than 10 samples, read class files will be temporarily saved to ",outputReadClassDir, " for more efficient processing"))
+ if(length(reads)>10 &(is.null(readClass.outputDir))){
+ readClass.outputDir <- tempdir()
+ message(paste0("There are more than 10 samples, read class files will be temporarily saved to ",readClass.outputDir, " for more efficient processing"))
rm.readClassSe <- TRUE # remove temporary read class files from system
}
-
+ if(!verbose) message("Start generating read class files")
readClassList <- BiocParallel::bplapply(names(reads), function(bamFileName){
bambu.constructReadClass(
bam.file= reads[bamFileName],
- outputReadClassDir=outputReadClassDir,
+ readClass.outputDir=readClass.outputDir,
genomeSequence = genomeSequence,
annotations = annotations,
stranded=stranded,
ncore = ncore,
verbose = verbose)},
BPPARAM=bpParameters)
+
+ if(!verbose) message("Finished generating read classes from genomic alignments.")
} else {
- readClassList <- readclass.file
+ readClassList <- readClass.file
}
if(extendAnnotations) {
- annotations <- bambu.extendAnnotations(readClassList, annotations, ir.control, verbose=verbose)
+ annotations <- bambu.extendAnnotations(readClassList, annotations, isoreParameters, verbose=verbose)
+ if(!verbose) message("Finished extending annotations.")
gc(verbose = FALSE)
}
- countsSe <- BiocParallel::bplapply(readClassList,
- bambu.quantify,
- annotations=annotations,
- min.exonDistance= ir.control[['min.exonDistance']],
- algo.control = algo.control,
- ncore = ncore,
- verbose = verbose,
- BPPARAM=bpParameters)
+
+ if(!verbose) message("Start isoform quantification")
+
+ countsSe <- BiocParallel::bplapply(readClassList,
+ bambu.quantify,
+ annotations=annotations,
+ min.exonDistance= isoreParameters[['min.exonDistance']],
+ emParameters = emParameters,
+ ncore = ncore,
+ verbose = verbose,
+ BPPARAM=bpParameters)
+
countsSe <- do.call(SummarizedExperiment::cbind, countsSe)
rowRanges(countsSe) <- annotations
+ if(!verbose) message("Finished isoform quantification.")
#===# Clean up temp directory
if(rm.readClassSe){
@@ -198,7 +208,7 @@ bambu <- function(reads = NULL, readclass.file = NULL, outputReadClassDir = NULL
#' Extend annotations
#' @inheritParams bambu
#' @noRd
-bambu.extendAnnotations <- function(readClassList, annotations, ir.control, verbose = FALSE){
+bambu.extendAnnotations <- function(readClassList, annotations, isoreParameters, verbose = FALSE){
combinedTxCandidates = NULL
for(readClassIndex in seq_along(readClassList)){
readClass <- readClassList[[readClassIndex]]
@@ -210,13 +220,13 @@ bambu.extendAnnotations <- function(readClassList, annotations, ir.control, verb
}
annotations <- isore.extendAnnotations(se=combinedTxCandidates,
annotationGrangesList=annotations,
- remove.subsetTx = ir.control[['remove.subsetTx']],
- min.readCount = ir.control[['min.readCount']],
- min.readFractionByGene = ir.control[['min.readFractionByGene']],
- min.sampleNumber = ir.control[['min.sampleNumber']],
- min.exonDistance = ir.control[['min.exonDistance']],
- min.exonOverlap = ir.control[['min.exonOverlap']],
- prefix = ir.control[['prefix']],
+ remove.subsetTx = isoreParameters[['remove.subsetTx']],
+ min.readCount = isoreParameters[['min.readCount']],
+ min.readFractionByGene = isoreParameters[['min.readFractionByGene']],
+ min.sampleNumber = isoreParameters[['min.sampleNumber']],
+ min.exonDistance = isoreParameters[['min.exonDistance']],
+ min.exonOverlap = isoreParameters[['min.exonOverlap']],
+ prefix = isoreParameters[['prefix']],
verbose = verbose)
return(annotations)
}
@@ -224,19 +234,19 @@ bambu.extendAnnotations <- function(readClassList, annotations, ir.control, verb
#' Perform quantification
#' @inheritParams bambu
#' @noRd
-bambu.quantify <- function(readClass, annotations, algo.control, min.exonDistance=35, ncore = 1, verbose = FALSE){
+bambu.quantify <- function(readClass, annotations, emParameters, min.exonDistance=35, ncore = 1, verbose = FALSE){
if(is.character(readClass)){
readClass <- readRDS(file=readClass)
seqlevelsStyle(readClass) <- seqlevelsStyle(annotations)[1]
}
readClass <- isore.estimateDistanceToAnnotations(readClass, annotations, min.exonDistance = min.exonDistance, verbose = verbose)
- dt <- getEmptyClassFromSE(readClass, annotations)
+ readClassDt <- getEmptyClassFromSE(readClass, annotations)
colNameRC <- colnames(readClass)
colDataRC <- colData(readClass)
rm(readClass)
gc(verbose=FALSE)
- counts <- bambu.quantDT(dt,algo.control = algo.control, ncore = ncore, verbose = verbose)
+ counts <- bambu.quantDT(readClassDt,emParameters = emParameters, ncore = ncore, verbose = verbose)
if(length(setdiff(counts$tx_name,names(annotations)))>0){
stop("The provided annotation is incomplete")
}
@@ -252,10 +262,10 @@ bambu.quantify <- function(readClass, annotations, algo.control, min.exonDistanc
#' Preprocess bam files and save read class files
#' @inheritParams bambu
#' @noRd
-bambu.constructReadClass <- function(bam.file, genomeSequence, annotations, outputReadClassDir=NULL, stranded=FALSE, ncore=1, verbose=FALSE){
+bambu.constructReadClass <- function(bam.file, genomeSequence, annotations, readClass.outputDir=NULL, stranded=FALSE, ncore=1, verbose=FALSE){
- readGrgList <- prepareDataFromBam(bam.file[[1]], cores=ncore, verbose = verbose)
+ readGrgList <- prepareDataFromBam(bam.file[[1]], ncore=ncore, verbose = verbose)
seqlevelsStyle(readGrgList) <- seqlevelsStyle(annotations)[1]
se <- isore.constructReadClasses(readGrgList = readGrgList,
runName = names(bam.file)[1],
@@ -265,8 +275,8 @@ bambu.constructReadClass <- function(bam.file, genomeSequence, annotations, outp
ncore = ncore,
verbose = verbose)
seqlevels(se) <- unique(c(seqlevels(se), seqlevels(annotations)))
- if(!is.null(outputReadClassDir)){
- readClassFile <- fs::path(outputReadClassDir,paste0(names(bam.file),'_readClassSe'), ext='rds')
+ if(!is.null(readClass.outputDir)){
+ readClassFile <- fs::path(readClass.outputDir,paste0(names(bam.file),'_readClassSe'), ext='rds')
if(file.exists(readClassFile)){
show(paste(readClassFile, 'exists, will be overwritten')) #warning is not printed, use show in addition
warning(paste(readClassFile, 'exists, will be overwritten'))
@@ -280,52 +290,52 @@ bambu.constructReadClass <- function(bam.file, genomeSequence, annotations, outp
#' Process data.table object
-#' @param dt A data.table object
+#' @param readClassDt A data.table object
#' @inheritParams bambu
#' @noRd
-bambu.quantDT <- function(dt = dt,algo.control = NULL,ncore = 1, verbose = FALSE){
- if(is.null(dt)){
+bambu.quantDT <- function(readClassDt = readClassDt,emParameters = NULL,ncore = 1, verbose = FALSE){
+ if(is.null(readClassDt)){
stop("Input object is missing.")
- }else if(any(!(c('gene_id','tx_id','read_class_id','nobs') %in% colnames(dt)))){
+ }else if(any(!(c('gene_id','tx_id','read_class_id','nobs') %in% colnames(readClassDt)))){
stop("Columns gene_id, tx_id, read_class_id, nobs, are missing from object.")
}
## check quantification parameters
- algo.control.default <- list(bias_correction = FALSE,
+ emParameters.default <- list(bias = FALSE,
maxiter = 10000,
- convcontrol = 10^(-4))
+ conv = 10^(-4))
- if(!is.null(algo.control)){
- for(i in names(algo.control)) {
- algo.control.default[[i]] <- algo.control[[i]]
+ if(!is.null(emParameters)){
+ for(i in names(emParameters)) {
+ emParameters.default[[i]] <- emParameters[[i]]
}
}
- algo.control <- algo.control.default
+ emParameters <- emParameters.default
##----step2: match to simple numbers to increase claculation efficiency
- geneVec <- unique(dt$gene_id)
- txVec <- unique(dt$tx_id)
- readclassVec <- unique(dt$read_class_id)
- dt <- as.data.table(dt)
- dt[, gene_sid:=match(gene_id, geneVec)]
- dt[, tx_sid:=match(tx_id, txVec)]
- dt[, read_class_sid:=match(read_class_id, readclassVec)]
+ geneVec <- unique(readClassDt$gene_id)
+ txVec <- unique(readClassDt$tx_id)
+ readclassVec <- unique(readClassDt$read_class_id)
+ readClassDt <- as.data.table(readClassDt)
+ readClassDt[, gene_sid:=match(gene_id, geneVec)]
+ readClassDt[, tx_sid:=match(tx_id, txVec)]
+ readClassDt[, read_class_sid:=match(read_class_id, readclassVec)]
- dt[,`:=`(tx_id = NULL, gene_id = NULL, read_class_id = NULL)]
+ readClassDt[,`:=`(tx_id = NULL, gene_id = NULL, read_class_id = NULL)]
##----step3: aggregate read class
- temp <- aggReadClass(dt)
- dt <- temp[[1]]
+ temp <- aggReadClass(readClassDt)
+ readClassDt <- temp[[1]]
eqClassVec <- temp[[2]]
##----step4: quantification
start.time <- proc.time()
- outList <- abundance_quantification(dt,
+ outList <- abundance_quantification(readClassDt,
ncore = ncore,
- bias_correction = algo.control[["bias_correction"]],
- maxiter = algo.control[["maxiter"]],
- conv.control = algo.control[["convcontrol"]])
+ bias = emParameters[["bias"]],
+ maxiter = emParameters[["maxiter"]],
+ conv = emParameters[["conv"]])
end.time <- proc.time()
if(verbose) message('Finished EM estimation in ', round((end.time-start.time)[3]/60,1), ' mins.')
diff --git a/R/plotBambu.R b/R/plotBambu.R
index 0b301197..a9c95dd7 100644
--- a/R/plotBambu.R
+++ b/R/plotBambu.R
@@ -59,7 +59,7 @@ plot.bambu <- function(se, group.variable = NULL, type = c("annotation","pca","h
txRanges <- rowRanges(se)[txVec]
names(txRanges) <- paste0(txVec,":", unlist(lapply(strand(txRanges),function(x) unique(as.character(x)))))
p_annotation <- ggbio::autoplot(txRanges, group.selfish = TRUE)
- p_expression <- ggbio::autoplot(as.matrix(log2(assays(se)$CPM[txVec,]+1)),axis.text.angle = 45)
+ p_expression <- ggbio::autoplot(as.matrix(log2(assays(se)$CPM[txVec,]+1)),axis.text.angle = 45, hjust = 1)
p <- gridExtra::grid.arrange(p_annotation@ggplot, p_expression, top = g, heights = c(1,1))
@@ -133,11 +133,11 @@ plot.bambu <- function(se, group.variable = NULL, type = c("annotation","pca","h
topAnnotation <- ComplexHeatmap::HeatmapAnnotation(group = sample.info[match(colnames(count.data), runname)]$groupVar)
p <- ComplexHeatmap::Heatmap(corData, name = "Sp.R", col = col_fun,
- top_annotation = topAnnotation)
-
+ top_annotation = topAnnotation, show_row_names = FALSE,column_names_gp = grid::gpar(fontsize = 9))
}else{
- p <- ComplexHeatmap::Heatmap(corData, name = "Sp.R", col = col_fun)
+ p <- ComplexHeatmap::Heatmap(corData, name = "Sp.R", col = col_fun, show_row_names = FALSE,column_names_gp = grid::gpar(fontsize = 9))
+
}
return(p)
diff --git a/R/prepareBam.R b/R/prepareBam.R
index 5e8bc78d..72541fd4 100755
--- a/R/prepareBam.R
+++ b/R/prepareBam.R
@@ -2,7 +2,7 @@
#' @param bamFile bamFile
#' @inheritParams bambu
#' @noRd
-prepareDataFromBam <- function(bamFile, yieldSize=NULL, verbose = FALSE, cores=1) {
+prepareDataFromBam <- function(bamFile, yieldSize=NULL, verbose = FALSE, ncore=1) {
if(class(bamFile)=='BamFile') {
if(!is.null(yieldSize)) {
@@ -22,7 +22,7 @@ prepareDataFromBam <- function(bamFile, yieldSize=NULL, verbose = FALSE, cores=1
}
# parallel processing of single files by reading chromosomes separately
- if(cores>1){
+ if(ncore>1){
chr <- scanBamHeader(bamFile)[[1]]
chrRanges <- GRanges(seqnames=names(chr), ranges=IRanges(start=1, end=chr))
@@ -30,7 +30,7 @@ prepareDataFromBam <- function(bamFile, yieldSize=NULL, verbose = FALSE, cores=1
helpFun,
chrRanges=chrRanges,
bamFile=bamFile,
- mc.cores = cores)
+ mc.cores = ncore)
} else {
diff --git a/R/readWrite.R b/R/readWrite.R
index 86651f66..173af0f5 100644
--- a/R/readWrite.R
+++ b/R/readWrite.R
@@ -1,20 +1,21 @@
#' Outputs a GTF file, transcript-count file, and gene-count file from bambu
-#' @title write bambu results to GTF and transcript/gene-count files
-#' @param se a summarizedExperiment object from \code{\link{bambu}}
+#' @title Write bambu results to GTF and transcript/gene-count files
+#' @param se a \code{\link{SummarizedExperiment}} object from \code{\link{bambu}}
#' @param path the destination of the output files (gtf, transcript counts, and gene counts)
-#' @return gtf a GTF dataframe
+#' @return The function will generate three files, a \code{\link{.gtf}} file for the annotations,
+#' two \code{\link{.txt}} files for transcript and gene counts respectively.
#' @export
-write.bambu <- function(se,path){
+writeBambuOutput <- function(se,path){
if (missing(se) | missing(path)){
stop('Both summarizedExperiment object from bambu and the path for the output files are required.')
}else{
- outdir <- strsplit(path,"/")[[1]][1]
- if (dir.exists(outdir) == FALSE){
- dir.create(outdir)
+ outdir <- paste0(path,"/")
+ if (!dir.exists(outdir)){
+ dir.create(outdir, recursive = TRUE)
}
transcript_grList <- rowRanges(se)
transcript_gtffn <- paste(path,"transcript_exon.gtf",sep="")
- gtf <- write.gtf(annotation=transcript_grList,file=transcript_gtffn)
+ gtf <- writeToGTF(annotation=transcript_grList,file=transcript_gtffn)
transcript_counts <- as.data.frame(assays(se)$counts)
transcript_countsfn <- paste(path,"counts_transcript.txt",sep="")
write.table(transcript_counts, file= transcript_countsfn, sep="\t",quote=FALSE)
@@ -24,14 +25,14 @@ write.bambu <- function(se,path){
write.table(gene_counts, file= gene_countsfn, sep="\t", quote=FALSE)
}
}
-#' Outputs a GTF file for the nanorna-bam nextflow pipeline
+#' Write annotation GRangesList into a GTF file
#' @title write GRangeslist into GTF file
-#' @param annotation a GRangesList object
+#' @param annotation a \code{\link{GRangesList}} object
#' @param file the output gtf file name
#' @param geneIDs an optional dataframe of geneIDs (column 2) with the corresponding transcriptIDs (column 1)
#' @return gtf a GTF dataframe
#' @export
-write.gtf <- function (annotation,file,geneIDs=NULL) {
+writeToGTF <- function (annotation,file,geneIDs=NULL) {
if (missing(annotation) | missing(file)){
stop('Both GRangesList and the name of file are required.')
}else if (class(annotation) != "CompressedGRangesList"){
@@ -63,17 +64,23 @@ write.gtf <- function (annotation,file,geneIDs=NULL) {
gtf <- rbind(gtf_trns,gtf_exon)
gtf <- gtf[order(gtf$attributes),]
write.table(gtf, file= file, quote=FALSE, row.names=FALSE, col.names=FALSE, sep = "\t")
- }
+}
+
+
#' Outputs GRangesList object from reading a GTF file
#' @title convert a GTF file into a GRangesList
-#' @param file a GTF file
-#' @return grlist a GRangesList object
+#' @param file a \code{\link{.gtf}} file
+#' @return grlist a \code{\link{GRangesList}} object, with two columns
+#' \itemize{
+#' \item TXNAME specifying prefix for new gene Ids (genePrefix.number), defaults to empty
+#' \item GENEID indicating whether filter to remove read classes which are a subset of known transcripts(), defaults to TRUE
+#' }
#' @export
-read.gtf <- function(file){
+readFromGTF <- function(file){
if (missing(file)){
stop('A GTF file is required.')
}else{
- data=read.delim(file,header=FALSE)
+ data=read.delim(file,header=FALSE, comment.char='#')
colnames(data) <- c("seqname","source","type","start","end","score","strand","frame","attribute")
data$strand[data$strand=='.'] <- '*'
data$GENEID = gsub('gene_id (.*); tra.*','\\1',data$attribute)
@@ -88,37 +95,3 @@ read.gtf <- function(file){
return (grlist)
}
-#' Outputs GRangesList object from reading a GTF file for running bambu
-#' @title convert a GTF file into a GRangesList
-#' @param file a GTF file
-#' @return grlist a GRangesList object
-#' @export
-prepareAnnotationsFromGTF_draft <- function(file){
- if (missing(file)){
- stop('A GTF file is required.')
- }else{
- data <- read.delim(file,header=FALSE,comment.char='#')
- colnames(data) <- c("seqname","source","type","start","end","score","strand","frame","attribute")
- data <- data[data$type=='exon',]
- data$strand[data$strand=='.'] <- '*'
- data$GENEID = gsub('gene_id (.*?);.*','\\1',data$attribute)
- data$TXNAME=gsub('.*transcript_id (.*?);.*', '\\1',data$attribute)
- data$exon_rank=as.integer(gsub('.*exon_number (.*?);.*', '\\1',data$attribute))
- geneData=unique(data[,c('TXNAME', 'GENEID')])
- grlist <- makeGRangesListFromDataFrame(
- data[,c('seqname', 'start','end','strand','exon_rank','TXNAME')],split.field='TXNAME',keep.extra.columns = TRUE)
-
- unlistedExons <- unlist(grlist, use.names = FALSE)
- partitioning <- PartitioningByEnd(cumsum(elementNROWS(grlist)), names=NULL)
- txIdForReorder <- togroup(PartitioningByWidth(grlist))
- unlistedExons <- unlistedExons[order(txIdForReorder, unlistedExons$exon_rank)] #'exonsByTx' is always sorted by exon rank, not by strand, make sure that this is the case here
- unlistedExons$exon_endRank <- unlist(sapply(elementNROWS(grlist),seq,to=1), use.names=FALSE)
- unlistedExons <- unlistedExons[order(txIdForReorder, start(unlistedExons))]
-# mcols(unlistedExons) <- mcols(unlistedExons)[,c('exon_rank','exon_endRank')]
- grlist <- relist(unlistedExons, partitioning)
- minEqClasses <- getMinimumEqClassByTx(grlist)
- mcols(grlist) <- DataFrame(geneData[(match(names(grlist), geneData$TXNAME)),])
- mcols(grlist)$eqClass <- minEqClasses$eqClass[match(names(grlist),minEqClasses$queryTxId)]
- }
- return (grlist)
-}
diff --git a/R/sysdata.rda b/R/sysdata.rda
index ed5526f2..2a68a949 100755
Binary files a/R/sysdata.rda and b/R/sysdata.rda differ
diff --git a/README.md b/README.md
index 59bcf5bf..d872787b 100755
--- a/README.md
+++ b/README.md
@@ -1,5 +1,201 @@
-
+
+
+
# bambu: reference-guided transcript discovery and quantification for long read RNA-Seq data
-The code is still under development.
+
+[](https://github.com/GoekeLab/bambu)
+[](https://github.com/GoekeLab/bambu/graphs/contributors)
+[](#installation)
+[](https://www.gnu.org/licenses/gpl-3.0)
+
+
+***bambu*** is a R package for multi-sample transcript discovery and quantification using long read RNA-Seq data. You can use ***bambu*** after read alignment to obtain expression estimates for known and novel transcripts and genes. The output from ***bambu*** can directly be used for visualisation and downstream analysis such as differential gene expression or transcript usage.
+
+
+---
+
+### Content
+
+ - [Installation](#installation)
+ - [General usage](#general-usage)
+ - [Use precalculated annotation objects](#use-precalculated-annotation-objects)
+ - [Advanced options](#advanced-options)
+ - [Complementary functions](#complementary-functions)
+ - [Release History](#release-history)
+ - [Contributors](#contributors)
+
+
+### Installation
+
+You can install ***bambu*** from github:
+
+```rscript
+if (!requireNamespace("devtools", quietly = TRUE))
+ install.packages("devtools")
+devtools::install_github("GoekeLab/bambu")
+```
+---
+
+### 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:
+
+ ```rscript
+library(bambu)
+
+test.bam <- system.file("extdata", "SGNex_A549_directRNA_replicate5_run1_chr9_1_1000000.bam", package = "bambu")
+
+
+se <- bambu(reads = test.bam, annotations = "TxDb.Hsapiens.UCSC.hg38.knownGene", genomeSequence = "BSgenome.Hsapiens.NCBI.GRCh38")
+
+```
+
+
+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:
+
+```rscript
+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 <- prepareAnnotationsFromGTF(gtf.file)
+
+se <- bambu(reads = test.bam, annotations = bambuAnnotations, genomeSequence = fa.file)
+
+```
+
+
+**Quantification of annotated transcripts and genes only (no transcript/gene discovery)**
+
+```rscript
+bambu(reads = test.bam, annotations = txdb, genomeSequence = fa.file, extendAnnotations = FALSE)
+```
+
+**Large sample number/ limited memory**
+For larger sample numbers we recommend to write the processed data to a file:
+
+```rscript
+bambu(reads = test.bam, readClass.outputDir = "./bambu/", annotations = bambuAnnotations, genomeSequence = fa.file)
+```
+---
+
+
+### Use precalculated annotation objects
+
+You can also use precalculated annotations.
+
+If you plan to run ***bambu*** more frequently, we recommend to save the bambuAnnotations object.
+
+The bambuAnnotation object can be calculated from a *.gtf* file:
+
+```rscript
+annotations <- prepareAnnotationFromGTF(gtf.file)
+```
+
+From *TxDb* object
+
+```rscript
+annotations <- prepareAnnotations(txdb)
+```
+
+---
+
+### Advanced Options
+
+**More stringent filtering thresholds imposed on potential novel transcripts**
+
+- Keep novel transcripts with min 5 read count in at least 1 sample:
+
+```rscript
+bambu(reads, annotations, genomeSequence, isoreParameters = list(min.readCount = 5))
+```
+
+- Keep novel transcripts with min 5 samples having at least 2 counts:
+
+```rscript
+bambu(reads, annotations, genomeSequence, isoreParameters = list(min.sampleNumber = 5))
+```
+
+- Filter out transcripts with relative abundance within gene lower than 10%:
+
+```rscript
+bambu(reads, annotations, genomeSequence, isoreParameters = list(min.readFractionByGene = 0.1))
+```
+
+**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.
+
+```rscript
+bambu(reads, annotations, genomeSequence, emParameters = list(bias = FALSE))
+```
+
+**Parallel computation**
+ ***bambu*** allows parallel computation.
+
+```rscript
+bambu(reads, annotations, genomeSequence, ncore = 8)
+```
+
+See [manual](docs/bambu_0.1.0.pdf) for details to customize other conditions.
+
+---
+
+### Complementary functions
+
+**Transcript expression to gene expression**
+
+```rscript
+transcriptToGeneExpression(se)
+```
+
+**Visualization**
+
+ You can visualize the novel genes/transcripts using ***plot.bambu*** function
+
+```rscript
+plot.bambu(se, type = "annotation", gene_id)
+
+plot.bambu(se, type = "annotation", transcript_id)
+```
+
+- ***plot.bambu*** can also be used to visualize the clustering of input samples on gene/transcript expressions
+
+```rscript
+plot.bambu(se, type = "heatmap") # heatmap
+
+plot.bambu(se, type = "pca") # PCA visualization
+```
+
+- ***plot.bambu*** can also be used to visualize the clustering of input samples on gene/transcript expressions with grouping variable
+
+```rscript
+plot.bambu(se, type = "heatmap", group.var) # heatmap
+
+plot.bambu(se, type = "pca", group.var) # PCA visualization
+```
+
+**Write bambu outputs to files**
+
+- ***writeBambuOutput*** will generate three files, including a *.gtf* file for the extended annotations, and two *.txt* files for the expression counts at transcript and gene levels.
+
+```rscript
+writeBambuOutput(se, path = "./bambu/")
+```
+---
+
+### Release History
+
+**bambu version 0.1.0**
+
+Release date: 29th May 2020
+
+### Contributors
+
+This package is developed and maintained by [Ying Chen](https://github.com/cying111), [Yuk Kei Wan](https://github.com/yuukiiwa), and [Jonathan Goeke](https://github.com/jonathangoeke) at the Genome Institute of Singapore. If you want to contribute, please leave an issue. Thank you.
+
+
diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R
index 4b168235..8fa19830 100755
--- a/data-raw/DATASET.R
+++ b/data-raw/DATASET.R
@@ -30,11 +30,11 @@ data5 <- data.frame(tx_id = c(1:6,2,3,1,2,5,1,2,3,5,1:5),
estOutput_woBC <- lapply(1:5, function(s){
- est <- bambu.quantDT(dt = get(paste0("data",s)), algo.control=list(bias_correction = FALSE,ncore = 1))
+ est <- bambu.quantDT(readClassDt = get(paste0("data",s)), emParameters=list(bias = FALSE))
})
estOutput_wBC <- lapply(1:5, function(s){
- est <- bambu.quantDT(dt = get(paste0("data",s)), algo.control=list(ncore = 1))
+ est <- bambu.quantDT(readClassDt = get(paste0("data",s)))
})
diff --git a/docs/404.html b/docs/404.html
new file mode 100644
index 00000000..282f3cbb
--- /dev/null
+++ b/docs/404.html
@@ -0,0 +1,148 @@
+
+
+
+
GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>. ++ +
Bambu can be used for transcript discovery and quantification from long read RNA-Seq data. Here, we present an example usage of bambu on Nanopore long read RNA-Sequencing from 2 human cancer cell lines
+To demonstrate the usage of Bambu, we used the data in NanoporeRNASeq, which contains single chromosome RNA-Seq data from two common cell lines K562 and MCF7. Each of these cell line has three replicates, with 1 direct RNA sequencing data and 2 cDNA sequencing data.
+ +data("sample_info") +sample_info +##> sample_id Platform cellLine protocol +##> 1: SGNex_K562_directcDNA_replicate1_run2 MinION K562 directcDNA +##> 2: SGNex_K562_directcDNA_replicate4_run2 GridION K562 directcDNA +##> 3: SGNex_K562_directRNA_replicate6_run1 GridION K562 directRNA +##> 4: SGNex_MCF7_directcDNA_replicate1_run2 MinION MCF7 directcDNA +##> 5: SGNex_MCF7_directcDNA_replicate3_run3 GridION MCF7 directcDNA +##> 6: SGNex_MCF7_directRNA_replicate4_run1 GridION MCF7 directRNA +##> bioRep cancer_type +##> 1: replicate1 Leukocyte +##> 2: replicate4 Leukocyte +##> 3: replicate6 Leukocyte +##> 4: replicate1 Breast +##> 5: replicate3 Breast +##> 6: replicate4 Breast
Name of bamfiles can be loaded as follows
+data("bamFileNames") +bamFileNames +##> [1] "SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234.bam" +##> [2] "SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234.bam" +##> [3] "SGNex_K562_directRNA_replicate6_run1_genome_chr22_1_25409234.bam" +##> [4] "SGNex_MCF7_directcDNA_replicate1_run2_genome_chr22_1_25409234.bam" +##> [5] "SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234.bam" +##> [6] "SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234.bam"
We then loaded bam.files.
+bam.file <- system.file("extdata",bamFileNames, package = "NanoporeRNASeq") +data("annotationGrangesList_chr22_1_25409234")
We applied bambu to perform EM on extended annotations
+seExtended <- bambu(reads = bam.file, annotations = annotationGrangesList_chr22_1_25409234, genomeSequence = "BSgenome.Hsapiens.NCBI.GRCh38", extendAnnotations = TRUE, verbose = FALSE, ncore = 6) +##> + | + | | 0% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |============ | 17% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |======================= | 33% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |=================================== | 50% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |=============================================== | 67% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |========================================================== | 83% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |============ | 17% + | + |======================= | 33% + | + |=================================== | 50% + | + |=============================================== | 67% + | + |========================================================== | 83% + | + |======================================================================| 100% +seExtended +##> class: RangedSummarizedExperiment +##> dim: 1923 6 +##> metadata(0): +##> assays(2): counts CPM +##> rownames(1923): tx.1 tx.2 ... ENST00000484509 ENST00000468442 +##> rowData names(4): TXNAME GENEID eqClass newTxClass +##> colnames(6): +##> SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234 +##> SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234 ... +##> SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234 +##> SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234 +##> colData names(1): name
bambu allows quantification without isoform discovery
+se <- bambu(reads = bam.file, annotations = annotationGrangesList_chr22_1_25409234, genomeSequence = "BSgenome.Hsapiens.NCBI.GRCh38", extendAnnotations = FALSE, verbose = FALSE, ncore = 6) +##> + | + | | 0% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |============ | 17% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |======================= | 33% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |=================================== | 50% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |=============================================== | 67% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |========================================================== | 83% + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |======================================================================| 100% +##> +##> + | + |======================================================================| 100% +##> +##> + | + | | 0% + | + |============ | 17% + | + |======================= | 33% + | + |=================================== | 50% + | + |=============================================== | 67% + | + |========================================================== | 83% + | + |======================================================================| 100% +se +##> class: RangedSummarizedExperiment +##> dim: 1500 6 +##> metadata(0): +##> assays(2): counts CPM +##> rownames(1500): ENST00000624155 ENST00000422332 ... ENST00000484509 +##> ENST00000468442 +##> rowData names(3): TXNAME GENEID eqClass +##> colnames(6): +##> SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234 +##> SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234 ... +##> SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234 +##> SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234 +##> colData names(1): name
We can check the estimated transcript expression using heatmap:
+colData(seExtended)$groupVar <- unlist(lapply(colnames(seExtended),function(x) unlist(strsplit(x,"_"))[2])) +colnames(seExtended) <- gsub("_genome_chr22_1_25409234","",colnames(seExtended)) +colData(seExtended)$name <- gsub("_genome_chr22_1_25409234","",colData(seExtended)$name) +plot.bambu(seExtended, group.variable = "groupVar", type = "heatmap")
or with PCA plot
+colData(seExtended)$groupVar <- unlist(lapply(colnames(seExtended),function(x) unlist(strsplit(x,"_"))[2])) +plot.bambu(seExtended, group.variable = "groupVar", type = "pca")
Single gene examples can also be checked using plot functions from bambu
+plot.bambu(seExtended, type = "annotation", gene_id = unique(rowData(seExtended)$GENEID)[10])
##> [[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.210]
+Gene expression can be obtained from transcript expression using this function:
+seGene <- transcriptToGeneExpression(seExtended) +seGene +##> class: RangedSummarizedExperiment +##> dim: 887 6 +##> metadata(0): +##> assays(2): counts CPM +##> rownames(887): ENSG00000015475 ENSG00000040608 ... gene.98 gene.99 +##> rowData names(2): GENEID newGeneClass +##> colnames(6): SGNex_K562_directcDNA_replicate1_run2 +##> SGNex_K562_directcDNA_replicate4_run2 ... +##> SGNex_MCF7_directcDNA_replicate3_run3 +##> SGNex_MCF7_directRNA_replicate4_run1 +##> colData names(2): name groupVar
Gene expression heatmap
+colData(seGene)$groupVar <- unlist(lapply(colnames(seGene),function(x) unlist(strsplit(x,"_"))[2])) +plot.bambu(seGene, group.variable = "groupVar", type = "heatmap")
Gene expression PCA plot
+colData(seGene)$groupVar <- unlist(lapply(colnames(seGene),function(x) unlist(strsplit(x,"_"))[2])) +plot.bambu(seGene, group.variable = "groupVar", type = "pca")
We used DESeq2 to find the differentially expressed genes:
+library(DESeq2) +dds <- DESeqDataSetFromMatrix(apply(assays(seGene)$counts,c(1,2),round),#tmp_wide[,-1], + colData = colData(seExtended), + design = ~ groupVar) +system.time(dds.deseq <- DESeq(dds)) +##> user system elapsed +##> 1.996 0.028 2.025 + +deGeneRes <- DESeq2::results(dds.deseq, independentFiltering=FALSE)
head(deGeneRes[order(deGeneRes$padj),]) +##> log2 fold change (MLE): groupVar MCF7 vs K562 +##> Wald test p-value: groupVar MCF7 vs K562 +##> DataFrame with 6 rows and 6 columns +##> baseMean log2FoldChange lfcSE stat +##> <numeric> <numeric> <numeric> <numeric> +##> ENSG00000185686 513.5554 -7.22327 0.498140 -14.50048 +##> ENSG00000197077 26.2357 9.09835 1.326114 6.86091 +##> ENSG00000283633 88.7407 -9.03039 1.431724 -6.30736 +##> ENSG00000099977 232.6720 1.85141 0.306629 6.03795 +##> ENSG00000169635 44.4275 -3.44047 0.579080 -5.94127 +##> ENSG00000100181 38.3698 -5.07047 0.892940 -5.67840 +##> pvalue +##> <numeric> +##> ENSG00000185686 0.0000000000000000000000000000000000000000000000120303 +##> ENSG00000197077 0.0000000000068425448545783570607904382313656081217312 +##> ENSG00000283633 0.0000000002838407468976333203669654163178986266968806 +##> ENSG00000099977 0.0000000015607995974142258612474572408387353539271913 +##> ENSG00000169635 0.0000000028282083250919303521398367383355917925591427 +##> ENSG00000100181 0.0000000135958879211409468852046023923732520621854292 +##> padj +##> <numeric> +##> ENSG00000185686 0.00000000000000000000000000000000000000000000714599 +##> ENSG00000197077 0.00000000203223582180977191457661517551974705853013 +##> ENSG00000283633 0.00000005620046788573139474432216163360398475390411 +##> ENSG00000099977 0.00000023177874021601254939083656177872816428475744 +##> ENSG00000169635 0.00000033599114902092130879429198592189820260500710 +##> ENSG00000100181 0.00000134599290419295367876952908281484866392929689
summary(deGeneRes) +##> +##> out of 594 with nonzero total read count +##> adjusted p-value < 0.1 +##> LFC > 0 (up) : 16, 2.7% +##> LFC < 0 (down) : 20, 3.4% +##> outliers [1] : 0, 0% +##> low counts [2] : 0, 0% +##> (mean count < 0) +##> [1] see 'cooksCutoff' argument of ?results +##> [2] see 'independentFiltering' argument of ?results
Plotting shrinked lFC results
+resLFC <- lfcShrink(dds.deseq, coef="groupVar_MCF7_vs_K562", type="apeglm") +plotMA(resLFC, ylim = c(-3,3))
We used DEXSeq to detect alternative used isoforms.
+library(DRIMSeq) +count.data <- as.data.frame(rowData(seExtended)) +count.data$gene_id <- count.data$GENEID +count.data$feature_id <- count.data$TXNAME +count.data$GENEID <- count.data$TXNAME <- NULL + +count.data <- cbind(count.data, assays(seExtended)$counts) + +sample.info <- as.data.frame(colData(seExtended)) +sample.info$sample_id <- sample.info$name +sample.info$name <- NULL +d <- dmDSdata(counts=count.data, samples=sample.info) + +n_samp_gene <- 1 +n_samp_feature <- 1 +min_count_gene <- 1 +min_count_feature <- 1 +dFilter <- dmFilter(d, + min_samps_feature_expr = n_samp_feature, + min_samps_feature_prop = n_samp_feature, + min_samps_gene_expr = n_samp_gene, + min_feature_expr = min_count_feature, + min_gene_expr = min_count_gene, + min_feature_prop=0.1) +table(table(counts(dFilter)$gene_id)) ## number of isoforms +##> +##> 2 3 4 5 6 7 8 10 +##> 23 15 21 12 8 6 4 1
library(DEXSeq) +formulaFullModel <- as.formula("~sample + exon + groupVar:exon") + + +dxd <- DEXSeqDataSet(countData=round(as.matrix(counts(dFilter)[,-c(1:2)])), + sampleData=DRIMSeq::samples(dFilter), + design=formulaFullModel, + featureID = counts(dFilter)$feature_id, + groupID=counts(dFilter)$gene_id) + + +system.time({ + dxd <- estimateSizeFactors(dxd) + print('Size factor estimated') + dxd <- estimateDispersions(dxd, formula = formulaFullModel) + print('Dispersion estimated') + #dxd <- estimateExonFoldChanges( dxd ) + dxd <- testForDEU(dxd, fullModel = formulaFullModel) + print('DEU tested') + dxd <- estimateExonFoldChanges(dxd, fitExpToVar="groupVar") + print('Exon fold changes estimated') +}) +##> [1] "Size factor estimated" +##> [1] "Dispersion estimated" +##> [1] "DEU tested" +##> [1] "Exon fold changes estimated" +##> user system elapsed +##> 7.860 0.040 7.903
dxr <- DEXSeqResults(dxd, independentFiltering=FALSE) +head(dxr) +##> +##> LRT p-value: full vs reduced +##> +##> DataFrame with 6 rows and 12 columns +##> groupID featureID exonBaseMean dispersion stat +##> <character> <character> <numeric> <numeric> <numeric> +##> gene.2:tx.2 gene.2 tx.2 2.714822 0.427670 3.150551 +##> gene.2:tx.3 gene.2 tx.3 0.654029 0.791030 0.140914 +##> gene.2:tx.4 gene.2 tx.4 2.567833 0.315359 1.003001 +##> gene.2:tx.66 gene.2 tx.66 2.107202 0.332461 0.422016 +##> gene.2:tx.67 gene.2 tx.67 1.243100 1.748445 1.683733 +##> gene.2:tx.122 gene.2 tx.122 1.865452 0.467004 1.043483 +##> pvalue padj K562 MCF7 log2fold_MCF7_K562 +##> <numeric> <numeric> <numeric> <numeric> <numeric> +##> gene.2:tx.2 0.0759013 0.99485 2.14944 0.0448427 -11.620740 +##> gene.2:tx.3 0.7073738 1.00000 1.15465 0.0448419 -9.506951 +##> gene.2:tx.4 0.3165853 1.00000 2.03209 1.1710398 -1.860342 +##> gene.2:tx.66 0.5159328 1.00000 1.58048 1.8911532 0.622989 +##> gene.2:tx.67 0.1944292 1.00000 1.05916 1.7073365 1.554900 +##> gene.2:tx.122 0.3070128 1.00000 1.44728 1.8878239 0.910422 +##> genomicData countData +##> <GRangesList> <matrix> +##> gene.2:tx.2 18:13:3:... +##> gene.2:tx.3 2:3:2:... +##> gene.2:tx.4 10:15:3:... +##> gene.2:tx.66 7:5:3:... +##> gene.2:tx.67 0:6:0:... +##> gene.2:tx.122 2:9:1:...
library(stageR) +strp <- function(x) substr(x,1,15) +qval <- perGeneQValue(dxr) +dxr.g <- data.frame(gene=names(qval),qval) + +columns <- c("featureID","groupID","pvalue") +dxr_pval <- as.data.frame(dxr[,columns]) +head(dxr_pval) +##> featureID groupID pvalue +##> gene.2:tx.2 tx.2 gene.2 0.07590133 +##> gene.2:tx.3 tx.3 gene.2 0.70737384 +##> gene.2:tx.4 tx.4 gene.2 0.31658535 +##> gene.2:tx.66 tx.66 gene.2 0.51593283 +##> gene.2:tx.67 tx.67 gene.2 0.19442922 +##> gene.2:tx.122 tx.122 gene.2 0.30701285 + +pConfirmation <- matrix(dxr_pval$pvalue,ncol=1) +dimnames(pConfirmation) <- list(strp(dxr_pval$featureID),"transcript") +pScreen <- qval +names(pScreen) <- strp(names(pScreen)) +tx2gene <- as.data.frame(dxr_pval[,c("featureID", "groupID")]) +for (i in 1:2) tx2gene[,i] <- strp(tx2gene[,i]) + + +stageRObj <- stageRTx(pScreen=pScreen, pConfirmation=pConfirmation, + pScreenAdjusted=TRUE, tx2gene=tx2gene) +stageRObj <- stageWiseAdjustment(stageRObj, method="dtu", alpha=0.5) +suppressWarnings({ + dex.padj <- getAdjustedPValues(stageRObj, order=FALSE, + onlySignificantGenes=TRUE) +})
dxrDT <- data.table(as.data.frame(dxr)) +setnames(dxrDT, old = c('groupID','featureID'), new = c('geneID','txID')) +dex.padj <- data.table(dex.padj) + +dxrDT <- dex.padj[dxrDT, on = c('geneID','txID')] +head(dxrDT) +##> geneID txID gene transcript exonBaseMean dispersion stat pvalue +##> 1: gene.2 tx.2 NA NA 2.7148218 0.4276702 3.1505509 0.07590133 +##> 2: gene.2 tx.3 NA NA 0.6540286 0.7910296 0.1409142 0.70737384 +##> 3: gene.2 tx.4 NA NA 2.5678325 0.3153589 1.0030014 0.31658535 +##> 4: gene.2 tx.66 NA NA 2.1072015 0.3324607 0.4220160 0.51593283 +##> 5: gene.2 tx.67 NA NA 1.2431000 1.7484453 1.6837326 0.19442922 +##> 6: gene.2 tx.122 NA NA 1.8654524 0.4670041 1.0434828 0.30701285 +##> padj K562 MCF7 log2fold_MCF7_K562 genomicData +##> 1: 0.9948496 2.149443 0.04484265 -11.6207395 <GRanges> +##> 2: 1.0000000 1.154654 0.04484192 -9.5069512 <GRanges> +##> 3: 1.0000000 2.032089 1.17103980 -1.8603417 <GRanges> +##> 4: 1.0000000 1.580476 1.89115320 0.6229887 <GRanges> +##> 5: 1.0000000 1.059156 1.70733655 1.5549004 <GRanges> +##> 6: 1.0000000 1.447282 1.88782389 0.9104218 <GRanges> +##> countData.SGNex_K562_directcDNA_replicate1_run2 +##> 1: 18 +##> 2: 2 +##> 3: 10 +##> 4: 7 +##> 5: 0 +##> 6: 2 +##> countData.SGNex_K562_directcDNA_replicate4_run2 +##> 1: 13 +##> 2: 3 +##> 3: 15 +##> 4: 5 +##> 5: 6 +##> 6: 9 +##> countData.SGNex_K562_directRNA_replicate6_run1 +##> 1: 3 +##> 2: 2 +##> 3: 3 +##> 4: 3 +##> 5: 0 +##> 6: 1 +##> countData.SGNex_MCF7_directcDNA_replicate1_run2 +##> 1: 0 +##> 2: 0 +##> 3: 0 +##> 4: 1 +##> 5: 1 +##> 6: 1 +##> countData.SGNex_MCF7_directcDNA_replicate3_run3 +##> 1: 0 +##> 2: 0 +##> 3: 1 +##> 4: 2 +##> 5: 0 +##> 6: 2 +##> countData.SGNex_MCF7_directRNA_replicate4_run1 +##> 1: 0 +##> 2: 0 +##> 3: 0 +##> 4: 0 +##> 5: 1 +##> 6: 0
dxrDT[,sigLFC2:=(padj < 0.5&(abs(log2fold_MCF7_K562)>=2))] +ggplot(dxrDT, aes(y = log2fold_MCF7_K562, x = exonBaseMean, color = as.factor(padj<0.5)))+ + geom_point(size = 0.5)+ + scale_x_log10()+ + scale_color_manual(values = c('grey','indianred'), name = "Significant")+ + xlab("Mean of normalized counts")+ + ylab("Log2 Fold change")+ + theme_minimal()
dxrDT[padj<0.5,.(geneID, txID, log2fold_MCF7_K562,K562,MCF7)] +##> geneID txID log2fold_MCF7_K562 K562 MCF7 +##> 1: ENSG00000183597 tx.35 -2.925745 4.2504114 2.284457 +##> 2: ENSG00000184436 tx.44 -4.132398 3.3428343 1.103626 +##> 3: ENSG00000272779 tx.105 4.276779 0.6241729 2.320295 +##> 4: ENSG00000100030 ENST00000215832 1.112208 5.7031758 6.535581 +##> 5: ENSG00000100030 ENST00000398822 -1.438071 4.0021766 3.004256 +##> 6: ENSG00000169635 ENST00000407464 2.362562 1.9298346 3.404064 +##> 7: ENSG00000169635 ENST00000443632 -1.904184 4.0971165 2.785404 +##> 8: ENSG00000215012 ENST00000407472 -1.753270 3.6246114 2.462383
Bambu can be used for transcript discovery and quantification from long read RNA-Seq data. Here, we present an example usage of bambu on Nanopore long read RNA-Sequencing from 2 human cancer cell lines
+To demonstrate the usage of Bambu, we used the data in NanoporeRNASeq, which contains single chromosome RNA-Seq data from two common cell lines K562 and MCF7. Each of these cell line has three replicates, with 1 direct RNA sequencing data and 2 cDNA sequencing data.
+library(NanoporeRNASeq)
+library(bambu)
data("sample_info")
+sample_info
+##> sample_id Platform cellLine protocol
+##> 1: SGNex_K562_directcDNA_replicate1_run2 MinION K562 directcDNA
+##> 2: SGNex_K562_directcDNA_replicate4_run2 GridION K562 directcDNA
+##> 3: SGNex_K562_directRNA_replicate6_run1 GridION K562 directRNA
+##> 4: SGNex_MCF7_directcDNA_replicate1_run2 MinION MCF7 directcDNA
+##> 5: SGNex_MCF7_directcDNA_replicate3_run3 GridION MCF7 directcDNA
+##> 6: SGNex_MCF7_directRNA_replicate4_run1 GridION MCF7 directRNA
+##> bioRep cancer_type
+##> 1: replicate1 Leukocyte
+##> 2: replicate4 Leukocyte
+##> 3: replicate6 Leukocyte
+##> 4: replicate1 Breast
+##> 5: replicate3 Breast
+##> 6: replicate4 Breast
Name of bamfiles can be loaded as follows
+data("bamFileNames")
+bamFileNames
+##> [1] "SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234.bam"
+##> [2] "SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234.bam"
+##> [3] "SGNex_K562_directRNA_replicate6_run1_genome_chr22_1_25409234.bam"
+##> [4] "SGNex_MCF7_directcDNA_replicate1_run2_genome_chr22_1_25409234.bam"
+##> [5] "SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234.bam"
+##> [6] "SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234.bam"
We then loaded bam.files.
+bam.file <- system.file("extdata",bamFileNames, package = "NanoporeRNASeq")
+data("annotationGrangesList_chr22_1_25409234")
We applied bambu to perform EM on extended annotations
+seExtended <- bambu(reads = bam.file, annotations = annotationGrangesList_chr22_1_25409234, genomeSequence = "BSgenome.Hsapiens.NCBI.GRCh38", extendAnnotations = TRUE, verbose = FALSE, ncore = 6)
+##>
+ |
+ | | 0%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |============ | 17%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |======================= | 33%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |=================================== | 50%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |=============================================== | 67%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |========================================================== | 83%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |============ | 17%
+ |
+ |======================= | 33%
+ |
+ |=================================== | 50%
+ |
+ |=============================================== | 67%
+ |
+ |========================================================== | 83%
+ |
+ |======================================================================| 100%
+seExtended
+##> class: RangedSummarizedExperiment
+##> dim: 1923 6
+##> metadata(0):
+##> assays(2): counts CPM
+##> rownames(1923): tx.1 tx.2 ... ENST00000484509 ENST00000468442
+##> rowData names(4): TXNAME GENEID eqClass newTxClass
+##> colnames(6):
+##> SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234
+##> SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234 ...
+##> SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234
+##> SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234
+##> colData names(1): name
bambu allows quantification without isoform discovery
+se <- bambu(reads = bam.file, annotations = annotationGrangesList_chr22_1_25409234, genomeSequence = "BSgenome.Hsapiens.NCBI.GRCh38", extendAnnotations = FALSE, verbose = FALSE, ncore = 6)
+##>
+ |
+ | | 0%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |============ | 17%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |======================= | 33%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |=================================== | 50%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |=============================================== | 67%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |========================================================== | 83%
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ |======================================================================| 100%
+##>
+##>
+ |
+ | | 0%
+ |
+ |============ | 17%
+ |
+ |======================= | 33%
+ |
+ |=================================== | 50%
+ |
+ |=============================================== | 67%
+ |
+ |========================================================== | 83%
+ |
+ |======================================================================| 100%
+se
+##> class: RangedSummarizedExperiment
+##> dim: 1500 6
+##> metadata(0):
+##> assays(2): counts CPM
+##> rownames(1500): ENST00000624155 ENST00000422332 ... ENST00000484509
+##> ENST00000468442
+##> rowData names(3): TXNAME GENEID eqClass
+##> colnames(6):
+##> SGNex_K562_directcDNA_replicate1_run2_genome_chr22_1_25409234
+##> SGNex_K562_directcDNA_replicate4_run2_genome_chr22_1_25409234 ...
+##> SGNex_MCF7_directcDNA_replicate3_run3_genome_chr22_1_25409234
+##> SGNex_MCF7_directRNA_replicate4_run1_genome_chr22_1_25409234
+##> colData names(1): name
We can check the estimated transcript expression using heatmap:
+colData(seExtended)$groupVar <- unlist(lapply(colnames(seExtended),function(x) unlist(strsplit(x,"_"))[2]))
+colnames(seExtended) <- gsub("_genome_chr22_1_25409234","",colnames(seExtended))
+colData(seExtended)$name <- gsub("_genome_chr22_1_25409234","",colData(seExtended)$name)
+plot.bambu(seExtended, group.variable = "groupVar", type = "heatmap")
or with PCA plot
+colData(seExtended)$groupVar <- unlist(lapply(colnames(seExtended),function(x) unlist(strsplit(x,"_"))[2]))
+plot.bambu(seExtended, group.variable = "groupVar", type = "pca")
Single gene examples can also be checked using plot functions from bambu
+plot.bambu(seExtended, type = "annotation", gene_id = unique(rowData(seExtended)$GENEID)[10])
##> [[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.210]
+Gene expression can be obtained from transcript expression using this function:
+seGene <- transcriptToGeneExpression(seExtended)
+seGene
+##> class: RangedSummarizedExperiment
+##> dim: 887 6
+##> metadata(0):
+##> assays(2): counts CPM
+##> rownames(887): ENSG00000015475 ENSG00000040608 ... gene.98 gene.99
+##> rowData names(2): GENEID newGeneClass
+##> colnames(6): SGNex_K562_directcDNA_replicate1_run2
+##> SGNex_K562_directcDNA_replicate4_run2 ...
+##> SGNex_MCF7_directcDNA_replicate3_run3
+##> SGNex_MCF7_directRNA_replicate4_run1
+##> colData names(2): name groupVar
Gene expression heatmap
+colData(seGene)$groupVar <- unlist(lapply(colnames(seGene),function(x) unlist(strsplit(x,"_"))[2]))
+plot.bambu(seGene, group.variable = "groupVar", type = "heatmap")
Gene expression PCA plot
+colData(seGene)$groupVar <- unlist(lapply(colnames(seGene),function(x) unlist(strsplit(x,"_"))[2]))
+plot.bambu(seGene, group.variable = "groupVar", type = "pca")
We used DESeq2 to find the differentially expressed genes:
+library(DESeq2)
+dds <- DESeqDataSetFromMatrix(apply(assays(seGene)$counts,c(1,2),round),#tmp_wide[,-1],
+ colData = colData(seExtended),
+ design = ~ groupVar)
+system.time(dds.deseq <- DESeq(dds))
+##> user system elapsed
+##> 2.020 0.068 2.089
+
+deGeneRes <- DESeq2::results(dds.deseq, independentFiltering=FALSE)
head(deGeneRes[order(deGeneRes$padj),])
+##> log2 fold change (MLE): groupVar MCF7 vs K562
+##> Wald test p-value: groupVar MCF7 vs K562
+##> DataFrame with 6 rows and 6 columns
+##> baseMean log2FoldChange lfcSE stat
+##> <numeric> <numeric> <numeric> <numeric>
+##> ENSG00000185686 513.5554 -7.22327 0.498140 -14.50048
+##> ENSG00000197077 26.2357 9.09835 1.326114 6.86091
+##> ENSG00000283633 88.7407 -9.03039 1.431724 -6.30736
+##> ENSG00000099977 232.6720 1.85141 0.306629 6.03795
+##> ENSG00000169635 44.4275 -3.44047 0.579080 -5.94127
+##> ENSG00000100181 38.3698 -5.07047 0.892940 -5.67840
+##> pvalue
+##> <numeric>
+##> ENSG00000185686 0.0000000000000000000000000000000000000000000000120303
+##> ENSG00000197077 0.0000000000068425448545783570607904382313656081217312
+##> ENSG00000283633 0.0000000002838407468976333203669654163178986266968806
+##> ENSG00000099977 0.0000000015607995974142258612474572408387353539271913
+##> ENSG00000169635 0.0000000028282083250919303521398367383355917925591427
+##> ENSG00000100181 0.0000000135958879211409468852046023923732520621854292
+##> padj
+##> <numeric>
+##> ENSG00000185686 0.00000000000000000000000000000000000000000000714599
+##> ENSG00000197077 0.00000000203223582180977191457661517551974705853013
+##> ENSG00000283633 0.00000005620046788573139474432216163360398475390411
+##> ENSG00000099977 0.00000023177874021601254939083656177872816428475744
+##> ENSG00000169635 0.00000033599114902092130879429198592189820260500710
+##> ENSG00000100181 0.00000134599290419295367876952908281484866392929689
summary(deGeneRes)
+##>
+##> out of 594 with nonzero total read count
+##> adjusted p-value < 0.1
+##> LFC > 0 (up) : 16, 2.7%
+##> LFC < 0 (down) : 20, 3.4%
+##> outliers [1] : 0, 0%
+##> low counts [2] : 0, 0%
+##> (mean count < 0)
+##> [1] see 'cooksCutoff' argument of ?results
+##> [2] see 'independentFiltering' argument of ?results
plotMA(deGeneRes, ylim = c(-3,3))
Plotting shrinked lFC results
+resLFC <- lfcShrink(dds.deseq, coef="groupVar_MCF7_vs_K562", type="apeglm")
+plotMA(resLFC, ylim = c(-3,3))
We used DEXSeq to detect alternative used isoforms.
+library(DRIMSeq)
+count.data <- as.data.frame(rowData(seExtended))
+count.data$gene_id <- count.data$GENEID
+count.data$feature_id <- count.data$TXNAME
+count.data$GENEID <- count.data$TXNAME <- NULL
+
+count.data <- cbind(count.data, assays(seExtended)$counts)
+
+sample.info <- as.data.frame(colData(seExtended))
+sample.info$sample_id <- sample.info$name
+sample.info$name <- NULL
+d <- dmDSdata(counts=count.data, samples=sample.info)
+
+n_samp_gene <- 1
+n_samp_feature <- 1
+min_count_gene <- 1
+min_count_feature <- 1
+dFilter <- dmFilter(d,
+ min_samps_feature_expr = n_samp_feature,
+ min_samps_feature_prop = n_samp_feature,
+ min_samps_gene_expr = n_samp_gene,
+ min_feature_expr = min_count_feature,
+ min_gene_expr = min_count_gene,
+ min_feature_prop=0.1)
+table(table(counts(dFilter)$gene_id)) ## number of isoforms
+##>
+##> 2 3 4 5 6 7 8 10
+##> 23 15 21 12 8 6 4 1
library(DEXSeq)
+formulaFullModel <- as.formula("~sample + exon + groupVar:exon")
+
+
+dxd <- DEXSeqDataSet(countData=round(as.matrix(counts(dFilter)[,-c(1:2)])),
+ sampleData=DRIMSeq::samples(dFilter),
+ design=formulaFullModel,
+ featureID = counts(dFilter)$feature_id,
+ groupID=counts(dFilter)$gene_id)
+
+
+system.time({
+ dxd <- estimateSizeFactors(dxd)
+ print('Size factor estimated')
+ dxd <- estimateDispersions(dxd, formula = formulaFullModel)
+ print('Dispersion estimated')
+ #dxd <- estimateExonFoldChanges( dxd )
+ dxd <- testForDEU(dxd, fullModel = formulaFullModel)
+ print('DEU tested')
+ dxd <- estimateExonFoldChanges(dxd, fitExpToVar="groupVar")
+ print('Exon fold changes estimated')
+})
+##> [1] "Size factor estimated"
+##> [1] "Dispersion estimated"
+##> [1] "DEU tested"
+##> [1] "Exon fold changes estimated"
+##> user system elapsed
+##> 7.816 0.024 7.844
dxr <- DEXSeqResults(dxd, independentFiltering=FALSE)
+head(dxr)
+##>
+##> LRT p-value: full vs reduced
+##>
+##> DataFrame with 6 rows and 12 columns
+##> groupID featureID exonBaseMean dispersion stat
+##> <character> <character> <numeric> <numeric> <numeric>
+##> gene.2:tx.2 gene.2 tx.2 2.714822 0.427670 3.150551
+##> gene.2:tx.3 gene.2 tx.3 0.654029 0.791030 0.140914
+##> gene.2:tx.4 gene.2 tx.4 2.567833 0.315359 1.003001
+##> gene.2:tx.66 gene.2 tx.66 2.107202 0.332461 0.422016
+##> gene.2:tx.67 gene.2 tx.67 1.243100 1.748445 1.683733
+##> gene.2:tx.122 gene.2 tx.122 1.865452 0.467004 1.043483
+##> pvalue padj K562 MCF7 log2fold_MCF7_K562
+##> <numeric> <numeric> <numeric> <numeric> <numeric>
+##> gene.2:tx.2 0.0759013 0.99485 2.14944 0.0448427 -11.620740
+##> gene.2:tx.3 0.7073738 1.00000 1.15465 0.0448419 -9.506951
+##> gene.2:tx.4 0.3165853 1.00000 2.03209 1.1710398 -1.860342
+##> gene.2:tx.66 0.5159328 1.00000 1.58048 1.8911532 0.622989
+##> gene.2:tx.67 0.1944292 1.00000 1.05916 1.7073365 1.554900
+##> gene.2:tx.122 0.3070128 1.00000 1.44728 1.8878239 0.910422
+##> genomicData countData
+##> <GRangesList> <matrix>
+##> gene.2:tx.2 18:13:3:...
+##> gene.2:tx.3 2:3:2:...
+##> gene.2:tx.4 10:15:3:...
+##> gene.2:tx.66 7:5:3:...
+##> gene.2:tx.67 0:6:0:...
+##> gene.2:tx.122 2:9:1:...
library(stageR)
+strp <- function(x) substr(x,1,15)
+qval <- perGeneQValue(dxr)
+dxr.g <- data.frame(gene=names(qval),qval)
+
+columns <- c("featureID","groupID","pvalue")
+dxr_pval <- as.data.frame(dxr[,columns])
+head(dxr_pval)
+##> featureID groupID pvalue
+##> gene.2:tx.2 tx.2 gene.2 0.07590133
+##> gene.2:tx.3 tx.3 gene.2 0.70737384
+##> gene.2:tx.4 tx.4 gene.2 0.31658535
+##> gene.2:tx.66 tx.66 gene.2 0.51593283
+##> gene.2:tx.67 tx.67 gene.2 0.19442922
+##> gene.2:tx.122 tx.122 gene.2 0.30701285
+
+pConfirmation <- matrix(dxr_pval$pvalue,ncol=1)
+dimnames(pConfirmation) <- list(strp(dxr_pval$featureID),"transcript")
+pScreen <- qval
+names(pScreen) <- strp(names(pScreen))
+tx2gene <- as.data.frame(dxr_pval[,c("featureID", "groupID")])
+for (i in 1:2) tx2gene[,i] <- strp(tx2gene[,i])
+
+
+stageRObj <- stageRTx(pScreen=pScreen, pConfirmation=pConfirmation,
+ pScreenAdjusted=TRUE, tx2gene=tx2gene)
+stageRObj <- stageWiseAdjustment(stageRObj, method="dtu", alpha=0.5)
+suppressWarnings({
+ dex.padj <- getAdjustedPValues(stageRObj, order=FALSE,
+ onlySignificantGenes=TRUE)
+})
dxrDT <- data.table(as.data.frame(dxr))
+setnames(dxrDT, old = c('groupID','featureID'), new = c('geneID','txID'))
+dex.padj <- data.table(dex.padj)
+
+dxrDT <- dex.padj[dxrDT, on = c('geneID','txID')]
+head(dxrDT)
+##> geneID txID gene transcript exonBaseMean dispersion stat pvalue
+##> 1: gene.2 tx.2 NA NA 2.7148218 0.4276702 3.1505509 0.07590133
+##> 2: gene.2 tx.3 NA NA 0.6540286 0.7910296 0.1409142 0.70737384
+##> 3: gene.2 tx.4 NA NA 2.5678325 0.3153589 1.0030014 0.31658535
+##> 4: gene.2 tx.66 NA NA 2.1072015 0.3324607 0.4220160 0.51593283
+##> 5: gene.2 tx.67 NA NA 1.2431000 1.7484453 1.6837326 0.19442922
+##> 6: gene.2 tx.122 NA NA 1.8654524 0.4670041 1.0434828 0.30701285
+##> padj K562 MCF7 log2fold_MCF7_K562 genomicData
+##> 1: 0.9948496 2.149443 0.04484265 -11.6207395 <GRanges>
+##> 2: 1.0000000 1.154654 0.04484192 -9.5069512 <GRanges>
+##> 3: 1.0000000 2.032089 1.17103980 -1.8603417 <GRanges>
+##> 4: 1.0000000 1.580476 1.89115320 0.6229887 <GRanges>
+##> 5: 1.0000000 1.059156 1.70733655 1.5549004 <GRanges>
+##> 6: 1.0000000 1.447282 1.88782389 0.9104218 <GRanges>
+##> countData.SGNex_K562_directcDNA_replicate1_run2
+##> 1: 18
+##> 2: 2
+##> 3: 10
+##> 4: 7
+##> 5: 0
+##> 6: 2
+##> countData.SGNex_K562_directcDNA_replicate4_run2
+##> 1: 13
+##> 2: 3
+##> 3: 15
+##> 4: 5
+##> 5: 6
+##> 6: 9
+##> countData.SGNex_K562_directRNA_replicate6_run1
+##> 1: 3
+##> 2: 2
+##> 3: 3
+##> 4: 3
+##> 5: 0
+##> 6: 1
+##> countData.SGNex_MCF7_directcDNA_replicate1_run2
+##> 1: 0
+##> 2: 0
+##> 3: 0
+##> 4: 1
+##> 5: 1
+##> 6: 1
+##> countData.SGNex_MCF7_directcDNA_replicate3_run3
+##> 1: 0
+##> 2: 0
+##> 3: 1
+##> 4: 2
+##> 5: 0
+##> 6: 2
+##> countData.SGNex_MCF7_directRNA_replicate4_run1
+##> 1: 0
+##> 2: 0
+##> 3: 0
+##> 4: 0
+##> 5: 1
+##> 6: 0
dxrDT[,sigLFC2:=(padj < 0.5&(abs(log2fold_MCF7_K562)>=2))]
+ggplot(dxrDT, aes(y = log2fold_MCF7_K562, x = exonBaseMean, color = as.factor(padj<0.5)))+
+ geom_point(size = 0.5)+
+ scale_x_log10()+
+ scale_color_manual(values = c('grey','indianred'), name = "Significant")+
+ xlab("Mean of normalized counts")+
+ ylab("Log2 Fold change")+
+ theme_minimal()
dxrDT[padj<0.5,.(geneID, txID, log2fold_MCF7_K562,K562,MCF7)]
+##> geneID txID log2fold_MCF7_K562 K562 MCF7
+##> 1: ENSG00000183597 tx.35 -2.925745 4.2504114 2.284457
+##> 2: ENSG00000184436 tx.44 -4.132398 3.3428343 1.103626
+##> 3: ENSG00000272779 tx.105 4.276779 0.6241729 2.320295
+##> 4: ENSG00000100030 ENST00000215832 1.112208 5.7031758 6.535581
+##> 5: ENSG00000100030 ENST00000398822 -1.438071 4.0021766 3.004256
+##> 6: ENSG00000169635 ENST00000407464 2.362562 1.9298346 3.404064
+##> 7: ENSG00000169635 ENST00000443632 -1.904184 4.0971165 2.785404
+##> 8: ENSG00000215012 ENST00000407472 -1.753270 3.6246114 2.462383
bambu is a R package for multi-sample transcript discovery and quantification using long read RNA-Seq data. You can use bambu after read alignment to obtain expression estimates for known and novel transcripts and genes. The output from bambu can directly be used for visualisation and downstream analysis such as differential gene expression or transcript usage.
+ +You can install bambu from github:
+if (!requireNamespace("devtools", quietly = TRUE))
+ install.packages("devtools")
+devtools::install_github("GoekeLab/bambu")
+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:
+```rscript library(bambu)
+test.bam <- system.file(“extdata”, “SGNex_A549_directRNA_replicate5_run1_chr9_1_1000000.bam”, package = “bambu”)
+se <- bambu(reads = test.bam, annotations = “TxDb.Hsapiens.UCSC.hg38.knownGene”, genomeSequence = “BSgenome.Hsapiens.NCBI.GRCh38”)
+```
+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:
+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 <- prepareAnnotationsFromGTF(gtf.file)
+
+se <- bambu(reads = test.bam, annotations = bambuAnnotations, genomeSequence = fa.file)
+
+Quantification of annotated transcripts and genes only (no transcript/gene discovery)
+bambu(reads = test.bam, annotations = txdb, genomeSequence = fa.file, extendAnnotations = FALSE)
+Large sample number/ limited memory
+For larger sample numbers we recommend to write the processed data to a file:
bambu(reads = test.bam, readClass.outputDir = "./bambu/", annotations = bambuAnnotations, genomeSequence = fa.file)
+You can also use precalculated annotations.
+If you plan to run bambu more frequently, we recommend to save the bambuAnnotations object.
+The bambuAnnotation object can be calculated from a gtf file:
+annotations <- prepareAnnotationFromGTF(gtf.file)
+From TxDb object
+annotations <- prepareAnnotations(txdb)
+More stringent filtering thresholds imposed on potential novel transcripts
+++Keep novel transcripts with min 5 read count in at least 1 sample:
+
bambu(reads, annotations, genomeSequence, isoreParameters = list(min.readCount = 5))
+++Keep novel transcripts with min 5 samples having at least 2 counts:
+
bambu(reads, annotations, genomeSequence, isoreParameters = list(min.sampleNumber = 5))
+++Filter out transcripts with relative abundance within gene lower than 10%:
+
bambu(reads, annotations, genomeSequence, isoreParameters = list(min.readFractionByGene = 0.1))
+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.
+
bambu(reads, annotations, genomeSequence, emParameters(bias = FALSE))
+Parallel computation
+++bambu allows parallel computation.
+
bambu(reads, annotations, genomeSequence, ncore = 8)
+See manual for details to customize other conditions.
+Transcript expression to gene expression
+transcriptToGeneExpression(se)
+Visualization
+++You can visualize the novel genes/transcripts using plot.bambu function
+
plot.bambu(se, type = "annotation", gene_id)
+
+plot.bambu(se, type = "annotation", transcript_id)
+++plot.bambu can also be used to visualize the clustering of input samples on gene/transcript expressions
+
plot.bambu(se, type = "heatmap") # heatmap
+
+plot.bambu(se, type = "pca") # PCA visualization
+++plot.bambu can also be used to visualize the clustering of input samples on gene/transcript expressions with grouping variable
+
plot.bambu(se, type = "heatmap", group.var) # heatmap
+
+plot.bambu(se, type = "pca", group.var) # PCA visualization
+Write bambu outputs to files
+++writeBambuOutput will generate three files, including a .gtf file for the extended annotations, and two .txt files for the expression counts at transcript and gene levels.
+
writeBambuOutput(se, path = "./bambu/")
+This package is developed and maintained byYing Chen, Yuk Kei Wan, Jonathan Goeke and at Genome Institute of Singapore. If you want to contribute, please leave an issue. Thank you.
+Outputs a GTF dataframe for the nanorna-bam nextflow pipeline
+SEtoGTF(se)+ +
se | +a summarizedExperiment object from |
+
---|
gtf a GTF dataframe
+ +This function takes bam file of genomic alignments and performs isoform recontruction and gene and transcript expression quantification. +It also allows saving of read class files of alignments, extending provided annotations, and quantification based on extended annotations. +When multiple samples are provided, extended annotations will be combined across samples to allow comparison.
+bambu( + reads = NULL, + readClass.file = NULL, + readClass.outputDir = NULL, + annotations = NULL, + genomeSequence = NULL, + stranded = FALSE, + ncore = 1, + yieldSize = NULL, + isoreParameters = NULL, + emParameters = NULL, + extendAnnotations = TRUE, + verbose = FALSE +)+ +
reads | +A string or a vector of strings specifying the paths of bam files for genomic alignments, or a |
+
---|---|
readClass.file | +A string or a vector of strings specifying the read class files that are saved during previous run of |
+
readClass.outputDir | +A string variable specifying the path to where read class files will be saved. |
+
annotations | +A |
+
genomeSequence | +A fasta file or a BSGenome object. |
+
ncore | +specifying number of cores used when parallel processing is used, defaults to 1. |
+
yieldSize | +see |
+
isoreParameters | +A list of controlling parameters for isoform reconstruction process:
|
+
emParameters | +A list of controlling parameters for quantification algorithm estimation process:
|
+
extendAnnotations | +A logical variable indicating whether annotations are to be extended for quantification. |
+
verbose | +A logical variable indicating whether processing messages will be printed. |
+
A list of two SummarizedExperiment object for transcript expression and gene expression.
+Main function
+ +# S3 method for bambu +plot( + se, + group.variable = NULL, + type = c("annotation", "pca", "heatmap"), + gene_id = NULL, + transcript_id = NULL +)+ +
se | +An summarized experiment object obtained from bambu or |
+
---|
Function to prepare tables and genomic ranges for transript reconstruction using a txdb object
+prepareAnnotations(txdb)+ +
txdb | +a |
+
---|
A GrangesList
object
+if (FALSE) { + library(TxDb.Hsapiens.UCSC.hg38.knownGene) + txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene + prepareAnnotations(txdb) + }
GRangesList
— prepareAnnotationsFromGTF • bambuGRangesList
R/annotationFunctions.R
+ prepareAnnotationsFromGTF.Rd
Prepare annotation granges object from GTF file
+prepareAnnotationsFromGTF(file)+ +
file | +a GTF file |
+
---|
Outputs GRangesList object from reading a GTF file
+readFromGTF(file)+ +
file | +a |
+
---|
grlist a GRangesList
object, with two columns
TXNAME specifying prefix for new gene Ids (genePrefix.number), defaults to empty
GENEID indicating whether filter to remove read classes which are a subset of known transcripts(), defaults to TRUE
R/transcriptToGeneExpression.R
+ transcriptToGeneExpression.Rd
Reduce transcript expression to gene expression
+transcriptToGeneExpression(se)+ +
se | +a summarizedExperiment object from |
+
---|
R/readWrite.R
+ writeBambuOutput.Rd
Outputs a GTF file, transcript-count file, and gene-count file from bambu
+writeBambuOutput(se, path)+ +
se | +a summarizedExperiment object from |
+
---|---|
path | +the destination of the output files (gtf, transcript counts, and gene counts) |
+
The function will generate three files, a .gtf
file for the annotations,
+two .txt
files for transcript and gene counts respectively.
Write annotation GRangesList into a GTF file
+writeToGTF(annotation, file, geneIDs = NULL)+ +
annotation | +a |
+
---|---|
file | +the output gtf file name |
+
geneIDs | +an optional dataframe of geneIDs (column 2) with the corresponding transcriptIDs (column 1) |
+
gtf a GTF dataframe
+ +