Mercurial > repos > artbio > small_rna_maps
annotate small_rna_maps.r @ 34:966bc5c46efd draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
author | artbio |
---|---|
date | Fri, 21 Oct 2022 23:19:55 +0000 |
parents | f2e7ad3058e8 |
children |
rev | line source |
---|---|
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
1 ## Setup R error handling to go to stderr |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
2 options(show.error.messages = FALSE, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
3 error = function() { |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
4 cat(geterrmessage(), file = stderr()) |
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
5 q("no", 1, FALSE) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
6 } |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
7 ) |
7
a96e6a7df2b7
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 06472d1bd1365e4f7b385d578a69f4646481e22f
artbio
parents:
6
diff
changeset
|
8 options(warn = -1) |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
9 library(RColorBrewer) |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
10 library(lattice) |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
11 library(latticeExtra) |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
12 library(grid) |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
13 library(gridExtra) |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
14 library(optparse) |
2
507383cce5a8
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit edbb53cb13b52bf8e71c562fa8acc2c3be2fb270
artbio
parents:
0
diff
changeset
|
15 |
7
a96e6a7df2b7
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 06472d1bd1365e4f7b385d578a69f4646481e22f
artbio
parents:
6
diff
changeset
|
16 |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
17 option_list <- list( |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
18 make_option(c("-i", "--ymin"), type = "double", help = "set min ylimit. e.g. '-100.0'"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
19 make_option(c("-a", "--ymax"), type = "double", help = "set max ylimit. e.g. '100.0'"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
20 make_option(c("-f", "--first_dataframe"), type = "character", help = "path to first dataframe"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
21 make_option(c("-e", "--extra_dataframe"), type = "character", help = "path to additional dataframe"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
22 make_option(c("-n", "--normalization"), type = "character", help = "space-separated normalization/size factors"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
23 make_option("--first_plot_method", type = "character", help = "How additional data should be plotted"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
24 make_option("--extra_plot_method", type = "character", help = "How additional data should be plotted"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
25 make_option("--global", type = "character", help = "data should be plotted as global size distribution"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
26 make_option("--output_pdf", type = "character", help = "path to the pdf file with plots") |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
27 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
28 |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
29 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
30 args <- parse_args(parser) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
31 |
2
507383cce5a8
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit edbb53cb13b52bf8e71c562fa8acc2c3be2fb270
artbio
parents:
0
diff
changeset
|
32 # data frames implementation |
30
183bf49fe77c
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d280e9be7cf96f4938a73ccf5985533109f3328f"
artbio
parents:
27
diff
changeset
|
33 |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
34 ## first table |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
35 table <- read.delim(args$first_dataframe, header = TRUE, row.names = NULL) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
36 colnames(table)[1] <- "Dataset" |
30
183bf49fe77c
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d280e9be7cf96f4938a73ccf5985533109f3328f"
artbio
parents:
27
diff
changeset
|
37 dropcol <- c("Strandness", "z.score") # not used by this Rscript and is dropped for backward compatibility |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
38 table <- table[, !(names(table) %in% dropcol)] |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
39 if (args$first_plot_method == "Counts" || args$first_plot_method == "Size") { |
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
40 table <- within(table, Counts[Polarity == "R"] <- (Counts[Polarity == "R"] * - 1)) # nolint |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
41 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
42 n_samples <- length(unique(table$Dataset)) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
43 samples <- unique(table$Dataset) |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
44 if (args$normalization != "") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
45 norm_factors <- as.numeric(unlist(strsplit(args$normalization, " "))) |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
46 } else { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
47 norm_factors <- rep(1, n_samples) |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
48 } |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
49 if (args$first_plot_method == "Counts" || args$first_plot_method == "Size" || args$first_plot_method == "Coverage") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
50 i <- 1 |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
51 for (sample in samples) { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
52 # Warning Here the column is hard coded as the last column (dangerous) |
30
183bf49fe77c
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d280e9be7cf96f4938a73ccf5985533109f3328f"
artbio
parents:
27
diff
changeset
|
53 # because its name changes with the method |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
54 table[, length(table)][table$Dataset == sample] <- table[, length(table)][table$Dataset == sample] * norm_factors[i] |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
55 i <- i + 1 |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
56 } |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
57 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
58 genes <- unique(table$Chromosome) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
59 per_gene_readmap <- lapply(genes, function(x) subset(table, Chromosome == x)) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
60 per_gene_limit <- lapply(genes, function(x) c(1, unique(subset(table, Chromosome == x)$Chrom_length))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
61 n_genes <- length(per_gene_readmap) |
30
183bf49fe77c
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d280e9be7cf96f4938a73ccf5985533109f3328f"
artbio
parents:
27
diff
changeset
|
62 |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
63 # second table |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
64 if (args$extra_plot_method != "") { |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
65 extra_table <- read.delim(args$extra_dataframe, header = TRUE, row.names = NULL) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
66 colnames(extra_table)[1] <- "Dataset" |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
67 dropcol <- c("Strandness", "z.score") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
68 table <- table[, !(names(table) %in% dropcol)] |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
69 if (args$extra_plot_method == "Counts" || args$extra_plot_method == "Size") { |
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
70 extra_table <- within(extra_table, Counts[Polarity == "R"] <- (Counts[Polarity == "R"] * -1)) # nolint |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
71 } |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
72 if (args$extra_plot_method == "Counts" || args$extra_plot_method == "Size" || args$extra_plot_method == "Coverage") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
73 i <- 1 |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
74 for (sample in samples) { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
75 extra_table[, length(extra_table)][extra_table$Dataset == sample] <- extra_table[, length(extra_table)][extra_table$Dataset == sample] * norm_factors[i] |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
76 i <- i + 1 |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
77 } |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
78 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
79 per_gene_size <- lapply(genes, function(x) subset(extra_table, Chromosome == x)) |
6
a3be3601bcb3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 9f9c64aff0d225881bedb97bd5035ccbca945d9d
artbio
parents:
5
diff
changeset
|
80 } |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
81 |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
82 ## functions |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
83 globalbc <- function(df, global = "", ...) { |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
84 if (global == "yes") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
85 bc <- barchart(Counts ~ as.factor(Size) | factor(Dataset, levels = unique(Dataset)), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
86 data = df, origin = 0, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
87 horizontal = FALSE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
88 col = c("darkblue"), |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
89 scales = list(y = list(tick.number = 4, rot = 90, relation = "same", cex = 0.5, alternating = TRUE), x = list(rot = 0, cex = 0.6, tck = 0.5, alternating = c(3, 3))), |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
90 xlab = list(label = bottom_first_method[[args$first_plot_method]], cex = .85), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
91 ylab = list(label = legend_first_method[[args$first_plot_method]], cex = .85), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
92 main = title_first_method[[args$first_plot_method]], |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
93 layout = c(2, 6), newpage = TRUE, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
94 as.table = TRUE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
95 aspect = 0.5, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
96 strip = strip.custom(par.strip.text = list(cex = 1), which.given = 1, bg = "lightblue"), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
97 ... |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
98 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
99 } else { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
100 bc <- barchart(Counts ~ as.factor(Size) | factor(Dataset, levels = unique(Dataset)), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
101 data = df, origin = 0, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
102 horizontal = FALSE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
103 group = Polarity, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
104 stack = TRUE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
105 col = c("red", "blue"), |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
106 scales = list(y = list(tick.number = 4, rot = 90, relation = "same", cex = 0.5, alternating = TRUE), x = list(rot = 0, cex = 0.6, tck = 0.5, alternating = c(3, 3))), |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
107 xlab = list(label = bottom_first_method[[args$first_plot_method]], cex = .85), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
108 ylab = list(label = legend_first_method[[args$first_plot_method]], cex = .85), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
109 main = title_first_method[[args$first_plot_method]], |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
110 layout = c(2, 6), newpage = TRUE, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
111 as.table = TRUE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
112 aspect = 0.5, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
113 strip = strip.custom(par.strip.text = list(cex = 1), which.given = 1, bg = "lightblue"), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
114 ... |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
115 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
116 } |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
117 return(bc) |
7
a96e6a7df2b7
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 06472d1bd1365e4f7b385d578a69f4646481e22f
artbio
parents:
6
diff
changeset
|
118 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
119 plot_unit <- function(df, method = args$first_plot_method, ...) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
120 if (exists("ymin", where = args)) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
121 min <- args$ymin |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
122 } else { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
123 min <- "" |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
124 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
125 if ((exists("ymax", where = args))) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
126 max <- args$ymax |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
127 } else { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
128 max <- "" |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
129 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
130 ylimits <- c(min, max) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
131 if (method == "Counts") { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
132 p <- xyplot(Counts ~ Coordinate | factor(Dataset, levels = unique(Dataset)) + factor(Chromosome, levels = unique(Chromosome)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
133 data = df, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
134 type = "h", |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
135 lwd = 1.5, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
136 scales = list(relation = "free", x = list(rot = 0, cex = 0.7, axs = "i", tck = 0.5), y = list(tick.number = 4, rot = 90, cex = 0.7)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
137 xlab = NULL, main = NULL, ylab = NULL, ylim = ylimits, |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
138 as.table = TRUE, |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
139 origin = 0, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
140 horizontal = FALSE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
141 group = Polarity, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
142 col = c("red", "blue"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
143 par.strip.text = list(cex = 0.7), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
144 ...) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
145 p <- combineLimits(p) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
146 } else if (method != "Size") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
147 p <- xyplot(eval(as.name(method)) ~ Coordinate | factor(Dataset, levels = unique(Dataset)) + factor(Chromosome, levels = unique(Chromosome)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
148 data = df, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
149 type = ifelse(method == "Coverage", "l", "p"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
150 pch = 19, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
151 cex = 0.35, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
152 scales = list(relation = "free", x = list(rot = 0, cex = 0.7, axs = "i", tck = 0.5), y = list(tick.number = 4, rot = 90, cex = 0.7)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
153 xlab = NULL, main = NULL, ylab = NULL, ylim = ylimits, |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
154 as.table = TRUE, |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
155 origin = 0, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
156 horizontal = FALSE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
157 group = Polarity, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
158 col = c("red", "blue"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
159 par.strip.text = list(cex = 0.7), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
160 ...) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
161 p <- combineLimits(p) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
162 } else { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
163 p <- barchart(Counts ~ as.factor(Size) | factor(Dataset, levels = unique(Dataset)) + Chromosome, data = df, origin = 0, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
164 horizontal = FALSE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
165 group = Polarity, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
166 stack = TRUE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
167 col = c("red", "blue"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
168 scales = list(y = list(rot = 90, relation = "free", cex = 0.7), x = list(rot = 0, cex = 0.7, axs = "i", tck = c(1, 0))), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
169 xlab = NULL, |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
170 ylab = NULL, |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
171 main = NULL, |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
172 as.table = TRUE, |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
173 par.strip.text = list(cex = 0.6), |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
174 ...) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
175 p <- combineLimits(p) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
176 } |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
177 return(p) |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
178 } |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
179 |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
180 |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
181 ## function parameters |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
182 |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
183 par_settings_firstplot <- list(layout.heights = list(top.padding = -2, bottom.padding = -2), strip.background = list(col = c("lightblue", "lightgreen"))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
184 par_settings_secondplot <- list(layout.heights = list(top.padding = -1, bottom.padding = -1), strip.background = list(col = c("lightblue", "lightgreen"))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
185 title_first_method <- list(Counts = "Read Counts", Coverage = "Coverage depths", Median = "Median sizes", Mean = "Mean sizes", Size = "Size Distributions") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
186 title_extra_method <- list(Counts = "Read Counts", Coverage = "Coverage depths", Median = "Median sizes", Mean = "Mean sizes", Size = "Size Distributions") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
187 legend_first_method <- list(Counts = "Read count", Coverage = "Coverage depth", Median = "Median size", Mean = "Mean size", Size = "Read count") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
188 legend_extra_method <- list(Counts = "Read count", Coverage = "Coverage depth", Median = "Median size", Mean = "Mean size", Size = "Read count") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
189 bottom_first_method <- list(Counts = "Coordinates (nucleotides)", Coverage = "Coordinates (nucleotides)", Median = "Coordinates (nucleotides)", Mean = "Coordinates (nucleotides)", Size = "Sizes of reads") |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
190 bottom_extra_method <- list(Counts = "Coordinates (nucleotides)", Coverage = "Coordinates (nucleotides)", Median = "Coordinates (nucleotides)", Mean = "Coordinates (nucleotides)", Size = "Sizes of reads") |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
191 |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
192 ## Plotting Functions |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
193 |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
194 double_plot <- function(...) { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
195 page_height <- 15 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
196 rows_per_page <- 10 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
197 graph_heights <- c(40, 30, 40, 30, 40, 30, 40, 30, 40, 30, 10) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
198 page_width <- 8.2677 * n_samples / 2 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
199 pdf(file = args$output_pdf, paper = "special", height = page_height, width = page_width) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
200 for (i in seq(1, n_genes, rows_per_page / 2)) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
201 start <- i |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
202 end <- i + rows_per_page / 2 - 1 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
203 if (end > n_genes) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
204 end <- n_genes |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
205 } |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
206 if (end - start + 1 < 5) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
207 graph_heights <- c(rep(c(40, 30), end - start + 1), 10, rep(c(40, 30), 5 - (end - start + 1))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
208 } |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
209 first_plot_list <- lapply(per_gene_readmap[start:end], function(x) update(useOuterStrips(plot_unit(x, par.settings = par_settings_secondplot), strip.left = strip.custom(par.strip.text = list(cex = 0.5))))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
210 second_plot_list <- lapply(per_gene_size[start:end], function(x) update(useOuterStrips(plot_unit(x, method = args$extra_plot_method, par.settings = par_settings_firstplot), strip.left = strip.custom(par.strip.text = list(cex = 0.5)), strip = FALSE))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
211 plot.list <- rbind(first_plot_list, second_plot_list) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
212 args_list <- c(plot.list, list(nrow = rows_per_page + 1, ncol = 1, heights = unit(graph_heights, rep("mm", 11)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
213 top = textGrob(paste(title_first_method[[args$first_plot_method]], "and", title_extra_method[[args$extra_plot_method]]), gp = gpar(cex = 1), vjust = 0, just = "top"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
214 left = textGrob(paste(legend_first_method[[args$first_plot_method]], "/", legend_extra_method[[args$extra_plot_method]]), gp = gpar(cex = 1), vjust = 0, hjust = 0, x = 1, y = (-0.38 / 4) * (end - start - (3.28 / 0.38)), rot = 90), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
215 sub = textGrob(paste(bottom_first_method[[args$first_plot_method]], "/", bottom_extra_method[[args$extra_plot_method]]), gp = gpar(cex = 1), just = "bottom", vjust = 2) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
216 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
217 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
218 do.call(grid.arrange, args_list) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
219 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
220 devname <- dev.off() |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
221 } |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
222 |
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
223 |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
224 single_plot <- function(...) { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
225 width <- 8.2677 * n_samples / 2 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
226 rows_per_page <- 8 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
227 graph_heights <- c(rep(40, 8), 10) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
228 pdf(file = args$output_pdf, paper = "special", height = 15, width = width) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
229 for (i in seq(1, n_genes, rows_per_page)) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
230 start <- i |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
231 end <- i + rows_per_page - 1 |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
232 if (end > n_genes) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
233 end <- n_genes |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
234 } |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
235 if (end - start + 1 < 8) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
236 graph_heights <- c(rep(c(40), end - start + 1), 10, rep(c(40), 8 - (end - start + 1))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
237 } |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
238 first_plot_list <- lapply(per_gene_readmap[start:end], function(x) update(useOuterStrips(plot_unit(x, par.settings = par_settings_firstplot), strip.left = strip.custom(par.strip.text = list(cex = 0.5))))) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
239 plot.list <- rbind(first_plot_list) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
240 args_list <- c(plot.list, list(nrow = rows_per_page + 1, ncol = 1, heights = unit(graph_heights, rep("mm", 9)), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
241 top = textGrob(title_first_method[[args$first_plot_method]], gp = gpar(cex = 1), vjust = 0, just = "top"), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
242 left = textGrob(legend_first_method[[args$first_plot_method]], gp = gpar(cex = 1), vjust = 0, hjust = 0, x = 1, y = (-0.41 / 7) * (end - start - (6.23 / 0.41)), rot = 90), |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
243 sub = textGrob(bottom_first_method[[args$first_plot_method]], gp = gpar(cex = 1), just = "bottom", vjust = 2) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
244 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
245 ) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
246 do.call(grid.arrange, args_list) |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
247 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
248 devname <- dev.off() |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
249 } |
0
6d48150495e3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d4d8106d66b65679a1a685ab94bfcf99cdb7b959
artbio
parents:
diff
changeset
|
250 |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
251 # main |
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
252 |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
253 if (args$extra_plot_method != "") { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
254 double_plot() |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
255 } |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
256 if (args$extra_plot_method == "" && !exists("global", where = args)) { |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
257 single_plot() |
5
12c14642e6ac
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 24a21619d79d83b38cef7f1a7b858c621e4c8449
artbio
parents:
2
diff
changeset
|
258 } |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
259 if (exists("global", where = args)) { |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
260 pdf(file = args$output, paper = "special", height = 11.69) |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
261 table <- within(table, Counts[Polarity == "R"] <- abs(Counts[Polarity == "R"])) # nolint |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
262 library(reshape2) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
263 ml <- melt(table, id.vars = c("Dataset", "Chromosome", "Polarity", "Size")) |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
264 if (args$global == "nomerge") { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
265 castml <- dcast(ml, Dataset + Polarity + Size ~ variable, function(x) sum(x)) |
34
966bc5c46efd
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b7c7c60d608694ca4f1638e4bb0d6db5b1afa944
artbio
parents:
32
diff
changeset
|
266 castml <- within(castml, Counts[Polarity == "R"] <- (Counts[Polarity == "R"] * -1)) # nolint |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
267 bc <- globalbc(castml, global = "no") |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
268 } else { |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
269 castml <- dcast(ml, Dataset + Size ~ variable, function(x) sum(x)) |
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
270 bc <- globalbc(castml, global = "yes") |
12
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
271 } |
d33263e6e812
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit b0676fd329c2ca50002f9f2fede531d8e550569f
artbio
parents:
11
diff
changeset
|
272 plot(bc) |
32
f2e7ad3058e8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
artbio
parents:
30
diff
changeset
|
273 devname <- dev.off() |
7
a96e6a7df2b7
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 06472d1bd1365e4f7b385d578a69f4646481e22f
artbio
parents:
6
diff
changeset
|
274 } |