Mercurial > repos > bgruening > music_construct_eset
annotate scripts/estimateprops.R @ 1:be91cb6f48e7 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:55:11 +0000 |
parents | 2cfd0db49bbc |
children | 7902cd31b9b5 |
rev | line source |
---|---|
0
2cfd0db49bbc
"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))) |
2cfd0db49bbc
"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))) |
2cfd0db49bbc
"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))) |
2cfd0db49bbc
"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))) |
2cfd0db49bbc
"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 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
6 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
7 ## Load Conf |
2cfd0db49bbc
"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) |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
9 source(args[1]) |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
10 |
2cfd0db49bbc
"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 |
2cfd0db49bbc
"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( |
2cfd0db49bbc
"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, |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
14 clusters = celltypes_label, |
2cfd0db49bbc
"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) |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
16 |
1
be91cb6f48e7
"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 |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
19 |
2cfd0db49bbc
"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 |
2cfd0db49bbc
"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
be91cb6f48e7
"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( |
be91cb6f48e7
"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), |
be91cb6f48e7
"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)), |
be91cb6f48e7
"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", |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
27 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
28 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
29 ## Make a Plot |
2cfd0db49bbc
"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
be91cb6f48e7
"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. |
be91cb6f48e7
"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) |
be91cb6f48e7
"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) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
34 |
be91cb6f48e7
"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, |
be91cb6f48e7
"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) |
be91cb6f48e7
"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") |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
38 |
be91cb6f48e7
"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)) { |
be91cb6f48e7
"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) |
be91cb6f48e7
"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:") |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
42 message(celltypes) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
43 } |
0
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
44 |
1
be91cb6f48e7
"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) { |
be91cb6f48e7
"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 |
be91cb6f48e7
"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") |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
48 } |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
49 |
be91cb6f48e7
"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)) { |
be91cb6f48e7
"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)) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
52 } |
be91cb6f48e7
"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" |
be91cb6f48e7
"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[ |
be91cb6f48e7
"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)] |
be91cb6f48e7
"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:") |
be91cb6f48e7
"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) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
58 |
0
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
59 |
2cfd0db49bbc
"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
be91cb6f48e7
"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 |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
62 levels = methods) |
be91cb6f48e7
"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 |
be91cb6f48e7
"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), ] |
be91cb6f48e7
"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 |
be91cb6f48e7
"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) |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
68 levels = sample_groups) |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
69 |
1
be91cb6f48e7
"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
2cfd0db49bbc
"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 |
2cfd0db49bbc
"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
be91cb6f48e7
"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 |
be91cb6f48e7
"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), |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
76 |
1
be91cb6f48e7
"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
2cfd0db49bbc
"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), |
2cfd0db49bbc
"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, |
2cfd0db49bbc
"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)) + |
2cfd0db49bbc
"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") + |
2cfd0db49bbc
"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")) + |
2cfd0db49bbc
"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() |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
84 |
2cfd0db49bbc
"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
be91cb6f48e7
"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 |
be91cb6f48e7
"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 |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
88 phenotype_factors], |
be91cb6f48e7
"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], |
be91cb6f48e7
"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]), |
be91cb6f48e7
"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, |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
93 levels = methods)) |
1
be91cb6f48e7
"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 |
be91cb6f48e7
"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
2cfd0db49bbc
"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
be91cb6f48e7
"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], |
be91cb6f48e7
"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
2cfd0db49bbc
"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 |
2cfd0db49bbc
"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 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
101 |
1
be91cb6f48e7
"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
2cfd0db49bbc
"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) + |
2cfd0db49bbc
"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), |
2cfd0db49bbc
"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) + |
2cfd0db49bbc
"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() + |
2cfd0db49bbc
"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")) + |
2cfd0db49bbc
"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)) |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
109 |
1
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
110 ## BoxPlot |
be91cb6f48e7
"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( |
be91cb6f48e7
"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), |
be91cb6f48e7
"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)), |
be91cb6f48e7
"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")) + |
be91cb6f48e7
"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), |
be91cb6f48e7
"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)) + |
be91cb6f48e7
"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() |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
118 |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
119 ## Heatmap |
be91cb6f48e7
"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( |
be91cb6f48e7
"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), |
be91cb6f48e7
"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)), |
be91cb6f48e7
"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")) + |
be91cb6f48e7
"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), |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
126 |
2cfd0db49bbc
"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
be91cb6f48e7
"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) |
be91cb6f48e7
"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) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
130 plot_hmap |
be91cb6f48e7
"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()) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
132 |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
133 ## Output Proportions |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
134 |
be91cb6f48e7
"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, |
be91cb6f48e7
"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_", |
be91cb6f48e7
"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", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
138 ".tabular"), |
be91cb6f48e7
"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) |
be91cb6f48e7
"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, |
be91cb6f48e7
"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_", |
be91cb6f48e7
"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", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
143 ".tabular"), |
be91cb6f48e7
"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) |
be91cb6f48e7
"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, |
be91cb6f48e7
"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_", |
be91cb6f48e7
"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)", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
148 ".tabular"), |
be91cb6f48e7
"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) |
be91cb6f48e7
"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, |
be91cb6f48e7
"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_", |
be91cb6f48e7
"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", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
153 ".tabular"), |
be91cb6f48e7
"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) |
be91cb6f48e7
"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, |
be91cb6f48e7
"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_", |
be91cb6f48e7
"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", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
158 ".tabular"), |
be91cb6f48e7
"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) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
160 |
0
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
161 |
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
162 ## Summary table |
2cfd0db49bbc
"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) { |
2cfd0db49bbc
"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
be91cb6f48e7
"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) |
be91cb6f48e7
"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 |
be91cb6f48e7
"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 |
be91cb6f48e7
"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) { |
be91cb6f48e7
"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) |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
170 }) |
be91cb6f48e7
"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 |
be91cb6f48e7
"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] |
be91cb6f48e7
"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) { |
be91cb6f48e7
"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:") |
be91cb6f48e7
"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) |
be91cb6f48e7
"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[ |
be91cb6f48e7
"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)] |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
178 } |
0
2cfd0db49bbc
"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
be91cb6f48e7
"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 = " + "), |
be91cb6f48e7
"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) |
be91cb6f48e7
"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
2cfd0db49bbc
"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
be91cb6f48e7
"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 ", |
be91cb6f48e7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 683bb72ae92b5759a239b7e3bf4c5a229ed35b54"
bgruening
parents:
0
diff
changeset
|
185 meth, |
be91cb6f48e7
"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
2cfd0db49bbc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/music/ commit 08c6fd3885bdfbf8b5c3f4dcc2d04729b577e3e1"
bgruening
parents:
diff
changeset
|
187 } |