annotate tmpnt.R @ 0:cc424daed0b0 draft

Uploaded
author dktanwar
date Tue, 24 Oct 2017 07:05:58 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
1 ## How to execute this tool
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
2 # $Rscript test_norm.R --input input.txt --output output.txt
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
3
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
4 # Send R errors to stderr
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
5 options(show.error.messages = F, error = function(){cat(geterrmessage(), file = stderr()); q("no", 1, F)})
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
6
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
7 # Avoid crashing Galaxy with an UTF8 error on German LC settings
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
8 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
9
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
10 # Import library
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
11 library("getopt")
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
12 library(limma)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
13 library("edgeR")
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
14
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
15 options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
16
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
17 # Take in trailing command line arguments
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
18 args <- commandArgs(trailingOnly = TRUE)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
19
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
20 # Get options using the spec as defined by the enclosed list
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
21 # Options are read from the default: commandArgs(TRUE)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
22 option_specification = matrix(c(
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
23 'input', 'i', 2, 'character',
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
24 'output', 'o', 2, 'character'
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
25 ), byrow=TRUE, ncol=4);
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
26
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
27 # Parse options
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
28 options = getopt(option_specification);
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
29
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
30 # Print options to stderr for debugging
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
31 cat("\n input: ", options$input)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
32 cat("\n output: ", options$output)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
33
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
34 # Read in the input file
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
35 inp <- read.table(file = options$input, sep = "\t", header = T, stringsAsFactors = FALSE)
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
36
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
37 # Changes every value in the first column to 0
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
38 cpm <- inp2
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
39
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
40 # Write output to new file which will be recognized by Galaxy
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
41 write.table(cpm, file = options$output, row.names = F, quote = F, sep = "\t")
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
42
cc424daed0b0 Uploaded
dktanwar
parents:
diff changeset
43 cat("\n success \n")