Mercurial > repos > bgruening > music_compare
annotate scripts/estimateprops.R.orig @ 2:6c75960f6e56 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
author | bgruening |
---|---|
date | Mon, 28 Oct 2024 17:32:54 +0000 |
parents | |
children |
rev | line source |
---|---|
2
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
1 suppressWarnings(suppressPackageStartupMessages(library(xbioc))) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
2 suppressWarnings(suppressPackageStartupMessages(library(MuSiC))) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
3 suppressWarnings(suppressPackageStartupMessages(library(reshape2))) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
4 suppressWarnings(suppressPackageStartupMessages(library(cowplot))) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
5 ## We use this script to estimate the effectiveness of proportion methods |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
6 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
7 ## Load Conf |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
8 args <- commandArgs(trailingOnly = TRUE) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
9 source(args[1]) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
10 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
11 ## Estimate cell type proportions |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
12 est_prop <- music_prop( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
13 bulk.eset = bulk_eset, sc.eset = scrna_eset, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
14 clusters = celltypes_label, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
15 samples = samples_label, select.ct = celltypes, verbose = T) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
16 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
17 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
18 estimated_music_props <- est_prop$Est.prop.weighted |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
19 estimated_nnls_props <- est_prop$Est.prop.allgene |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
20 ## |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
21 estimated_music_props_flat <- melt(estimated_music_props) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
22 estimated_nnls_props_flat <- melt(estimated_nnls_props) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
23 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
24 scale_yaxes <- function(gplot, value) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
25 if (is.na(value)) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
26 gplot |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
27 } else { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
28 gplot + scale_y_continuous(lim = c(0, value)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
29 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
30 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
31 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
32 sieve_data <- function(func, music_data, nnls_data) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
33 if (func == "list") { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
34 res <- list(if ("MuSiC" %in% methods) music_data else NULL, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
35 if ("NNLS" %in% methods) nnls_data else NULL) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
36 res[lengths(res) > 0] ## filter out NULL elements |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
37 } else if (func == "rbind") { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
38 rbind(if ("MuSiC" %in% methods) music_data else NULL, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
39 if ("NNLS" %in% methods) nnls_data else NULL) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
40 } else if (func == "c") { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
41 c(if ("MuSiC" %in% methods) music_data else NULL, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
42 if ("NNLS" %in% methods) nnls_data else NULL) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
43 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
44 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
45 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
46 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
47 ## Show different in estimation methods |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
48 ## Jitter plot of estimated cell type proportions |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
49 jitter_fig <- scale_yaxes(Jitter_Est( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
50 sieve_data("list", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
51 data.matrix(estimated_music_props), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
52 data.matrix(estimated_nnls_props)), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
53 method.name = methods, title = "Jitter plot of Est Proportions", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
54 size = 2, alpha = 0.7) + theme_minimal(), maxyscale) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
55 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
56 ## Make a Plot |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
57 ## A more sophisticated jitter plot is provided as below. We separated |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
58 ## the T2D subjects and normal subjects by their disease factor levels. |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
59 m_prop <- sieve_data("rbind", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
60 estimated_music_props_flat, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
61 estimated_nnls_props_flat) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
62 colnames(m_prop) <- c("Sub", "CellType", "Prop") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
63 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
64 if (is.null(celltypes)) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
65 celltypes <- levels(m_prop$CellType) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
66 message("No celltypes declared, using:") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
67 message(celltypes) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
68 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
69 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
70 if (is.null(phenotype_factors)) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
71 phenotype_factors <- colnames(pData(bulk_eset)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
72 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
73 ## filter out unwanted factors like "sampleID" and "subjectName" |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
74 phenotype_factors <- phenotype_factors[ |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
75 !(phenotype_factors %in% phenotype_factors_always_exclude)] |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
76 message("Phenotype Factors to use:") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
77 message(paste0(phenotype_factors, collapse = ", ")) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
78 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
79 m_prop$CellType <- factor(m_prop$CellType, levels = celltypes) # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
80 m_prop$Method <- factor(rep(methods, each = nrow(estimated_music_props_flat)), # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
81 levels = methods) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
82 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
83 if (use_disease_factor) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
84 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
85 if (phenotype_target_threshold == -99) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
86 phenotype_target_threshold <- -Inf |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
87 message("phenotype target threshold set to -Inf") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
88 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
89 ## the "2" here is to do with the sample groups, not number of methods |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
90 m_prop$Disease_factor <- rep(bulk_eset[[phenotype_target]], 2 * length(celltypes)) # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
91 m_prop <- m_prop[!is.na(m_prop$Disease_factor), ] |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
92 ## Generate a TRUE/FALSE table of Normal == 1 and Disease == 2 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
93 sample_groups <- c("Normal", sample_disease_group) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
94 m_prop$Disease <- factor(sample_groups[(m_prop$Disease_factor > phenotype_target_threshold) + 1], # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
95 levels = sample_groups) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
96 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
97 ## Binary to scale: e.g. TRUE / 5 = 0.2 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
98 m_prop$D <- (m_prop$Disease == # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
99 sample_disease_group) / sample_disease_group_scale |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
100 ## NA's are not included in the comparison below |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
101 m_prop <- rbind(subset(m_prop, Disease != sample_disease_group), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
102 subset(m_prop, Disease == sample_disease_group)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
103 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
104 jitter_new <- scale_yaxes( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
105 ggplot(m_prop, aes(Method, Prop)) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
106 geom_point(aes(fill = Method, color = Disease, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
107 stroke = D, shape = Disease), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
108 size = 2, alpha = 0.7, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
109 position = position_jitter(width = 0.25, height = 0)) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
110 facet_wrap(~ CellType, scales = "free") + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
111 scale_colour_manual(values = c("white", "gray20")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
112 scale_shape_manual(values = c(21, 24)) + theme_minimal(), maxyscale) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
113 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
114 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
115 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
116 if (use_disease_factor) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
117 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
118 ## Plot to compare method effectiveness |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
119 ## Create dataframe for beta cell proportions and Disease_factor levels |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
120 ## - Ugly code. Essentially, doubles the cell type proportions for each |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
121 ## set of MuSiC and NNLS methods |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
122 m_prop_ana <- data.frame( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
123 pData(bulk_eset)[rep(1:nrow(estimated_music_props), length(methods)), #nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
124 phenotype_factors], |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
125 ## get proportions of target cell type |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
126 ct.prop = sieve_data("c", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
127 estimated_music_props[, phenotype_scrna_target], |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
128 estimated_nnls_props[, phenotype_scrna_target]), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
129 ## |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
130 Method = factor(rep(methods, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
131 each = nrow(estimated_music_props)), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
132 levels = methods)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
133 ## - fix headers |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
134 colnames(m_prop_ana)[1:length(phenotype_factors)] <- phenotype_factors #nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
135 ## - drop NA for target phenotype (e.g. hba1c) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
136 m_prop_ana <- subset(m_prop_ana, !is.na(m_prop_ana[phenotype_target])) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
137 m_prop_ana$Disease <- factor( # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
138 ## - Here we set Normal/Disease assignments across the methods |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
139 sample_groups[( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
140 m_prop_ana[phenotype_target] > phenotype_target_threshold) + 1 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
141 ], |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
142 sample_groups) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
143 ## - Then we scale this binary assignment to a plotable factor |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
144 m_prop_ana$D <- (m_prop_ana$Disease == # nolint |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
145 sample_disease_group) / sample_disease_group_scale |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
146 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
147 jitt_compare <- scale_yaxes( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
148 ggplot(m_prop_ana, aes_string(phenotype_target, "ct.prop")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
149 geom_smooth(method = "lm", se = FALSE, col = "black", lwd = 0.25) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
150 geom_point(aes(fill = Method, color = Disease, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
151 stroke = D, shape = Disease), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
152 size = 2, alpha = 0.7) + facet_wrap(~ Method) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
153 ggtitle(paste0(toupper(phenotype_target), " vs. ", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
154 toupper(phenotype_scrna_target), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
155 " Cell Type Proportion")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
156 theme_minimal() + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
157 ylab(paste0("Proportion of ", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
158 phenotype_scrna_target, " cells")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
159 xlab(paste0("Level of bulk factor (", phenotype_target, ")")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
160 scale_colour_manual(values = c("white", "gray20")) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
161 scale_shape_manual(values = c(21, 24)), maxyscale) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
162 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
163 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
164 ## BoxPlot |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
165 plot_box <- scale_yaxes(Boxplot_Est( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
166 sieve_data("list", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
167 data.matrix(estimated_music_props), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
168 data.matrix(estimated_nnls_props)), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
169 method.name = methods) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
170 theme(axis.text.x = element_text(angle = -90), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
171 axis.text.y = element_text(size = 8)) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
172 ggtitle(element_blank()) + theme_minimal(), maxyscale) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
173 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
174 ## Heatmap |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
175 plot_hmap <- Prop_heat_Est( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
176 sieve_data( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
177 "list", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
178 data.matrix(estimated_music_props), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
179 data.matrix(estimated_nnls_props)), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
180 method.name = methods) + |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
181 theme(axis.text.x = element_text(angle = -90), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
182 axis.text.y = element_text(size = 6)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
183 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
184 pdf(file = outfile_pdf, width = 8, height = 8) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
185 if (length(celltypes) <= 8) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
186 plot_grid(jitter_fig, plot_box, labels = "auto", ncol = 1, nrow = 2) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
187 } else { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
188 print(jitter_fig) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
189 plot_box |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
190 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
191 if (use_disease_factor) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
192 plot_grid(jitter_new, jitt_compare, labels = "auto", ncol = 1, nrow = 2) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
193 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
194 plot_hmap |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
195 message(dev.off()) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
196 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
197 writable <- function(obj, prefix, title) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
198 write.table(obj, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
199 file = paste0("report_data/", prefix, "_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
200 title, ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
201 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
202 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
203 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
204 ## Output Proportions |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
205 if ("NNLS" %in% methods) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
206 writable(est_prop$Est.prop.allgene, "prop", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
207 "NNLS Estimated Proportions of Cell Types") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
208 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
209 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
210 if ("MuSiC" %in% methods) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
211 writable(est_prop$Est.prop.weighted, "prop", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
212 "Music Estimated Proportions of Cell Types") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
213 writable(est_prop$Weight.gene, "weightgene", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
214 "Music Estimated Proportions of Cell Types (by Gene)") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
215 writable(est_prop$r.squared.full, "rsquared", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
216 "Music R-sqr Estimated Proportions of Each Subject") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
217 writable(est_prop$Var.prop, "varprop", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
218 "Matrix of Variance of MuSiC Estimates") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
219 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
220 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
221 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
222 <<<<<<< HEAD |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
223 ======= |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
224 write.table(est_prop$Est.prop.weighted, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
225 file = paste0("report_data/prop_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
226 "Music Estimated Proportions of Cell Types", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
227 ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
228 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
229 write.table(est_prop$Est.prop.allgene, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
230 file = paste0("report_data/prop_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
231 "NNLS Estimated Proportions of Cell Types", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
232 ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
233 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
234 write.table(est_prop$Weight.gene, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
235 file = paste0("report_data/weightgene_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
236 "Music Estimated Proportions of Cell Types (by Gene)", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
237 ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
238 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
239 write.table(est_prop$r.squared.full, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
240 file = paste0("report_data/rsquared_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
241 "Music R-sqr Estimated Proportions of Each Subject", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
242 ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
243 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
244 write.table(est_prop$Var.prop, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
245 file = paste0("report_data/varprop_", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
246 "Matrix of Variance of MuSiC Estimates", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
247 ".tabular"), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
248 quote = F, sep = "\t", col.names = NA) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
249 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
250 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
251 >>>>>>> 7a416140 (fitting summaries only apply when disease factor is used) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
252 if (use_disease_factor) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
253 ## Summary table of linear regressions of disease factors |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
254 for (meth in methods) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
255 ##lm_beta_meth = lm(ct.prop ~ age + bmi + hba1c + gender, data = |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
256 sub_data <- subset(m_prop_ana, Method == meth) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
257 |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
258 ## We can only do regression where there are more than 1 factors |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
259 ## so we must find and exclude the ones which are not |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
260 gt1_facts <- sapply(phenotype_factors, function(facname) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
261 return(length(unique(sort(sub_data[[facname]]))) == 1) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
262 }) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
263 form_factors <- phenotype_factors |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
264 exclude_facts <- names(gt1_facts)[gt1_facts] |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
265 if (length(exclude_facts) > 0) { |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
266 message("Factors with only one level will be excluded:") |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
267 message(exclude_facts) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
268 form_factors <- phenotype_factors[ |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
269 !(phenotype_factors %in% exclude_facts)] |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
270 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
271 lm_beta_meth <- lm(as.formula( |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
272 paste("ct.prop", paste(form_factors, collapse = " + "), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
273 sep = " ~ ")), data = sub_data) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
274 message(paste0("Summary: ", meth)) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
275 capture.output(summary(lm_beta_meth), |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
276 file = paste0("report_data/summ_Log of ", |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
277 meth, |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
278 " fitting.txt")) |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
279 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
280 } |
6c75960f6e56
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit d5c7ca22af1d4f0eaa7a607886554bebb95e8c50
bgruening
parents:
diff
changeset
|
281 |