Mercurial > repos > ieguinoa > data_manager_fetch_tx2gene
comparison data_manager/get_tx2gene_table.R @ 3:d71f65b854de draft
Uploaded
author | ieguinoa |
---|---|
date | Fri, 19 Oct 2018 07:36:02 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:7d3ffe28ff3f | 3:d71f65b854de |
---|---|
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 |