annotate edgeR_repenrich.R @ 6:77807fc5d609 draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit e9282183531bacbb4bbe2d6e53258f6e0ad0bc34
author drosofff
date Wed, 31 May 2017 13:09:15 -0400
parents 1805b262c12d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
1 #!/usr/bin/env Rscript
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
2
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
3 # A command-line interface to edgeR for use with Galaxy edger-repenrich
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
4 # written by Christophe Antoniewski drosofff@gmail.com 2017.05.30
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
5
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
6
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
7 # setup R error handling to go to stderr
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
8 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
9
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
10 # To not crash galaxy with an UTF8 error with not-US LC settings.
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
11 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
12
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
13 library("getopt")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
14 library("tools")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
15 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
16 args <- commandArgs(trailingOnly = TRUE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
17
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
18 # get options, using the spec as defined by the enclosed list.
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
19 # we read the options from the default: commandArgs(TRUE).
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
20 spec <- matrix(c(
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
21 "quiet", "q", 0, "logical",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
22 "help", "h", 0, "logical",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
23 "outfile", "o", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
24 "countsfile", "n", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
25 "factorName", "N", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
26 "levelNameA", "A", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
27 "levelNameB", "B", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
28 "levelAfiles", "a", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
29 "levelBfiles", "b", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
30 "alignmentA", "i", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
31 "alignmentB", "j", 1, "character",
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
32 "plots" , "p", 1, "character"),
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
33 byrow=TRUE, ncol=4)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
34 opt <- getopt(spec)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
35
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
36 # if help was asked for print a friendly message
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
37 # and exit with a non-zero error code
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
38 if (!is.null(opt$help)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
39 cat(getopt(spec, usage=TRUE))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
40 q(status=1)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
41 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
42
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
43 # enforce the following required arguments
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
44 if (is.null(opt$outfile)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
45 cat("'outfile' is required\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
46 q(status=1)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
47 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
48 if (is.null(opt$levelAfiles) | is.null(opt$levelBfiles)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
49 cat("input count files are required for both levels\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
50 q(status=1)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
51 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
52 if (is.null(opt$alignmentA) | is.null(opt$alignmentB)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
53 cat("total aligned read files are required for both levels\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
54 q(status=1)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
55 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
56
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
57 verbose <- if (is.null(opt$quiet)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
58 TRUE
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
59 } else {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
60 FALSE
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
61 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
62
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
63 suppressPackageStartupMessages({
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
64 library("edgeR")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
65 library("limma")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
66 })
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
67
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
68 # build levels A and B file lists
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
69
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
70 library("rjson")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
71 filesA <- fromJSON(opt$levelAfiles, method = "C", unexpected.escape = "error")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
72 filesB <- fromJSON(opt$levelBfiles, method = "C", unexpected.escape = "error")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
73 listA <- list()
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
74 indice = 0
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
75 listA[["level"]] <- opt$levelNameA
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
76 for (file in filesA) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
77 indice = indice +1
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
78 listA[[paste0(opt$levelNameA,"_",indice)]] <- read.delim(file, header=FALSE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
79 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
80 listB <- list()
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
81 indice = 0
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
82 listB[["level"]] <- opt$levelNameB
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
83 for (file in filesB) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
84 indice = indice +1
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
85 listB[[paste0(opt$levelNameB,"_",indice)]] <- read.delim(file, header=FALSE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
86 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
87
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
88 # build a counts table
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
89 counts <- data.frame(row.names=listA[[2]][,1])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
90 for (element in names(listA[-1])) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
91 counts<-cbind(counts, listA[[element]][,4])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
92 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
93 for (element in names(listB[-1])) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
94 counts<-cbind(counts, listB[[element]][,4])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
95 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
96 colnames(counts)=c(names(listA[-1]), names(listB[-1]))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
97
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
98 # build aligned counts vector
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
99
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
100 filesi <- fromJSON(opt$alignmentA, method = "C", unexpected.escape = "error")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
101 filesj <- fromJSON(opt$alignmentB, method = "C", unexpected.escape = "error")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
102 sizes <- c()
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
103 for (file in filesi) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
104 sizes <- c(sizes, read.delim(file, header=FALSE)[1,1])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
105 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
106 for (file in filesj) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
107 sizes <- c(sizes, read.delim(file, header=FALSE)[1,1])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
108 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
109
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
110 # build a meta data object
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
111
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
112 meta <- data.frame(
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
113 row.names=colnames(counts),
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
114 condition=c(rep(opt$levelNameA,length(filesA)), rep(opt$levelNameB,length(filesB)) ),
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
115 libsize=sizes
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
116 )
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
117
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
118
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
119 # Define the library size and conditions for the GLM
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
120 libsize <- meta$libsize
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
121 condition <- factor(meta$condition)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
122 design <- model.matrix(~0+condition)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
123 colnames(design) <- levels(meta$condition)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
124
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
125
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
126 # Build a DGE object for the GLM
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
127 y <- DGEList(counts=counts, lib.size=libsize)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
128
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
129 # Normalize the data
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
130 y <- calcNormFactors(y)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
131 y$samples
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
132 # plotMDS(y) latter
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
133
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
134 # Estimate the variance
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
135 y <- estimateGLMCommonDisp(y, design)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
136 y <- estimateGLMTrendedDisp(y, design)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
137 y <- estimateGLMTagwiseDisp(y, design)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
138 # plotBCV(y) latter
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
139
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
140 # Builds and outputs an object to contain the normalized read abundance in counts per million of reads
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
141 cpm <- cpm(y, log=FALSE, lib.size=libsize)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
142 cpm <- as.data.frame(cpm)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
143 colnames(cpm) <- colnames(counts)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
144 if (!is.null(opt$countsfile)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
145 normalizedAbundance <- data.frame(Tag=rownames(cpm))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
146 normalizedAbundance <- cbind(normalizedAbundance, cpm)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
147 write.table(normalizedAbundance, file=opt$countsfile, sep="\t", col.names=TRUE, row.names=FALSE, quote=FALSE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
148 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
149
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
150 # Conduct fitting of the GLM
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
151 yfit <- glmFit(y, design)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
152
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
153 # Initialize result matrices to contain the results of the GLM
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
154 results <- matrix(nrow=dim(counts)[1],ncol=0)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
155 logfc <- matrix(nrow=dim(counts)[1],ncol=0)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
156
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
157 # Make the comparisons for the GLM
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
158 my.contrasts <- makeContrasts(
3
1805b262c12d planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit ca572343d2a24d645dedd6c5d2cb352115ed8bf3
drosofff
parents: 1
diff changeset
159 paste0(opt$levelNameA,"_",opt$levelNameB," = ", opt$levelNameA, " - ", opt$levelNameB),
1
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
160 levels = design
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
161 )
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
162
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
163 # Define the contrasts used in the comparisons
3
1805b262c12d planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit ca572343d2a24d645dedd6c5d2cb352115ed8bf3
drosofff
parents: 1
diff changeset
164 allcontrasts = paste0(opt$levelNameA," vs ",opt$levelNameB)
1
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
165
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
166 # Conduct a for loop that will do the fitting of the GLM for each comparison
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
167 # Put the results into the results objects
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
168 lrt <- glmLRT(yfit, contrast=my.contrasts[,1])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
169 plotSmear(lrt, de.tags=rownames(y))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
170 title(allcontrasts)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
171 res <- topTags(lrt,n=dim(c)[1],sort.by="none")$table
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
172 results <- cbind(results,res[,c(1,5)])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
173 logfc <- cbind(logfc,res[c(1)])
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
174
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
175 # Add the repeat types back into the results.
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
176 # We should still have the same order as the input data
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
177 results$class <- listA[[2]][,2]
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
178 results$type <- listA[[2]][,3]
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
179
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
180 # Sort the results table by the FDR
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
181 results <- results[with(results, order(FDR)), ]
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
182
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
183 # Save the results
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
184 write.table(results, opt$outfile, quote=FALSE, sep="\t", col.names=FALSE)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
185
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
186 # Plot Fold Changes for repeat classes and types
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
187
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
188 # open the device and plots
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
189 if (!is.null(opt$plots)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
190 if (verbose) cat("creating plots\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
191 pdf(opt$plots)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
192 plotMDS(y, main="Multidimensional Scaling Plot Of Distances Between Samples")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
193 plotBCV(y, xlab="Gene abundance (Average log CPM)", main="Biological Coefficient of Variation Plot")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
194 logFC <- results[, "logFC"]
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
195 # Plot the repeat classes
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
196 classes <- with(results, reorder(class, -logFC, median))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
197 par(mar=c(6,10,4,1))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
198 boxplot(logFC ~ classes, data=results, outline=FALSE, horizontal=TRUE,
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
199 las=2, xlab="log(Fold Change)", main=paste0(allcontrasts, ", by Class"))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
200 abline(v=0)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
201 # Plot the repeat types
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
202 types <- with(results, reorder(type, -logFC, median))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
203 boxplot(logFC ~ types, data=results, outline=FALSE, horizontal=TRUE,
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
204 las=2, xlab="log(Fold Change)", main=paste0(allcontrasts, ", by Type"))
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
205 abline(v=0)
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
206 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
207
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
208 # close the plot device
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
209 if (!is.null(opt$plots)) {
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
210 cat("closing plot device\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
211 dev.off()
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
212 }
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
213
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
214 cat("Session information:\n\n")
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
215
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
216 sessionInfo()
54a3f3a195d6 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/repenrich commit 114b47cc624e39b4f485c8623458fc98494c564d
drosofff
parents:
diff changeset
217