Mercurial > repos > bgruening > music_inspect_eset
annotate scripts/compare.R @ 8:fde4c972e7c5 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:21:59 +0000 |
parents | 7705cc75ac18 |
children |
rev | line source |
---|---|
3
8c64a2da3869
"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))) |
8c64a2da3869
"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))) |
8c64a2da3869
"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))) |
8c64a2da3869
"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))) |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
6 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
7 ## Load Conf |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
9 source(args[1]) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
10 |
8c64a2da3869
"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", |
8c64a2da3869
"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]] |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
13 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
14 delim <- "::" ## separator bulk datasets and their samples |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
15 |
8c64a2da3869
"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) { |
8c64a2da3869
"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)) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
18 gplot |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
19 } else { |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
21 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
22 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
23 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
24 |
8c64a2da3869
"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) { |
8c64a2da3869
"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)) { |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
28 } |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
30 sam_fact <- NULL |
8c64a2da3869
"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)) { |
8c64a2da3869
"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), |
8c64a2da3869
"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]])) |
8c64a2da3869
"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, |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
36 } else { |
8c64a2da3869
"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 |
8c64a2da3869
"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), |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
39 factor_name) |
8c64a2da3869
"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, |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
42 } |
8c64a2da3869
"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") |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
45 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
46 |
8c64a2da3869
"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 |
8c64a2da3869
"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. |
8c64a2da3869
"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, |
8c64a2da3869
"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, |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
51 factor_group) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
52 ## - Generate |
8c64a2da3869
"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( |
8c64a2da3869
"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, |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
55 clusters = ctypes_label, |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
57 ## - |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
60 ## - |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
62 ## - |
8c64a2da3869
"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, |
8c64a2da3869
"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, |
8c64a2da3869
"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)), |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
67 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
68 |
8c64a2da3869
"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) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
70 results <- list() |
8c64a2da3869
"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)) { |
8c64a2da3869
"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")) |
8c64a2da3869
"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]] |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
74 ## - sc Data |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
76 ## - params |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
79 celltypes <- scgroup$celltype |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
80 |
8c64a2da3869
"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() |
8c64a2da3869
"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)) { |
8c64a2da3869
"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")) |
8c64a2da3869
"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]] |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
85 ## - bulk Data |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
87 ## - bulk params |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
90 ## |
8c64a2da3869
"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( |
8c64a2da3869
"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, |
8c64a2da3869
"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, |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
95 ## |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
97 } |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
99 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
100 return(results) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
101 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
102 |
8c64a2da3869
"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) { |
8c64a2da3869
"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) |
8c64a2da3869
"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)) { |
8c64a2da3869
"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]])) { |
8c64a2da3869
"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]] |
8c64a2da3869
"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( |
8c64a2da3869
"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) + |
8c64a2da3869
"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 ", |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
111 "proportions in ", |
8c64a2da3869
"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 ", |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
113 sc_name, " (scRNA)")) + |
8c64a2da3869
"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)") + |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
115 ylab("Samples (Bulk)") + |
8c64a2da3869
"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), |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
118 print(plot_hmap) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
119 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
120 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
121 dev.off() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
122 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
123 |
8c64a2da3869
"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) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
125 ## Generated |
8c64a2da3869
"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) { |
8c64a2da3869
"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) { |
8c64a2da3869
"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)})) |
8c64a2da3869
"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 |
8c64a2da3869
"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") |
8c64a2da3869
"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") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
132 return(ren_new) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
133 } |
8c64a2da3869
"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"), |
8c64a2da3869
"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"), |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
137 return(tab) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
138 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
139 |
8c64a2da3869
"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) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
141 unique(sort( |
8c64a2da3869
"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) { |
8c64a2da3869
"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) { |
8c64a2da3869
"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]]) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
145 if (prepend_bkname) { |
8c64a2da3869
"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 |
8c64a2da3869
"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. |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
148 res <- paste0(bkname, delim, res) |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
149 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
150 return(res) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
151 }) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
152 })) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
153 )) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
154 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
155 |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"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. |
8c64a2da3869
"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") |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
162 |
8c64a2da3869
"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. |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
164 ddff <- data.frame() |
8c64a2da3869
"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() |
8c64a2da3869
"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) { |
8c64a2da3869
"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) { |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
168 group_sname <- unlist(strsplit(sample, split = delim)) |
3
8c64a2da3869
"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] |
8c64a2da3869
"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] |
8c64a2da3869
"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)) { |
8c64a2da3869
"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]])) { |
8c64a2da3869
"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]] |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
177 ## messy, yes. |
8c64a2da3869
"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)) { |
8c64a2da3869
"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] |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
181 } else { |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
184 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
185 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
186 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
187 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
188 } |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
190 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
191 |
8c64a2da3869
"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) { |
8c64a2da3869
"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. |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
194 res <- c() |
8c64a2da3869
"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)) { |
8c64a2da3869
"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]])) { |
8c64a2da3869
"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 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
198 dat$Samples <- paste0(bulkgroup, delim, dat$Samples) #nolint |
3
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
200 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
201 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
202 return(res) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
203 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
204 |
8c64a2da3869
"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) { |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
206 bulk_names <- unlist( |
8c64a2da3869
"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))) |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
209 bd <- list() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
210 bd_scale <- list() |
8c64a2da3869
"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() |
8c64a2da3869
"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() |
8c64a2da3869
"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) { |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
214 subs <- mat_names[startsWith(mat_names, paste0(bname, delim))] |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
215 ## - |
8c64a2da3869
"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]) |
8c64a2da3869
"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]) |
8c64a2da3869
"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] |
8c64a2da3869
"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] |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
220 } |
8c64a2da3869
"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), |
8c64a2da3869
"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), |
8c64a2da3869
"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, |
8c64a2da3869
"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))) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
225 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
226 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
227 do_cluster <- function(grudat_spread_melt, xaxis, yaxis, value_name, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
228 xlabs="", ylabs="", titled="", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
229 order_col=T, order_row=T, size=11) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
230 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
231 data_m <- grudat_spread_melt |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
232 data_matrix <- { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
233 tmp <- dcast(data_m, formula(paste0(yaxis, " ~ ", xaxis)), value.var = value_name) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
234 rownames(tmp) <- tmp[[yaxis]] |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
235 tmp[[yaxis]] <- NULL |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
236 tmp |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
237 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
238 dist_method <- "euclidean" |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
239 clust_method <- "complete" |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
240 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
241 if (order_row) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
242 dd_row <- as.dendrogram(hclust(dist(data_matrix, method = dist_method), method = clust_method)) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
243 row_ord <- order.dendrogram(dd_row) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
244 ordered_row_names <- row.names(data_matrix[row_ord, ]) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
245 data_m[[yaxis]] <- factor(data_m[[yaxis]], levels = ordered_row_names) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
246 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
247 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
248 if (order_col) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
249 dd_col <- as.dendrogram(hclust(dist(t(data_matrix), method = dist_method), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
250 method = clust_method)) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
251 col_ord <- order.dendrogram(dd_col) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
252 ordered_col_names <- colnames(data_matrix[, col_ord]) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
253 data_m[[xaxis]] <- factor(data_m[[xaxis]], levels = ordered_col_names) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
254 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
255 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
256 heat_plot <- ggplot(data_m, aes_string(x = xaxis, y = yaxis, fill = value_name)) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
257 geom_tile(colour = "white") + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
258 scale_fill_gradient2(low = "steelblue", high = "red", mid = "white", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
259 name = element_blank()) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
260 scale_y_discrete(position = "right") + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
261 theme(axis.text.x = element_text(angle = -90, hjust = 0, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
262 size = size)) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
263 ggtitle(label = titled) + xlab(xlabs) + ylab(ylabs) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
264 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
265 ## Graphics |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
266 dendro_linesize <- 0.5 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
267 dendro_colunit <- 0.2 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
268 dendro_rowunit <- 0.1 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
269 final_plot <- heat_plot |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
270 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
271 if (order_row) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
272 dendro_data_row <- ggdendro::dendro_data(dd_row, type = "rectangle") |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
273 dendro_row <- cowplot::axis_canvas(heat_plot, axis = "y", coord_flip = TRUE) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
274 ggplot2::geom_segment(data = ggdendro::segment(dendro_data_row), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
275 ggplot2::aes(y = -y, x = x, xend = xend, yend = -yend), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
276 size = dendro_linesize) + ggplot2::coord_flip() |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
277 final_plot <- cowplot::insert_yaxis_grob( |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
278 final_plot, dendro_row, grid::unit(dendro_colunit, "null"), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
279 position = "left") |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
280 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
281 if (order_col) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
282 dendro_data_col <- ggdendro::dendro_data(dd_col, type = "rectangle") |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
283 dendro_col <- cowplot::axis_canvas(heat_plot, axis = "x") + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
284 ggplot2::geom_segment(data = ggdendro::segment(dendro_data_col), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
285 ggplot2::aes(x = x, y = y, xend = xend, yend = yend), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
286 size = dendro_linesize) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
287 final_plot <- cowplot::insert_xaxis_grob( |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
288 final_plot, dendro_col, grid::unit(dendro_rowunit, "null"), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
289 position = "top") |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
290 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
291 return(cowplot::ggdraw(final_plot)) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
292 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
293 |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
294 summarize_heatmaps <- function(grudat_spread_melt, do_factors, cluster="None") { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
295 ## - Cluster is either "Rows", "Cols", "Both", or "None" |
3
8c64a2da3869
"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, |
8c64a2da3869
"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(), |
8c64a2da3869
"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) { |
8c64a2da3869
"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 |
8c64a2da3869
"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? |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
301 if (use_log) { |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
303 } |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
304 if (cluster == "None") { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
305 return(ggplot(melted) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
306 geom_tile(aes_string(y = yaxis, x = xaxis, fill = fillval), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
307 colour = "white") + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
308 scale_fill_gradient2( |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
309 low = "steelblue", high = "red", mid = "white", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
310 name = element_blank()) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
311 theme(axis.text.x = element_text( |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
312 angle = -90, hjust = 0, size = size)) + |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
313 ggtitle(label = title) + xlab(xlabs) + ylab(ylabs)) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
314 } else { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
315 return(do_cluster(grudat_spread_melt, xaxis, yaxis, fillval, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
316 xlabs, ylabs, title, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
317 (cluster %in% c("Cols", "Both")), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
318 (cluster %in% c("Rows", "Both")))) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
319 } |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
320 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
321 |
8c64a2da3869
"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) { |
8c64a2da3869
"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")) |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
325 plist <- list() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
326 if (do_logged) { |
8c64a2da3869
"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, |
8c64a2da3869
"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)", |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
329 size = size) |
8c64a2da3869
"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, |
8c64a2da3869
"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)", |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
332 size = size) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
333 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
334 if (do_normal) { |
8c64a2da3869
"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, |
8c64a2da3869
"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, |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
337 size = size) |
8c64a2da3869
"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, |
8c64a2da3869
"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, |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
340 size = size) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
341 } |
8c64a2da3869
"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"), |
8c64a2da3869
"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), |
8c64a2da3869
"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))) |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
345 } |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
346 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
347 p1 <- do_gridplot("Cell Types vs Bulk Datasets", "Bulk", "both") |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
348 p2a <- do_gridplot("Cell Types vs Samples", "Sample", "normal", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
349 ncol = 1, size = 8) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
350 p2b <- do_gridplot("Cell Types vs Samples (log10+1)", "Sample", "log", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
351 ncol = 1, size = 8) |
3
8c64a2da3869
"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() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
353 if (do_factors) { |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
354 p3 <- do_gridplot("Cell Types vs Factors", "Factors", "both") |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
355 } |
8c64a2da3869
"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, |
8c64a2da3869
"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), |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
358 factors = p3)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
359 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
360 |
8c64a2da3869
"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) { |
8c64a2da3869
"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") + |
8c64a2da3869
"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()) |
8c64a2da3869
"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") + |
8c64a2da3869
"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()) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
366 |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) |
8c64a2da3869
"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 |
8c64a2da3869
"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)) + |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
373 ylab("Bulk Dataset") |
8c64a2da3869
"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)) + |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
375 ylab("Bulk Dataset") |
8c64a2da3869
"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 |
8c64a2da3869
"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() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
378 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
379 if (do_factors) { |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) + |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
383 ylab("Bulk Dataset") |
8c64a2da3869
"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)) + |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
385 ylab("Bulk Dataset") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
386 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
387 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
388 title_a <- "Cell Types vs Bulk Datasets" |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
389 title_b <- "Bulk Datasets vs Cell Types" |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
390 if (do_factors) { |
8c64a2da3869
"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") |
8c64a2da3869
"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") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
393 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
394 |
8c64a2da3869
"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"), |
8c64a2da3869
"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), |
8c64a2da3869
"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)) |
8c64a2da3869
"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"), |
8c64a2da3869
"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), |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
402 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
403 |
8c64a2da3869
"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) { |
8c64a2da3869
"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) { |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
407 } |
8c64a2da3869
"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 |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) { |
8c64a2da3869
"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, ] |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
413 } |
8c64a2da3869
"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)) |
8c64a2da3869
"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)) { |
8c64a2da3869
"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, ] |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
418 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
419 return(grudat_filt) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
420 } |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
421 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
422 writable2 <- function(obj, prefix, title) { |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
423 write.table(obj, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
424 file = paste0("report_data/", prefix, "_", |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
425 title, ".tabular"), |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
426 quote = F, sep = "\t", col.names = NA) |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
427 } |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
428 |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
429 |
8c64a2da3869
"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) |
8c64a2da3869
"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) |
8c64a2da3869
"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) |
8c64a2da3869
"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, |
8c64a2da3869
"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)) |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
435 grudat_spread_melt_filt <- filter_output(grudat_spread_melt, out_filt) |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
436 |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
437 plot_all_individual_heatmaps(results) |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
438 |
8c64a2da3869
"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 |
8c64a2da3869
"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) |
8c64a2da3869
"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) |
4
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
442 heat_maps <- summarize_heatmaps(grudat_spread_melt_filt, do_factors, |
7705cc75ac18
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d007ae51743e621dc47524f681501e72ef3a2910"
bgruening
parents:
3
diff
changeset
|
443 dendro_setting) |
3
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
444 |
8c64a2da3869
"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) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
446 print(heat_maps) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
447 print(box_plots) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
448 dev.off() |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
449 |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
450 ## Generate output tables |
8c64a2da3869
"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) { |
8c64a2da3869
"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))}) |
8c64a2da3869
"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) { |
8c64a2da3869
"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))}) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
455 |
8c64a2da3869
"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 |
8c64a2da3869
"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 |
8c64a2da3869
"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", |
8c64a2da3869
"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") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
460 |
8c64a2da3869
"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") |
8c64a2da3869
"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") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
463 writable2({ |
8c64a2da3869
"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 |
8c64a2da3869
"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") |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
466 |
8c64a2da3869
"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)) { |
8c64a2da3869
"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")) |
8c64a2da3869
"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")) |
8c64a2da3869
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 8beed1a19fcd9dc59f7746e1dfa735a2d5f29784"
bgruening
parents:
diff
changeset
|
470 } |