Mercurial > repos > bgruening > music_compare
annotate scripts/compare.R @ 5:d817b3807562 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 7b4e1e85d9d288a904444eb9fcb96bcdc856b9ff
author | bgruening |
---|---|
date | Wed, 06 Nov 2024 23:22:10 +0000 |
parents | 4447ed460308 |
children |
rev | line source |
---|---|
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
1 suppressWarnings(suppressPackageStartupMessages(library(xbioc))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
2 suppressWarnings(suppressPackageStartupMessages(library(MuSiC))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
3 suppressWarnings(suppressPackageStartupMessages(library(reshape2))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
4 suppressWarnings(suppressPackageStartupMessages(library(cowplot))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
5 ## We use this script to estimate the effectiveness of proportion methods |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
6 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
7 ## Load Conf |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
8 args <- commandArgs(trailingOnly = TRUE) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
9 source(args[1]) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
10 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
11 method_key <- list("MuSiC" = "est_music", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
12 "NNLS" = "est_nnls")[[est_method]] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
13 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
14 delim <- "::" ## separator bulk datasets and their samples |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
15 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
16 scale_yaxes <- function(gplot, value) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
17 if (is.na(value)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
18 gplot |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
19 } else { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
20 gplot + scale_y_continuous(lim = c(0, value)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
21 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
22 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
23 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
24 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
25 set_factor_data <- function(bulk_data, factor_name = NULL) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
26 if (is.null(factor_name)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
27 factor_name <- "None" ## change to something plottable |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
28 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
29 pdat <- pData(bulk_data) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
30 sam_fact <- NULL |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
31 if (factor_name %in% colnames(pdat)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
32 sam_fact <- cbind(rownames(pdat), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
33 as.character(pdat[[factor_name]])) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
34 cat(paste0(" - factor: ", factor_name, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
35 " found in phenotypes\n")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
36 } else { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
37 ## We assign this as the factor for the entire dataset |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
38 sam_fact <- cbind(rownames(pdat), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
39 factor_name) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
40 cat(paste0(" - factor: assigning \"", factor_name, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
41 "\" to whole dataset\n")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
42 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
43 colnames(sam_fact) <- c("Samples", "Factors") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
44 return(as.data.frame(sam_fact)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
45 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
46 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
47 ## Due to limiting sizes, we need to load and unload |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
48 ## possibly very large datasets. |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
49 process_pair <- function(sc_data, bulk_data, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
50 ctypes_label, samples_label, ctypes, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
51 factor_group) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
52 ## - Generate |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
53 est_prop <- music_prop( |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
54 bulk.eset = bulk_data, sc.eset = sc_data, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
55 clusters = ctypes_label, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
56 samples = samples_label, select.ct = ctypes, verbose = T) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
57 ## - |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
58 estimated_music_props <- est_prop$Est.prop.weighted |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
59 estimated_nnls_props <- est_prop$Est.prop.allgene |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
60 ## - |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
61 fact_data <- set_factor_data(bulk_data, factor_group) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
62 ## - |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
63 return(list(est_music = estimated_music_props, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
64 est_nnls = estimated_nnls_props, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
65 bulk_sample_totals = colSums(exprs(bulk_data)), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
66 plot_groups = fact_data)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
67 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
68 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
69 music_on_all <- function(files) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
70 results <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
71 for (sc_name in names(files)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
72 cat(paste0("sc-group:", sc_name, "\n")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
73 scgroup <- files[[sc_name]] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
74 ## - sc Data |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
75 sc_est <- readRDS(scgroup$dataset) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
76 ## - params |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
77 celltypes_label <- scgroup$label_cell |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
78 samples_label <- scgroup$label_sample |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
79 celltypes <- scgroup$celltype |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
80 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
81 results[[sc_name]] <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
82 for (bulk_name in names(scgroup$bulk)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
83 cat(paste0(" - bulk-group:", bulk_name, "\n")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
84 bulkgroup <- scgroup$bulk[[bulk_name]] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
85 ## - bulk Data |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
86 bulk_est <- readRDS(bulkgroup$dataset) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
87 ## - bulk params |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
88 pheno_facts <- bulkgroup$pheno_facts |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
89 pheno_excl <- bulkgroup$pheno_excl |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
90 ## |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
91 results[[sc_name]][[bulk_name]] <- process_pair( |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
92 sc_est, bulk_est, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
93 celltypes_label, samples_label, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
94 celltypes, bulkgroup$factor_group) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
95 ## |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
96 rm(bulk_est) ## unload |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
97 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
98 rm(sc_est) ## unload |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
99 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
100 return(results) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
101 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
102 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
103 plot_all_individual_heatmaps <- function(results) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
104 pdf(out_heatmulti_pdf, width = 8, height = 8) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
105 for (sc_name in names(results)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
106 for (bk_name in names(results[[sc_name]])) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
107 res <- results[[sc_name]][[bk_name]] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
108 plot_hmap <- Prop_heat_Est( |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
109 data.matrix(res[[method_key]]), method.name = est_method) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
110 ggtitle(paste0("[", est_method, "Cell type ", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
111 "proportions in ", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
112 bk_name, " (Bulk) based on ", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
113 sc_name, " (scRNA)")) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
114 xlab("Cell Types (scRNA)") + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
115 ylab("Samples (Bulk)") + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
116 theme(axis.text.x = element_text(angle = -90), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
117 axis.text.y = element_text(size = 6)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
118 print(plot_hmap) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
119 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
120 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
121 dev.off() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
122 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
123 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
124 merge_factors_spread <- function(grudat_spread, factor_groups) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
125 ## Generated |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
126 merge_it <- function(matr, plot_groups, valname) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
127 ren <- melt(lapply(matr, function(mat) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
128 mat["ct"] <- rownames(mat); return(mat)})) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
129 ## - Grab factors and merge into list |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
130 ren_new <- merge(ren, plot_groups, by.x = "variable", by.y = "Samples") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
131 colnames(ren_new) <- c("Sample", "Cell", valname, "Bulk", "Factors") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
132 return(ren_new) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
133 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
134 tab <- merge(merge_it(grudat$spread$prop, factor_groups, "value.prop"), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
135 merge_it(grudat$spread$scale, factor_groups, "value.scale"), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
136 by = c("Sample", "Cell", "Bulk", "Factors")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
137 return(tab) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
138 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
139 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
140 unlist_names <- function(results, method, prepend_bkname=FALSE) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
141 unique(sort( |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
142 unlist(lapply(names(results), function(scname) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
143 lapply(names(results[[scname]]), function(bkname) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
144 res <- get(method)(results[[scname]][[bkname]][[method_key]]) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
145 if (prepend_bkname) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
146 ## We *do not* assume unique bulk sample names |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
147 ## across different bulk datasets. |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
148 res <- paste0(bkname, delim, res) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
149 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
150 return(res) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
151 }) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
152 })) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
153 )) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
154 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
155 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
156 summarized_matrix <- function(results) { # nolint |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
157 ## We assume that cell types MUST be unique, but that sample |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
158 ## names do not need to be. For this reason, we must prepend |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
159 ## the bulk dataset name to the individual sample names. |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
160 all_celltypes <- unlist_names(results, "colnames") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
161 all_samples <- unlist_names(results, "rownames", prepend_bkname = TRUE) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
162 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
163 ## Iterate through all possible samples and populate a table. |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
164 ddff <- data.frame() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
165 ddff_scale <- data.frame() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
166 for (cell in all_celltypes) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
167 for (sample in all_samples) { |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
168 group_sname <- unlist(strsplit(sample, split = delim)) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
169 bulk <- group_sname[1] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
170 id_sample <- group_sname[2] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
171 for (scgroup in names(results)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
172 if (bulk %in% names(results[[scgroup]])) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
173 mat_prop <- results[[scgroup]][[bulk]][[method_key]] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
174 vec_counts <- results[[scgroup]][[bulk]]$bulk_sample_totals |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
175 ## - We use sample instead of id_sample because we need to |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
176 ## extract bulk sets from the complete matrix later. It's |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
177 ## messy, yes. |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
178 if (cell %in% colnames(mat_prop)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
179 ddff[cell, sample] <- mat_prop[id_sample, cell] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
180 ddff_scale[cell, sample] <- mat_prop[id_sample, cell] * vec_counts[[id_sample]] #nolint |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
181 } else { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
182 ddff[cell, sample] <- 0 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
183 ddff_scale[cell, sample] <- 0 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
184 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
185 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
186 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
187 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
188 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
189 return(list(prop = ddff, scaled = ddff_scale)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
190 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
191 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
192 flatten_factor_list <- function(results) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
193 ## Get a 2d DF of all factors across all bulk samples. |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
194 res <- c() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
195 for (scgroup in names(results)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
196 for (bulkgroup in names(results[[scgroup]])) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
197 dat <- results[[scgroup]][[bulkgroup]]$plot_groups |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
198 dat$Samples <- paste0(bulkgroup, delim, dat$Samples) #nolint |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
199 res <- rbind(res, dat) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
200 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
201 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
202 return(res) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
203 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
204 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
205 group_by_dataset <- function(summat) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
206 bulk_names <- unlist( |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
207 lapply(names(files), function(x) names(files[[x]]$bulk))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
208 mat_names <- colnames(summat$prop) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
209 bd <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
210 bd_scale <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
211 bd_spread_scale <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
212 bd_spread_prop <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
213 for (bname in bulk_names) { |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
214 subs <- mat_names[startsWith(mat_names, paste0(bname, delim))] |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
215 ## - |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
216 bd[[bname]] <- rowSums(summat$prop[, subs]) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
217 bd_scale[[bname]] <- rowSums(summat$scaled[, subs]) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
218 bd_spread_scale[[bname]] <- summat$scaled[, subs] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
219 bd_spread_prop[[bname]] <- summat$prop[, subs] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
220 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
221 return(list(prop = as.data.frame(bd), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
222 scaled = as.data.frame(bd_scale), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
223 spread = list(scale = bd_spread_scale, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
224 prop = bd_spread_prop))) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
225 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
226 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
227 do_cluster <- function(grudat_spread_melt, xaxis, yaxis, value_name, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
228 xlabs="", ylabs="", titled="", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
229 order_col=T, order_row=T, size=11) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
230 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
231 data_m <- grudat_spread_melt |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
232 data_matrix <- { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
233 tmp <- dcast(data_m, formula(paste0(yaxis, " ~ ", xaxis)), value.var = value_name) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
234 rownames(tmp) <- tmp[[yaxis]] |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
235 tmp[[yaxis]] <- NULL |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
236 tmp |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
237 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
238 dist_method <- "euclidean" |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
239 clust_method <- "complete" |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
240 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
241 if (order_row) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
242 dd_row <- as.dendrogram(hclust(dist(data_matrix, method = dist_method), method = clust_method)) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
243 row_ord <- order.dendrogram(dd_row) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
244 ordered_row_names <- row.names(data_matrix[row_ord, ]) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
245 data_m[[yaxis]] <- factor(data_m[[yaxis]], levels = ordered_row_names) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
246 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
247 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
248 if (order_col) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
249 dd_col <- as.dendrogram(hclust(dist(t(data_matrix), method = dist_method), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
250 method = clust_method)) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
251 col_ord <- order.dendrogram(dd_col) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
252 ordered_col_names <- colnames(data_matrix[, col_ord]) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
253 data_m[[xaxis]] <- factor(data_m[[xaxis]], levels = ordered_col_names) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
254 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
255 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
256 heat_plot <- ggplot(data_m, aes_string(x = xaxis, y = yaxis, fill = value_name)) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
257 geom_tile(colour = "white") + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
258 scale_fill_gradient2(low = "steelblue", high = "red", mid = "white", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
259 name = element_blank()) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
260 scale_y_discrete(position = "right") + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
261 theme(axis.text.x = element_text(angle = -90, hjust = 0, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
262 size = size)) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
263 ggtitle(label = titled) + xlab(xlabs) + ylab(ylabs) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
264 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
265 ## Graphics |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
266 dendro_linesize <- 0.5 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
267 dendro_colunit <- 0.2 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
268 dendro_rowunit <- 0.1 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
269 final_plot <- heat_plot |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
270 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
271 if (order_row) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
272 dendro_data_row <- ggdendro::dendro_data(dd_row, type = "rectangle") |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
273 dendro_row <- cowplot::axis_canvas(heat_plot, axis = "y", coord_flip = TRUE) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
274 ggplot2::geom_segment(data = ggdendro::segment(dendro_data_row), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
275 ggplot2::aes(y = -y, x = x, xend = xend, yend = -yend), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
276 size = dendro_linesize) + ggplot2::coord_flip() |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
277 final_plot <- cowplot::insert_yaxis_grob( |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
278 final_plot, dendro_row, grid::unit(dendro_colunit, "null"), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
279 position = "left") |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
280 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
281 if (order_col) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
282 dendro_data_col <- ggdendro::dendro_data(dd_col, type = "rectangle") |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
283 dendro_col <- cowplot::axis_canvas(heat_plot, axis = "x") + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
284 ggplot2::geom_segment(data = ggdendro::segment(dendro_data_col), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
285 ggplot2::aes(x = x, y = y, xend = xend, yend = yend), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
286 size = dendro_linesize) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
287 final_plot <- cowplot::insert_xaxis_grob( |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
288 final_plot, dendro_col, grid::unit(dendro_rowunit, "null"), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
289 position = "top") |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
290 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
291 return(cowplot::ggdraw(final_plot)) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
292 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
293 |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
294 summarize_heatmaps <- function(grudat_spread_melt, do_factors, cluster="None") { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
295 ## - Cluster is either "Rows", "Cols", "Both", or "None" |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
296 do_single <- function(grudat_melted, yaxis, xaxis, fillval, title, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
297 ylabs = element_blank(), xlabs = element_blank(), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
298 use_log = TRUE, size = 11) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
299 ## Convert from matrix to long format |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
300 melted <- grudat_melted ## copy? |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
301 if (use_log) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
302 melted[[fillval]] <- log10(melted[[fillval]] + 1) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
303 } |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
304 if (cluster == "None") { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
305 return(ggplot(melted) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
306 geom_tile(aes_string(y = yaxis, x = xaxis, fill = fillval), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
307 colour = "white") + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
308 scale_fill_gradient2( |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
309 low = "steelblue", high = "red", mid = "white", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
310 name = element_blank()) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
311 theme(axis.text.x = element_text( |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
312 angle = -90, hjust = 0, size = size)) + |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
313 ggtitle(label = title) + xlab(xlabs) + ylab(ylabs)) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
314 } else { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
315 return(do_cluster(grudat_spread_melt, xaxis, yaxis, fillval, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
316 xlabs, ylabs, title, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
317 (cluster %in% c("Cols", "Both")), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
318 (cluster %in% c("Rows", "Both")))) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
319 } |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
320 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
321 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
322 do_gridplot <- function(title, xvar, plot="both", ncol=2, size = 11) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
323 do_logged <- (plot %in% c("log", "both")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
324 do_normal <- (plot %in% c("normal", "both")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
325 plist <- list() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
326 if (do_logged) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
327 plist[["1"]] <- do_single(grudat_spread_melt, "Cell", xvar, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
328 "value.scale", "Reads (log10+1)", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
329 size = size) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
330 plist[["2"]] <- do_single(grudat_spread_melt, "Cell", xvar, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
331 "value.prop", "Sample (log10+1)", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
332 size = size) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
333 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
334 if (do_normal) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
335 plist[["A"]] <- do_single(grudat_spread_melt, "Cell", xvar, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
336 "value.scale", "Reads", use_log = F, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
337 size = size) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
338 plist[["B"]] <- do_single(grudat_spread_melt, "Cell", xvar, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
339 "value.prop", "Sample", use_log = F, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
340 size = size) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
341 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
342 return(plot_grid(ggdraw() + draw_label(title, fontface = "bold"), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
343 plot_grid(plotlist = plist, ncol = ncol), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
344 ncol = 1, rel_heights = c(0.05, 0.95))) |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
345 } |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
346 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
347 p1 <- do_gridplot("Cell Types vs Bulk Datasets", "Bulk", "both") |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
348 p2a <- do_gridplot("Cell Types vs Samples", "Sample", "normal", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
349 ncol = 1, size = 8) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
350 p2b <- do_gridplot("Cell Types vs Samples (log10+1)", "Sample", "log", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
351 ncol = 1, size = 8) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
352 p3 <- ggplot + theme_void() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
353 if (do_factors) { |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
354 p3 <- do_gridplot("Cell Types vs Factors", "Factors", "both") |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
355 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
356 return(list(bulk = p1, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
357 samples = list(log = p2b, normal = p2a), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
358 factors = p3)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
359 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
360 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
361 summarize_boxplots <- function(grudat_spread, do_factors) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
362 common1 <- ggplot(grudat_spread, aes(x = value.prop)) + ggtitle("Sample") + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
363 xlab(element_blank()) + ylab(element_blank()) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
364 common2 <- ggplot(grudat_spread, aes(x = value.scale)) + ggtitle("Reads") + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
365 xlab(element_blank()) + ylab(element_blank()) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
366 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
367 A <- B <- list() #nolint |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
368 ## Cell type by sample |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
369 A$p1 <- common2 + geom_boxplot(aes(y = Cell, color = Bulk)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
370 A$p2 <- common1 + geom_boxplot(aes(y = Cell, color = Bulk)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
371 ## Sample by Cell type |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
372 B$p1 <- common2 + geom_boxplot(aes(y = Bulk, color = Cell)) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
373 ylab("Bulk Dataset") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
374 B$p2 <- common1 + geom_boxplot(aes(y = Bulk, color = Cell)) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
375 ylab("Bulk Dataset") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
376 ## -- Factor plots are optional |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
377 A$p3 <- B$p3 <- A$p4 <- B$p4 <- ggplot() + theme_void() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
378 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
379 if (do_factors) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
380 A$p3 <- common1 + geom_boxplot(aes(y = Cell, color = Factors)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
381 A$p4 <- common2 + geom_boxplot(aes(y = Cell, color = Factors)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
382 B$p3 <- common1 + geom_boxplot(aes(y = Bulk, color = Factors)) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
383 ylab("Bulk Dataset") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
384 B$p4 <- common2 + geom_boxplot(aes(y = Bulk, color = Factors)) + |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
385 ylab("Bulk Dataset") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
386 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
387 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
388 title_a <- "Cell Types vs Bulk Datasets" |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
389 title_b <- "Bulk Datasets vs Cell Types" |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
390 if (do_factors) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
391 title_a <- paste0(title_a, " and Factors") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
392 title_b <- paste0(title_b, " and Factors") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
393 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
394 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
395 a_all <- plot_grid(ggdraw() + draw_label(title_a, fontface = "bold"), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
396 plot_grid(plotlist = A, ncol = 2), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
397 ncol = 1, rel_heights = c(0.05, 0.95)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
398 b_all <- plot_grid(ggdraw() + draw_label(title_b, fontface = "bold"), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
399 plot_grid(plotlist = B, ncol = 2), |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
400 ncol = 1, rel_heights = c(0.05, 0.95)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
401 return(list(cell = a_all, bulk = b_all)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
402 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
403 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
404 filter_output <- function(grudat_spread_melt, out_filt) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
405 print_red <- function(comment, red_list) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
406 cat(paste(comment, paste(red_list, collapse = ", "), "\n")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
407 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
408 grudat_filt <- grudat_spread_melt |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
409 print_red("Total Cell types:", unique(grudat_filt$Cell)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
410 if (!is.null(out_filt$cells)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
411 grudat_filt <- grudat_filt[grudat_filt$Cell %in% out_filt$cells, ] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
412 print_red(" - selecting:", out_filt$cells) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
413 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
414 print_red("Total Factors:", unique(grudat_spread_melt$Factors)) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
415 if (!is.null(out_filt$facts)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
416 grudat_filt <- grudat_filt[grudat_filt$Factors %in% out_filt$facts, ] |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
417 print_red(" - selecting:", out_filt$facts) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
418 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
419 return(grudat_filt) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
420 } |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
421 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
422 writable2 <- function(obj, prefix, title) { |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
423 write.table(obj, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
424 file = paste0("report_data/", prefix, "_", |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
425 title, ".tabular"), |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
426 quote = F, sep = "\t", col.names = NA) |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
427 } |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
428 |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
429 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
430 results <- music_on_all(files) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
431 summat <- summarized_matrix(results) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
432 grudat <- group_by_dataset(summat) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
433 grudat_spread_melt <- merge_factors_spread(grudat$spread, |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
434 flatten_factor_list(results)) |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
435 grudat_spread_melt_filt <- filter_output(grudat_spread_melt, out_filt) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
436 |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
437 plot_all_individual_heatmaps(results) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
438 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
439 ## The output filters ONLY apply to boxplots, since these take |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
440 do_factors <- (length(unique(grudat_spread_melt[["Factors"]])) > 1) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
441 box_plots <- summarize_boxplots(grudat_spread_melt_filt, do_factors) |
1
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
442 heat_maps <- summarize_heatmaps(grudat_spread_melt_filt, do_factors, |
4447ed460308
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
0
diff
changeset
|
443 dendro_setting) |
0
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
444 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
445 pdf(out_heatsumm_pdf, width = 14, height = 14) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
446 print(heat_maps) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
447 print(box_plots) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
448 dev.off() |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
449 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
450 ## Generate output tables |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
451 stats_prop <- lapply(grudat$spread$prop, function(x) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
452 t(apply(x, 1, summary))}) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
453 stats_scale <- lapply(grudat$spread$scale, function(x) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
454 t(apply(x, 1, summary))}) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
455 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
456 ## Make the value table printable |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
457 grudat_spread_melt$value.scale <- as.integer(grudat_spread_melt$value.scale) # nolint |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
458 colnames(grudat_spread_melt) <- c("Sample", "Cell", "Bulk", "Factors", |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
459 "CT Prop in Sample", "Number of Reads") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
460 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
461 writable2(grudat_spread_melt, "values", "Data Table") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
462 writable2(summat$prop, "values", "Matrix of Cell Type Sample Proportions") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
463 writable2({ |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
464 aa <- as.matrix(summat$scaled); mode(aa) <- "integer"; aa |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
465 }, "values", "Matrix of Cell Type Read Counts") |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
466 |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
467 for (bname in names(stats_prop)) { |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
468 writable2(stats_prop[[bname]], "stats", paste0(bname, ": Sample Props")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
469 writable2(stats_scale[[bname]], "stats", paste0(bname, ": Read Props")) |
10bf0f89035f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
470 } |