Mercurial > repos > mvdbeek > r_goseq_1_22_0
comparison getgo.r @ 6:0e9424413ab0 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/goseq_1_22_0 commit f95b47ed1a09ce14d3b565e8ea56d8bf12c35814-dirty
author | mvdbeek |
---|---|
date | Thu, 03 Mar 2016 09:56:51 -0500 |
parents | b79c65c90744 |
children | 04b9c519d3e1 |
comparison
equal
deleted
inserted
replaced
5:b79c65c90744 | 6:0e9424413ab0 |
---|---|
1 suppressWarnings(suppressMessages(library(goseq))) | 1 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
2 suppressWarnings(suppressMessages(library(optparse))) | 2 |
3 suppressWarnings(suppressMessages(library(rtracklayer))) | 3 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
4 suppressWarnings(suppressMessages(library(reshape2))) | 4 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
5 | |
6 suppressPackageStartupMessages({ | |
7 library("goseq") | |
8 library("optparse") | |
9 library("rtracklayer") | |
10 library("reshape2") | |
11 }) | |
12 | |
5 sink(stdout(), type = "message") | 13 sink(stdout(), type = "message") |
6 | 14 |
7 option_list <- list( | 15 option_list <- list( |
8 make_option(c("-gtf", "--gtf"), type="character", help = "Path to GTF file for which to fetch GO data"), | 16 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]"), | 17 make_option(c("-g", "--genome"), type="character", help = "Genome [used for looking up GO categories]"), |
13 ) | 21 ) |
14 | 22 |
15 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) | 23 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) |
16 args = parse_args(parser) | 24 args = parse_args(parser) |
17 | 25 |
18 # Vars: | 26 # vars |
19 | 27 |
20 gtf = args$gtf | 28 gtf = args$gtf |
21 genome = args$genome | 29 genome = args$genome |
22 gene_id = args$gene_id | 30 gene_id = args$gene_id |
23 output = args$output | 31 output = args$output |
24 cats = unlist(strsplit(args$cats, ',')) | 32 cats = unlist(strsplit(args$cats, ',')) |
33 | |
34 # retrieve and transform data | |
25 genes = unique(import.gff(gtf)$gene_id) | 35 genes = unique(import.gff(gtf)$gene_id) |
26 go_categories = getgo(genes, genome, id, fetch.cats=cats) | 36 go_categories = getgo(genes, genome, gene_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) | 37 go_categories = goseq:::reversemapping(go_categories) |
31 go_categories = melt(go_categories) | 38 go_categories = melt(go_categories) |
32 colnames(go_categories) = c("#gene_id", "go_category") | |
33 | 39 |
34 write.table(go_categories, output, sep="\t", row.names = FALSE, quote = FALSE) | 40 write.table(go_categories, output, sep="\t", col.names = FALSE, row.names = FALSE, quote = FALSE) |
35 sessionInfo() | 41 sessionInfo() |