view data_manager/get_tx2gene_table.R @ 3:d71f65b854de draft

Uploaded
author ieguinoa
date Fri, 19 Oct 2018 07:36:02 -0400
parents
children
line wrap: on
line source

library(getopt)

# we read the options from the default: commandArgs(TRUE).
spec <- matrix(c(
  "input_type", "t", 1, "character",
  "outfile", "o", 1, "character",
  "gtfFile", "x", 1, "character"),
  byrow=TRUE, ncol=4)
opt <- getopt(spec)

suppressPackageStartupMessages({library("GenomicFeatures")})
txdb <- makeTxDbFromGFF(opt$gtfFile, format=opt$input_type)
k <- keys(txdb, keytype = "GENEID")
df <- select(txdb, keys = k, keytype = "GENEID", columns = "TXNAME")
tx2gene <- df[, 2:1] # tx ID, then gene ID
write.table(tx2gene,file = opt$outfile, quote = FALSE, sep = " ",row.names = FALSE,col.names = FALSE)