Mercurial > repos > artbio > repenrich
comparison edgeR_repenrich.R @ 13:530626b0757c draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/repenrich commit df6b9491ad06e8a85e67c663b68db3cce3eb0115
author | artbio |
---|---|
date | Tue, 02 Apr 2024 21:16:37 +0000 |
parents | 6bba3e33c2e7 |
children |
comparison
equal
deleted
inserted
replaced
12:89e05f831259 | 13:530626b0757c |
---|---|
17 }) | 17 }) |
18 | 18 |
19 options(stringAsFactors = FALSE, useFancyQuotes = FALSE) | 19 options(stringAsFactors = FALSE, useFancyQuotes = FALSE) |
20 | 20 |
21 # get options, using the spec as defined by the enclosed list. | 21 # get options, using the spec as defined by the enclosed list. |
22 # we read the options from the default: commandArgs(TRUE). | |
23 spec <- matrix( | 22 spec <- matrix( |
24 c( | 23 c( |
25 "quiet", "q", 0, "logical", | 24 "quiet", "q", 0, "logical", |
26 "outfile", "o", 1, "character", | 25 "outfile", "o", 1, "character", |
27 "countsfile", "n", 1, "character", | 26 "countsfile", "n", 1, "character", |
28 "factorName", "N", 1, "character", | 27 "factorName", "N", 1, "character", |
29 "levelNameA", "A", 1, "character", | 28 "levelNameA", "A", 1, "character", |
30 "levelNameB", "B", 1, "character", | 29 "levelNameB", "B", 1, "character", |
31 "levelAfiles", "a", 1, "character", | 30 "levelAfiles", "a", 1, "character", |
32 "levelBfiles", "b", 1, "character", | 31 "levelBfiles", "b", 1, "character", |
33 "alignmentA", "i", 1, "character", | |
34 "alignmentB", "j", 1, "character", | |
35 "plots", "p", 1, "character" | 32 "plots", "p", 1, "character" |
36 ), | 33 ), |
37 byrow = TRUE, ncol = 4 | 34 byrow = TRUE, ncol = 4 |
38 ) | 35 ) |
39 opt <- getopt(spec) | 36 opt <- getopt(spec) |
63 } | 60 } |
64 for (element in names(listB[-1])) { | 61 for (element in names(listB[-1])) { |
65 counts <- cbind(counts, listB[[element]][, 4]) | 62 counts <- cbind(counts, listB[[element]][, 4]) |
66 } | 63 } |
67 colnames(counts) <- c(names(listA[-1]), names(listB[-1])) | 64 colnames(counts) <- c(names(listA[-1]), names(listB[-1])) |
68 | 65 sizes <- colSums(counts) |
69 # build aligned counts vector | |
70 filesi <- fromJSON(opt$alignmentA, method = "C", unexpected.escape = "error") | |
71 filesj <- fromJSON(opt$alignmentB, method = "C", unexpected.escape = "error") | |
72 sizes <- c() | |
73 for (file in filesi) { | |
74 sizes <- c(sizes, read.delim(file, header = TRUE)[1, 1]) | |
75 } | |
76 for (file in filesj) { | |
77 sizes <- c(sizes, read.delim(file, header = TRUE)[1, 1]) | |
78 } | |
79 | 66 |
80 # build a meta data object | 67 # build a meta data object |
81 meta <- data.frame( | 68 meta <- data.frame( |
82 row.names = colnames(counts), | 69 row.names = colnames(counts), |
83 condition = c(rep(opt$levelNameA, length(filesA)), rep(opt$levelNameB, length(filesB))), | 70 condition = c(rep(opt$levelNameA, length(filesA)), rep(opt$levelNameB, length(filesB))), |
185 results <- cbind(TE_item = rownames(results), results) | 172 results <- cbind(TE_item = rownames(results), results) |
186 colnames(results) <- c("TE_item", "log2FC", "FDR", "Class", "Type") | 173 colnames(results) <- c("TE_item", "log2FC", "FDR", "Class", "Type") |
187 results$log2FC <- format(results$log2FC, digits = 5) | 174 results$log2FC <- format(results$log2FC, digits = 5) |
188 results$FDR <- format(results$FDR, digits = 5) | 175 results$FDR <- format(results$FDR, digits = 5) |
189 write.table(results, opt$outfile, quote = FALSE, sep = "\t", col.names = TRUE, row.names = FALSE) | 176 write.table(results, opt$outfile, quote = FALSE, sep = "\t", col.names = TRUE, row.names = FALSE) |
190 | |
191 cat("Session information:\n\n") | |
192 sessionInfo() |