annotate data_manager/get_tx2gene_table.R @ 4:bacd91d8b05a draft

Uploaded
author ieguinoa
date Sun, 21 Oct 2018 17:48:48 -0400
parents d71f65b854de
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
1 library(getopt)
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
2
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
3 # we read the options from the default: commandArgs(TRUE).
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
4 spec <- matrix(c(
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
5 "input_type", "t", 1, "character",
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
6 "outfile", "o", 1, "character",
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
7 "gtfFile", "x", 1, "character"),
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
8 byrow=TRUE, ncol=4)
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
9 opt <- getopt(spec)
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
10
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
11 suppressPackageStartupMessages({library("GenomicFeatures")})
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
12 txdb <- makeTxDbFromGFF(opt$gtfFile, format=opt$input_type)
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
13 k <- keys(txdb, keytype = "GENEID")
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
14 df <- select(txdb, keys = k, keytype = "GENEID", columns = "TXNAME")
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
15 tx2gene <- df[, 2:1] # tx ID, then gene ID
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
16 write.table(tx2gene,file = opt$outfile, quote = FALSE, sep = " ",row.names = FALSE,col.names = FALSE)
d71f65b854de Uploaded
ieguinoa
parents:
diff changeset
17