Skip to content

Commit

Permalink
add possibility to generate txdb object from gtf file in diffbind2.R
Browse files Browse the repository at this point in the history
  • Loading branch information
frankRuehle committed Jan 18, 2022
1 parent a6f5f1c commit 026226d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/diffbind/diffbind2.R
Expand Up @@ -88,9 +88,19 @@ if(!is.numeric(FOLD)) stop("Fold threshold is not numeric. Run with:\n",r
if(!is.logical(ANNOTATE)) stop("Annotate not logical. Run with:\n",runstr)
if(!is.logical(PE)) stop("Paired end (pe) not logical. Run with:\n",runstr)
if(ANNOTATE & !is.numeric(TSS)) stop("Region around TSS not numeric. Run with:\n",runstr)
if(ANNOTATE & !require(TXDB, character.only=TRUE)) stop("Transcript DB", TXDB, "not installed\n")
if(ANNOTATE & !require(ANNODB, character.only=TRUE)) stop("Annotation DB", ANNODB, "not installed\n")

if(ANNOTATE) {
if(grepl("\\.gtf$", TXDB)){ # check the input format for the transcript annotation
library(GenomicFeatures)
txdb <- makeTxDbFromGFF(TXDB, format="gtf") # if the input format is gtf file, then this file will be used to create a TxDb object
} else {
if(!require(TXDB, character.only=TRUE)) stop("Transcript DB", TXDB, "not installed\n")
txdb <- eval(parse(text=TXDB)) # if the input format is bioconductor, then the transcript annoation library will be used
}
}


# check for DiffBind version
currentDiffbindVersion <- packageVersion('DiffBind')
DiffBindWarningText <- ""
Expand Down Expand Up @@ -285,7 +295,6 @@ dev.off()
##
if(ANNOTATE) {
library(ChIPseeker)
txdb <- eval(parse(text=TXDB))
result <- lapply(result, function(x) {
tryCatch({
x.ann <- annotatePeak(x, TxDb=txdb, annoDb=ANNODB, tssRegion=TSS, verbose=T)
Expand Down

0 comments on commit 026226d

Please sign in to comment.