annotate scripts/estimateprops.R @ 1:817eb707bbf4 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
author bgruening
date Fri, 26 Nov 2021 15:54:31 +0000
parents 2fed32b5aa02
children 577435e5e6b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
1 suppressWarnings(suppressPackageStartupMessages(library(xbioc)))
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
2 suppressWarnings(suppressPackageStartupMessages(library(MuSiC)))
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
3 suppressWarnings(suppressPackageStartupMessages(library(reshape2)))
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
4 suppressWarnings(suppressPackageStartupMessages(library(cowplot)))
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
5 ## We use this script to estimate the effectiveness of proportion methods
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
6
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
7 ## Load Conf
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
8 args <- commandArgs(trailingOnly = TRUE)
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
9 source(args[1])
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
10
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
11 ## Estimate cell type proportions
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
12 est_prop <- music_prop(
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
13 bulk.eset = bulk_eset, sc.eset = scrna_eset,
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
14 clusters = celltypes_label,
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
15 samples = samples_label, select.ct = celltypes, verbose = T)
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
16
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
17 estimated_music_props <- est_prop$Est.prop.weighted
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
18 estimated_nnls_props <- est_prop$Est.prop.allgene
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
19
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
20 ## Show different in estimation methods
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
21 ## Jitter plot of estimated cell type proportions
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
22 jitter_fig <- Jitter_Est(
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
23 list(data.matrix(estimated_music_props),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
24 data.matrix(estimated_nnls_props)),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
25 method.name = methods, title = "Jitter plot of Est Proportions",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
26 size = 2, alpha = 0.7) + theme_minimal()
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
27
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
28
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
29 ## Make a Plot
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
30 ## A more sophisticated jitter plot is provided as below. We separated
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
31 ## the T2D subjects and normal subjects by their disease factor levels.
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
32 estimated_music_props_flat <- melt(estimated_music_props)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
33 estimated_nnls_props_flat <- melt(estimated_nnls_props)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
34
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
35 m_prop <- rbind(estimated_music_props_flat,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
36 estimated_nnls_props_flat)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
37 colnames(m_prop) <- c("Sub", "CellType", "Prop")
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
38
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
39 if (is.null(celltypes)) {
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
40 celltypes <- levels(m_prop$CellType)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
41 message("No celltypes declared, using:")
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
42 message(celltypes)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
43 }
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
44
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
45 if (phenotype_target_threshold == -99) {
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
46 phenotype_target_threshold <- -Inf
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
47 message("phenotype target threshold set to -Inf")
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
48 }
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
49
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
50 if (is.null(phenotype_factors)) {
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
51 phenotype_factors <- colnames(pData(bulk_eset))
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
52 }
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
53 ## filter out unwanted factors like "sampleID" and "subjectName"
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
54 phenotype_factors <- phenotype_factors[
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
55 !(phenotype_factors %in% phenotype_factors_always_exclude)]
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
56 message("Phenotype Factors to use:")
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
57 message(phenotype_factors)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
58
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
59
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
60 m_prop$CellType <- factor(m_prop$CellType, levels = celltypes) # nolint
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
61 m_prop$Method <- factor(rep(methods, each = nrow(estimated_music_props_flat)), # nolint
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
62 levels = methods)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
63 m_prop$Disease_factor <- rep(bulk_eset[[phenotype_target]], 2 * length(celltypes)) # nolint
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
64 m_prop <- m_prop[!is.na(m_prop$Disease_factor), ]
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
65 ## Generate a TRUE/FALSE table of Normal == 1 and Disease == 2
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
66 sample_groups <- c("Normal", sample_disease_group)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
67 m_prop$Disease <- factor(sample_groups[(m_prop$Disease_factor > phenotype_target_threshold) + 1], # nolint
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
68 levels = sample_groups)
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
69
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
70 ## Binary to scale: e.g. TRUE / 5 = 0.2
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
71 m_prop$D <- (m_prop$Disease == # nolint
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
72 sample_disease_group) / sample_disease_group_scale
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
73 ## NA's are not included in the comparison below
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
74 m_prop <- rbind(subset(m_prop, Disease != sample_disease_group),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
75 subset(m_prop, Disease == sample_disease_group))
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
76
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
77 jitter_new <- ggplot(m_prop, aes(Method, Prop)) +
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
78 geom_point(aes(fill = Method, color = Disease, stroke = D, shape = Disease),
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
79 size = 2, alpha = 0.7,
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
80 position = position_jitter(width = 0.25, height = 0)) +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
81 facet_wrap(~ CellType, scales = "free") +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
82 scale_colour_manual(values = c("white", "gray20")) +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
83 scale_shape_manual(values = c(21, 24)) + theme_minimal()
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
84
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
85 ## Plot to compare method effectiveness
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
86 ## Create dataframe for beta cell proportions and Disease_factor levels
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
87 m_prop_ana <- data.frame(pData(bulk_eset)[rep(1:nrow(estimated_music_props), 2), #nolint
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
88 phenotype_factors],
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
89 ct.prop = c(estimated_music_props[, 2],
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
90 estimated_nnls_props[, 2]),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
91 Method = factor(rep(methods,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
92 each = nrow(estimated_music_props)),
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
93 levels = methods))
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
94 colnames(m_prop_ana)[1:length(phenotype_factors)] <- phenotype_factors #nolint
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
95 m_prop_ana <- subset(m_prop_ana, !is.na(m_prop_ana[phenotype_target]))
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
96 m_prop_ana$Disease <- factor(sample_groups[( # nolint
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
97 m_prop_ana[phenotype_target] > phenotype_target_threshold) + 1],
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
98 sample_groups)
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
99 m_prop_ana$D <- (m_prop_ana$Disease == # nolint
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
100 sample_disease_group) / sample_disease_group_scale
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
101
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
102 jitt_compare <- ggplot(m_prop_ana, aes_string(phenotype_target, "ct.prop")) +
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
103 geom_smooth(method = "lm", se = FALSE, col = "black", lwd = 0.25) +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
104 geom_point(aes(fill = Method, color = Disease, stroke = D, shape = Disease),
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
105 size = 2, alpha = 0.7) + facet_wrap(~ Method) +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
106 ggtitle(compare_title) + theme_minimal() +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
107 scale_colour_manual(values = c("white", "gray20")) +
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
108 scale_shape_manual(values = c(21, 24))
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
109
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
110 ## BoxPlot
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
111 plot_box <- Boxplot_Est(list(
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
112 data.matrix(estimated_music_props),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
113 data.matrix(estimated_nnls_props)),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
114 method.name = c("MuSiC", "NNLS")) +
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
115 theme(axis.text.x = element_text(angle = -90),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
116 axis.text.y = element_text(size = 8)) +
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
117 ggtitle(element_blank()) + theme_minimal()
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
118
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
119 ## Heatmap
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
120 plot_hmap <- Prop_heat_Est(list(
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
121 data.matrix(estimated_music_props),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
122 data.matrix(estimated_nnls_props)),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
123 method.name = c("MuSiC", "NNLS")) +
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
124 theme(axis.text.x = element_text(angle = -90),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
125 axis.text.y = element_text(size = 6))
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
126
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
127 pdf(file = outfile_pdf, width = 8, height = 8)
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
128 plot_grid(jitter_fig, plot_box, labels = "auto", ncol = 1, nrow = 2)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
129 plot_grid(jitter_new, jitt_compare, labels = "auto", ncol = 1, nrow = 2)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
130 plot_hmap
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
131 message(dev.off())
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
132
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
133 ## Output Proportions
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
134
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
135 write.table(est_prop$Est.prop.weighted,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
136 file = paste0("report_data/prop_",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
137 "Music Estimated Proportions of Cell Types",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
138 ".tabular"),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
139 quote = F, sep = "\t", col.names = NA)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
140 write.table(est_prop$Est.prop.allgene,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
141 file = paste0("report_data/prop_",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
142 "NNLS Estimated Proportions of Cell Types",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
143 ".tabular"),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
144 quote = F, sep = "\t", col.names = NA)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
145 write.table(est_prop$Weight.gene,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
146 file = paste0("report_data/weightgene_",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
147 "Music Estimated Proportions of Cell Types (by Gene)",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
148 ".tabular"),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
149 quote = F, sep = "\t", col.names = NA)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
150 write.table(est_prop$r.squared.full,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
151 file = paste0("report_data/rsquared_",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
152 "Music R-sqr Estimated Proportions of Each Subject",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
153 ".tabular"),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
154 quote = F, sep = "\t", col.names = NA)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
155 write.table(est_prop$Var.prop,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
156 file = paste0("report_data/varprop_",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
157 "Matrix of Variance of MuSiC Estimates",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
158 ".tabular"),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
159 quote = F, sep = "\t", col.names = NA)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
160
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
161
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
162 ## Summary table
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
163 for (meth in methods) {
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
164 ##lm_beta_meth = lm(ct.prop ~ age + bmi + hba1c + gender, data =
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
165 sub_data <- subset(m_prop_ana, Method == meth)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
166 ## We can only do regression where there are more than 1 factors
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
167 ## so we must find and exclude the ones which are not
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
168 gt1_facts <- sapply(phenotype_factors, function(facname) {
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
169 return(length(unique(sort(sub_data[[facname]]))) == 1)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
170 })
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
171 form_factors <- phenotype_factors
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
172 exclude_facts <- names(gt1_facts)[gt1_facts]
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
173 if (length(exclude_facts) > 0) {
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
174 message("Factors with only one level will be excluded:")
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
175 message(exclude_facts)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
176 form_factors <- phenotype_factors[
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
177 !(phenotype_factors %in% exclude_facts)]
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
178 }
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
179 lm_beta_meth <- lm(as.formula(
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
180 paste("ct.prop", paste(form_factors, collapse = " + "),
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
181 sep = " ~ ")), data = sub_data)
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
182 message(paste0("Summary: ", meth))
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
183 capture.output(summary(lm_beta_meth),
1
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
184 file = paste0("report_data/summ_Log of ",
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
185 meth,
817eb707bbf4 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents: 0
diff changeset
186 " fitting.txt"))
0
2fed32b5aa02 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff changeset
187 }