-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.R
More file actions
183 lines (144 loc) · 5.97 KB
/
tests.R
File metadata and controls
183 lines (144 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Test functions / code for main Shiny app
## Tabs
# '1) View protein traces'
# '2) Protein differential intensity'
# '3) Protein differential assembly'
# '4) View complex features'
# '5) Complex differential intensity'
## Objects/plots
# plot
# anntable
# pc_volcano
# pc_difftable
# pc_assemblyScatter
# pc_assemblyTable
# cc_volcano
# cc_table
# cf_traces
# cf_table
# define inputs
default_proteins <- c("NUP54", "NUP62", "NUP58 KIAA0410 NUPL1")
default_complexftid <- "127_corum_corum"
input = list("fcolumn" = "Gene_names",
"fvalue" = default_proteins,
"logscale" = FALSE,
"collapse_conditions" = FALSE,
"collapse_replicates" = TRUE,
"show_monomers" = TRUE,
"pc_volcano_pvalcutoff" = 0.05,
"pc_volcano_fccutoff" = 2,
"cc_volcano_pvalcutoff" = 0.05,
"cc_volcano_fccutoff" = 2,
"pc_assemblyScatter_meanDiffcutoff" = 0.3)
target_id_traces = subset(protTraces, trace_subset_ids = input$fvalue,
trace_subset_type = input$fcolumn)
# Test traces plot
##################
plot(target_id_traces,
#colour_by = input$fcolumn,
collapse_conditions = input$collapse_conditions,
aggregateReplicates = input$collapse_replicates,
name = "",
monomer_MW = input$show_monomers,
# log = input$logscale,
design_matrix = designMatrix,
plot = FALSE)
# get protein info for selected set independent of filter column type
proteins[get(input$fcolumn) %in% input$fvalue]
# Test pc Volcano plot
######################
diffProteins = diffProteins_differentiated_undifferentiated
selected_protein_ids = proteins[get(input$fcolumn) %in% input$fvalue]$protein_id
dplot <<- plotVolcano(diffProteins,
pBHadj_cutoff = input$pc_volcano_pvalcutoff,
FC_cutoff = input$pc_volcano_fccutoff,
highlight = selected_protein_ids,
plot = FALSE)
ggplotly(dplot)
# Test pc Scatter plot
######################
diffProteinAssemblyState = copy(diffAssemblyState_differentiated_undifferentiated)
selected_protein_ids = proteins[get(input$fcolumn) %in% input$fvalue]$protein_id
meanDiff_cutoff = input$pc_assemblyScatter_meanDiffcutoff
splot1 <<- ggplot(diffProteinAssemblyState,
aes(x=meanAMF1, y=meanAMF2, colour=-log10(betaPval_BHadj), label = paste(protein_id,Entry_name,Gene_names))) +
geom_abline(intercept = meanDiff_cutoff, slope = 1) +
geom_abline(intercept = -meanDiff_cutoff, slope = 1) +
geom_point() +
theme_bw()
splot2 = splot1 + geom_point(data = diffProteinAssemblyState[protein_id %in% selected_protein_ids],
aes(x=meanAMF1, y=meanAMF2, label = paste(protein_id,Entry_name,Gene_names)),
colour="red", size = 3)
ggplotly(splot2)
## Test differential Complex-centric plots/analysis
###################################################
###################################################
# Are all complex Ids the same in the 3 comparisons?
library(UpSetR)
upset(fromList(list("d_ud" = diffComplexes_differentiated_undifferentiated$complex_id,
"st_d" = diffComplexes_stimulated_differentiated$complex_id,
"st_ud" = diffComplexes_stimulated_undifferentiated$complex_id)))
# All are the same!
# CC volcano
############
diffComplexes = copy(diffComplexes_differentiated_undifferentiated)
selected_complex_id = default_complexftid
plotVolcano(diffComplexes,
pBHadj_cutoff = input$cc_volcano_pvalcutoff,
FC_cutoff = input$cc_volcano_fccutoff,
highlight = selected_complex_id,
plot = FALSE)
# debugonce(plotVolcano)
# label choice n/a, workaround: Additional function plotVolcano_c for complex level plot with hover label
plotVolcano_c(diffComplexes,
pBHadj_cutoff = input$cc_volcano_pvalcutoff,
FC_cutoff = input$cc_volcano_fccutoff,
highlight = selected_complex_id,
plot = FALSE)
## Test cc feature plots
target_complex = selected_complex_id
CCprofiler::plotFeatures(feature_table = complexFeaturesCollapsed,
traces = protTraces,
feature_id = input$cf_value,
design_matrix=designMatrix,
calibration=calibration_functions,
annotation_label = "Entry_name",
peak_area = T,
legend = F,
onlyBest = F,
PDF = FALSE,
monomer_MW=T,
aggregateReplicates=T)
# Test alternative complex ids that are part of a complexfeatureid group
# target_complex = "2202_corum_corum" -> runs itself dead
# full feature id:
input[["cf_column"]] = "complex_id"
input[["cf_value"]] = complexFeaturesCollapsed$complex_id[11] # works smoothly
names(complexFeaturesCollapsed)
CCprofiler::plotFeatures(feature_table = complexFeaturesCollapsed,
traces = protTraces,
feature_id = input$cf_value,
design_matrix=designMatrix,
calibration=calibration_functions,
annotation_label = "Entry_name",
peak_area = T,
legend = F,
onlyBest = F,
PDF = FALSE,
monomer_MW=T,
aggregateReplicates=T)
p = plotFeaturesObject(feature_table = complexFeaturesCollapsed,
traces = protTraces,
feature_id = input$cf_value,
design_matrix=designMatrix,
calibration=calibration_functions,
annotation_label = "Entry_name",
peak_area = T,
legend = F,
onlyBest = F,
PDF = FALSE,
monomer_MW=T,
aggregateReplicates=T)
# plot object return won't work; internal methods required:
# Fehler in plotFeaturesObject(feature_table = complexFeaturesCollapsed, :
# unbenutzte Argumente (design_matrix = designMatrix, aggregateReplicates = T)