3
|
1 library(getopt)
|
|
2
|
|
3 # we read the options from the default: commandArgs(TRUE).
|
|
4 spec <- matrix(c(
|
|
5 "input_type", "t", 1, "character",
|
|
6 "outfile", "o", 1, "character",
|
|
7 "gtfFile", "x", 1, "character"),
|
|
8 byrow=TRUE, ncol=4)
|
|
9 opt <- getopt(spec)
|
|
10
|
|
11 suppressPackageStartupMessages({library("GenomicFeatures")})
|
|
12 txdb <- makeTxDbFromGFF(opt$gtfFile, format=opt$input_type)
|
|
13 k <- keys(txdb, keytype = "GENEID")
|
|
14 df <- select(txdb, keys = k, keytype = "GENEID", columns = "TXNAME")
|
|
15 tx2gene <- df[, 2:1] # tx ID, then gene ID
|
|
16 write.table(tx2gene,file = opt$outfile, quote = FALSE, sep = " ",row.names = FALSE,col.names = FALSE)
|
|
17
|