Mercurial > repos > mvdbeek > r_goseq_1_22_0
comparison getgo.r @ 5:b79c65c90744 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/goseq_1_22_0 commit 81aedf1b50849160f6c048c0da4bb1038bb813a5
author | mvdbeek |
---|---|
date | Sun, 28 Feb 2016 11:52:10 -0500 |
parents | |
children | 0e9424413ab0 |
comparison
equal
deleted
inserted
replaced
4:76eab486aba9 | 5:b79c65c90744 |
---|---|
1 suppressWarnings(suppressMessages(library(goseq))) | |
2 suppressWarnings(suppressMessages(library(optparse))) | |
3 suppressWarnings(suppressMessages(library(rtracklayer))) | |
4 suppressWarnings(suppressMessages(library(reshape2))) | |
5 sink(stdout(), type = "message") | |
6 | |
7 option_list <- list( | |
8 make_option(c("-gtf", "--gtf"), type="character", help = "Path to GTF file for which to fetch GO data"), | |
9 make_option(c("-g", "--genome"), type="character", help = "Genome [used for looking up GO categories]"), | |
10 make_option(c("-i", "--gene_id"), type="character", help="Gene ID format"), | |
11 make_option(c("-c", "--cats"), type="character", help="Comma-seperated list of categories to fetch"), | |
12 make_option(c("-o", "--output"), type="character", help="Path to output file") | |
13 ) | |
14 | |
15 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) | |
16 args = parse_args(parser) | |
17 | |
18 # Vars: | |
19 | |
20 gtf = args$gtf | |
21 genome = args$genome | |
22 gene_id = args$gene_id | |
23 output = args$output | |
24 cats = unlist(strsplit(args$cats, ',')) | |
25 genes = unique(import.gff(gtf)$gene_id) | |
26 go_categories = getgo(genes, genome, id, fetch.cats=cats) | |
27 | |
28 # transform go category list to sth. more manipulatable in galaxy | |
29 go_categories <- lapply(go_categories, unlist) | |
30 go_categories = goseq:::reversemapping(go_categories) | |
31 go_categories = melt(go_categories) | |
32 colnames(go_categories) = c("#gene_id", "go_category") | |
33 | |
34 write.table(go_categories, output, sep="\t", row.names = FALSE, quote = FALSE) | |
35 sessionInfo() |