comparison get_deseq_dataset.R @ 19:c56e0689e46e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 5b6dc96c6e14582d5bb1dc213ac8d26dc7b2829e
author iuc
date Tue, 04 Dec 2018 08:19:06 -0500
parents d9e5cadc7f0b
children 89d26b11d452
comparison
equal deleted inserted replaced
18:3bf1b3ec1ddf 19:c56e0689e46e
7 } else { 7 } else {
8 hasHeader <- FALSE 8 hasHeader <- FALSE
9 } 9 }
10 10
11 if (!is.null(tximport)) { 11 if (!is.null(tximport)) {
12 if (is.null(tx2gene)) stop("A transcript-to-gene map or a GTF file is required for tximport") 12 if (is.null(tx2gene)) stop("A transcript-to-gene map or a GTF/GFF3 file is required for tximport")
13 if (tolower(file_ext(opt$tx2gene)) == "gtf") { 13 if (tolower(file_ext(opt$tx2gene)) == "gff") {
14 gtfFile <-tx2gene 14 gffFile <-tx2gene
15 } else { 15 } else {
16 gtfFile <- NULL 16 gffFile <- NULL
17 tx2gene <- read.table(tx2gene, header=FALSE) 17 tx2gene <- read.table(tx2gene, header=FALSE)
18 } 18 }
19 useTXI <- TRUE 19 useTXI <- TRUE
20 } else { 20 } else {
21 useTXI <- FALSE 21 useTXI <- FALSE
43 design = designFormula) 43 design = designFormula)
44 colnames(dds) <- row.names(sampleTable) 44 colnames(dds) <- row.names(sampleTable)
45 45
46 } else { 46 } else {
47 # construct the object using tximport 47 # construct the object using tximport
48 # first need to make the tx2gene table
49 # this takes ~2-3 minutes using Bioconductor functions
50 if (!is.null(gtfFile)) {
51 suppressPackageStartupMessages({
52 library("GenomicFeatures")
53 })
54 txdb <- makeTxDbFromGFF(gtfFile, format="gtf")
55 k <- keys(txdb, keytype = "GENEID")
56 df <- select(txdb, keys = k, keytype = "GENEID", columns = "TXNAME")
57 tx2gene <- df[, 2:1] # tx ID, then gene ID
58 }
59 library("tximport") 48 library("tximport")
60 txiFiles <- as.character(sampleTable$filename) 49 txiFiles <- as.character(sampleTable$filename)
61 labs <- row.names(sampleTable) 50 labs <- row.names(sampleTable)
62 names(txiFiles) <- labs 51 names(txiFiles) <- labs
63 txi <- tximport(txiFiles, type=txtype, tx2gene=tx2gene) 52 if (!is.null(gffFile)) {
53 # first need to make the tx2gene table
54 # this takes ~2-3 minutes using Bioconductor functions
55 suppressPackageStartupMessages({
56 library("GenomicFeatures")
57 })
58 txdb <- makeTxDbFromGFF(gffFile)
59 k <- keys(txdb, keytype = "TXNAME")
60 tx2gene <- select(txdb, k, "GENEID", "TXNAME")
61 }
62 try(txi <- tximport(txiFiles, type=txtype, tx2gene=tx2gene))
63 if (!exists("txi")) {
64 # Remove version from transcript IDs
65 tx2gene$TXNAME <- sub('\\.[0-9]+', '', tx2gene$TXNAME)
66 txi <- tximport(txiFiles, type=txtype, tx2gene=tx2gene)
67 }
64 dds <- DESeqDataSetFromTximport(txi, 68 dds <- DESeqDataSetFromTximport(txi,
65 subset(sampleTable, select=-c(filename)), 69 subset(sampleTable, select=-c(filename)),
66 designFormula) 70 designFormula)
67 } 71 }
68 return(dds) 72 return(dds)