-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 26.3 KB
/
.Rhistory
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# MRS, Algorithm :crit, active, import_5, 18-03, 20-03
# REFINED, Nature Communications :crit, active, import_6, 19-01, 20-05
# RADAR, IEEE Sensors :crit, active, import_7, 19-01, 20-05
# Transfer Learning, BMC Bioinformatics :crit, active, import_8, 19-08, 20-05
# 3D REFINED, BMC Bioinformatics :crit, active, import_9, 20-01, 20-10
# Dose-Response, Oxford Bioinformatics :crit, active, import_10, 20-03, 20-12
section Future milestones
Proposal Defense :active first_1, 20-01, 20-04
Dissertation, Ch 1 - 2 :active first_2, 20-06, 20-10
Dissertation, Ch 3 - 4 :active first_3, 20-10, 21-05
Dissertation, Submission :active first_4, 21-05, 21-06
PhD Defense :active first_5, 21-06, 21-07
Graduation :active first_6, 21-07, 21-08
# Dissertation, Introduction :active first_2, 20-09, 20-10
# Dissertation, Methodology :active first_3, 20-10, 21-02
# Dissertation, Results :active first_4, 21-02, 21-04
# Dissertation, Submission :active first_5, 21-04, 21-05
# Dissertation, Defense :active first_6, 21-06, 21-07
# Graduation :active first_7, 21-07, 21-08
")
# m1$x$config$ganttConfig$numberSectionStyles = 1
print(style_widget(m1, "display:none", "line.today"))
# %>%
rm(list = ls())
setwd("/Users/sdhruba/Dropbox (Personal)/Miscellaneous/Dissertation_fellowship/")
## Define style widgets...
style_widget <- function(hw = NULL, style = "", addl_selector = "") {
stopifnot(!is.null(hw), inherits(hw, "htmlwidget"))
elementId <- hw$elementId # use current id of htmlwidget if already specified
if(is.null(elementId)) {
elementId <- sprintf("htmlwidget-%s", htmlwidgets:::createWidgetId()) # borrow htmlwidgets unique id creator
hw$elementId <- elementId
}
htmlwidgets::prependContent(hw, htmltools::tags$style(sprintf("#%s %s {%s}", elementId, addl_selector, style)))
}
## Add entries to GANTT chart...
m1 <- DiagrammeR::mermaid("
gantt
dateFormat YY-MM
axisFormat %Y-%m
title GANTT Chart: Saugato Rahman Dhruba
section Degrees
# B.Sc. in EEE :done, first_1, 09-03, 14-05
# M.Sc. in ECE :done, first_2, 13-08, 15-08
Ph.D. in ECE :active first_3, 16-08, 21-08
section Publications
Transfer learning [Poster], CNB-MAC 2017 :crit, done, import_1, 16-08, 17-07
Proteomic Data [Talk], BHI 2018 :crit, done, import_2, 17-08, 18-01
Transfer learning [Talk], ICIBM 2018 :crit, done, import_3, 17-08, 18-04
Inconsistency [Article], Briefings in Bioinformatics :crit, done, import_4, 16-08, 18-01
DRTL [Talk], EMBC 2018 :crit, done, import_5, 17-01, 17-08
Recursive model [Talk], CNB-MAC 2018 :crit, done, import_6, 17-11, 18-07
Transfer learning [Article], BMC Bioinformatics :crit, done, import_7, 17-08, 18-06
Functional RF [Article], Scientific Reports :crit, done, import_8, 18-04, 19-01
Recursive model [Article], BMC Bioinformatics :crit, done, import_9, 17-11, 18-08
Tumor-CL TL [Article], Nature Communication :crit, active, import_10, 18-10, 20-03
REFINED [Article], Nature Communications :crit, active, import_11, 19-01, 20-05
Shooter detection [Article], IEEE Sensors :crit, active, import_12, 19-02, 20-05
# Tumor-CL TL [Article], Nature Communication :crit, active, import_13, 20-01, 20-03
# REFINED [Article], Nature Communications :crit, active, import_14, 20-01, 20-05
# Shooter detection [Article], IEEE Sensors :crit, active, import_15, 20-01, 20-05
3D REFINED [Article], BMC Bioinformatics :crit, active, import_16, 20-01, 20-10
section Industry Experience
Co-op internship, Biogen :crit, done, import_1, 19-07, 19-12
PD biomarker [Poster], ASHG 2019 :crit, done, import_2, 19-07, 19-09
section Awards
Presidential Fellowship, TTU :done, import_1, 16-08, 19-07
NSF Travel Award, CNB-MAC 2017 :done, import_2, 17-08
NSF Travel Award, BHI 2018 :done, import_3, 18-03
NSF Travel Award, ICIBM 2018 :done, import_4, 18-06
NSF Travel Award, CNB-MAC 2018 :done, import_5, 18-08
BIG Recognition Award, Biogen :done, impott_6, 19-08
section Future milestones
Proposal Defense :active first_1, 20-01, 20-04
Dissertation, Ch 1 - 2 :active first_2, 20-06, 20-10
Dissertation, Ch 3 - 4 :active first_3, 20-10, 21-05
Dissertation, Submission :active first_4, 21-05, 21-06
PhD Defense :active first_5, 21-06, 21-07
Graduation :active first_6, 21-07, 21-08
# Dissertation, Introduction :active first_2, 20-09, 20-10
# Dissertation, Methodology :active first_3, 20-10, 21-02
# Dissertation, Results :active first_4, 21-02, 21-04
# Dissertation, Submission :active first_5, 21-04, 21-05
# Dissertation, Defense :active first_6, 21-06, 21-07
# Graduation :active first_7, 21-07, 21-08
")
# m1$x$config$ganttConfig$numberSectionStyles = 1
print(style_widget(m1, "display:none", "line.today"))
# %>%
rm(list = ls())
setwd("/Users/sdhruba/Dropbox (Personal)/Miscellaneous/Dissertation_fellowship/")
## Define style widgets...
style_widget <- function(hw = NULL, style = "", addl_selector = "") {
stopifnot(!is.null(hw), inherits(hw, "htmlwidget"))
elementId <- hw$elementId # use current id of htmlwidget if already specified
if(is.null(elementId)) {
elementId <- sprintf("htmlwidget-%s", htmlwidgets:::createWidgetId()) # borrow htmlwidgets unique id creator
hw$elementId <- elementId
}
htmlwidgets::prependContent(hw, htmltools::tags$style(sprintf("#%s %s {%s}", elementId, addl_selector, style)))
}
## Add entries to GANTT chart...
m1 <- DiagrammeR::mermaid("
gantt
dateFormat YY-MM
axisFormat %Y-%m
title GANTT Chart: Saugato Rahman Dhruba
section Degrees
# B.Sc. in EEE :done, first_1, 09-03, 14-05
# M.Sc. in ECE :done, first_2, 13-08, 15-08
Ph.D. in ECE :active first_3, 16-08, 21-08
section Publications
Transfer learning [Poster], CNB-MAC 2017 :crit, done, import_1, 16-08, 17-07
Proteomic Data [Talk], BHI 2018 :crit, done, import_2, 17-08, 18-01
Transfer learning [Talk], ICIBM 2018 :crit, done, import_3, 17-08, 18-04
Inconsistency [Article], Briefings in Bioinformatics :crit, done, import_4, 16-08, 18-01
DRTL [Talk], EMBC 2018 :crit, done, import_5, 17-01, 17-08
Recursive model [Talk], CNB-MAC 2018 :crit, done, import_6, 17-11, 18-07
Transfer learning [Article], BMC Bioinformatics :crit, done, import_7, 17-08, 18-06
Functional RF [Article], Scientific Reports :crit, done, import_8, 18-04, 19-01
Recursive model [Article], BMC Bioinformatics :crit, done, import_9, 17-11, 18-08
Tumor-CL TL [Article], Nature Communication :crit, active, import_10, 18-10, 20-03
REFINED [Article], Nature Communications :crit, active, import_11, 19-01, 20-05
Shooter detection [Article], IEEE Sensors :crit, active, import_12, 19-02, 20-05
# Tumor-CL TL [Article], Nature Communication :crit, active, import_13, 20-01, 20-03
# REFINED [Article], Nature Communications :crit, active, import_14, 20-01, 20-05
# Shooter detection [Article], IEEE Sensors :crit, active, import_15, 20-01, 20-05
3D REFINED [Article], BMC Bioinformatics :crit, active, import_16, 20-01, 20-10
section Industry Experience
Co-op internship, Biogen :crit, done, import_1, 19-07, 19-12
PD biomarker [Poster], ASHG 2019 :crit, done, import_2, 19-07, 19-09
section Awards
Presidential Fellowship, TTU :done, import_1, 16-08, 19-07
NSF Travel Award, CNB-MAC 2017 :done, import_2, 17-08
NSF Travel Award, BHI 2018 :done, import_3, 18-03
NSF Travel Award, ICIBM 2018 :done, import_4, 18-06
NSF Travel Award, CNB-MAC 2018 :done, import_5, 18-08
BIG Recognition Award, Biogen :done, impott_6, 19-08
section Future milestones
Proposal Defense :active first_1, 20-01, 20-04
Dissertation, Ch 1 - 2 :active first_2, 20-06, 20-10
Dissertation, Ch 3 - 4 :active first_3, 20-10, 21-05
Dissertation, Submission :active first_4, 21-05, 21-06
PhD Defense :active first_5, 21-06, 21-07
Graduation :active first_6, 21-07, 21-08
# Dissertation, Introduction :active first_2, 20-09, 20-10
# Dissertation, Methodology :active first_3, 20-10, 21-02
# Dissertation, Results :active first_4, 21-02, 21-04
# Dissertation, Submission :active first_5, 21-04, 21-05
# Dissertation, Defense :active first_6, 21-06, 21-07
# Graduation :active first_7, 21-07, 21-08
")
# m1$x$config$ganttConfig$numberSectionStyles = 1
print(style_widget(m1, "display:none", "line.today"))
# %>%
rm(list = ls())
setwd("/Users/sdhruba/Dropbox (Personal)/Miscellaneous/Dissertation_fellowship/")
## Define style widgets...
style_widget <- function(hw = NULL, style = "", addl_selector = "") {
stopifnot(!is.null(hw), inherits(hw, "htmlwidget"))
elementId <- hw$elementId # use current id of htmlwidget if already specified
if(is.null(elementId)) {
elementId <- sprintf("htmlwidget-%s", htmlwidgets:::createWidgetId()) # borrow htmlwidgets unique id creator
hw$elementId <- elementId
}
htmlwidgets::prependContent(hw, htmltools::tags$style(sprintf("#%s %s {%s}", elementId, addl_selector, style)))
}
## Add entries to GANTT chart...
m1 <- DiagrammeR::mermaid("
gantt
dateFormat YY-MM
axisFormat %Y-%m
title GANTT Chart: Saugato Rahman Dhruba
section Degrees
# B.Sc. in EEE :done, first_1, 09-03, 14-05
# M.Sc. in ECE :done, first_2, 13-08, 15-08
Ph.D. in ECE :active first_3, 16-08, 21-08
section Publications
Transfer learning [Poster], CNB-MAC 2017 :crit, done, import_1, 16-08, 17-07
Proteomic Data [Talk], BHI 2018 :crit, done, import_2, 17-08, 18-01
Transfer learning [Talk], ICIBM 2018 :crit, done, import_3, 17-08, 18-04
Inconsistency [Article], Briefings in Bioinformatics :crit, done, import_4, 16-08, 18-01
DRTL [Talk], EMBC 2018 :crit, done, import_5, 17-01, 17-08
Recursive model [Talk], CNB-MAC 2018 :crit, done, import_6, 17-11, 18-07
Transfer learning [Article], BMC Bioinformatics :crit, done, import_7, 17-08, 18-06
Functional RF [Article], Scientific Reports :crit, done, import_8, 18-04, 19-01
Recursive model [Article], BMC Bioinformatics :crit, done, import_9, 17-11, 18-08
Tumor-CL TL [Article], Nature Communication :crit, active, import_10, 18-10, 20-03
REFINED [Article], Nature Communications :crit, active, import_11, 19-01, 20-05
Shooter detection [Article], IEEE Sensors :crit, active, import_12, 19-02, 20-05
# Tumor-CL TL [Article], Nature Communication :crit, active, import_13, 20-01, 20-03
# REFINED [Article], Nature Communications :crit, active, import_14, 20-01, 20-05
# Shooter detection [Article], IEEE Sensors :crit, active, import_15, 20-01, 20-05
3D REFINED [Article], BMC Bioinformatics :crit, active, import_16, 20-01, 20-10
section Industry Experience
Co-op internship, Biogen :crit, done, import_1, 19-07, 19-12
PD biomarker [Poster], ASHG 2019 :crit, done, import_2, 19-07, 19-09
section Awards
Presidential Fellowship, TTU :done, import_1, 16-08, 19-07
NSF Travel Award, CNB-MAC 2017 :done, import_2, 17-08
NSF Travel Award, BHI 2018 :done, import_3, 18-03
NSF Travel Award, ICIBM 2018 :done, import_4, 18-06
NSF Travel Award, CNB-MAC 2018 :done, import_5, 18-08
BIG Recognition Award, Biogen :done, impott_6, 19-08
section Future milestones
Proposal Defense :active first_1, 20-01, 20-04
Dissertation, Ch 1 - 2 :active first_2, 20-06, 20-10
Dissertation, Ch 3 - 4 :active first_3, 20-10, 21-05
Dissertation, Submission :active first_4, 21-05, 21-06
PhD Defense :active first_5, 21-06, 21-07
Graduation :active first_6, 21-07, 21-08
# Dissertation, Introduction :active first_2, 20-09, 20-10
# Dissertation, Methodology :active first_3, 20-10, 21-02
# Dissertation, Results :active first_4, 21-02, 21-04
# Dissertation, Submission :active first_5, 21-04, 21-05
# Dissertation, Defense :active first_6, 21-06, 21-07
# Graduation :active first_7, 21-07, 21-08
")
# m1$x$config$ganttConfig$numberSectionStyles = 1
print(style_widget(m1, "display:none", "line.today"))
# %>%
y = runif(100, min = 100, max = 300)
y.hat = runif(100, min = 100, max = 300)
?runif
cor(y, y.hat, method = "pearson")
y.hat = y*0.8 + 0.05
cor(y, y.hat, method = "pearson")
y.hat = y*0.8 + 0.05
y = runif(100, min = 100, max = 300)
y.hat = y^2*0.8 - 0.05*y + 0.1
cor(y, y.hat, method = "pearson")
y.hat = y^15*0.8 - 0.05*y + 0.1
cor(y, y.hat, method = "pearson")
y.hat = y^15*0.8 - 0.05*y^3 + 0.1
cor(y, y.hat, method = "pearson")
y = runif(100, min = 100, max = 300)
y.hat = y^15*0.8 - 0.05*y^3 + 0.1
cor(y, y.hat, method = "pearson")
y.hat.z = (y.hat - mean(y.hat)) / sd(y.hat)
cor(y, y.hat, method = "pearson")
cor(y, y.hat.z, method = "pearson")
cor(y, y.hat.z, method = "spearman")
cor(y, y.hat, method = "spearman")
q()
BiocManager::install("PharmacoGx")
library(PharmacoGx)
availablePSets()
load("C:/Users/SRDhruba/Dropbox (Personal)/Virus_Project/kTSP_results_RNAseq3_06_Apr_2020.Rdata")
View(clf.res)
install.packages(R0)
install.packages("R0")
q()
q()
q()
q()
## Compare Images before histMatching
ggRGB(img_a,1,2,3) +
ggRGB(img_b, 1,2,3, ggLayer = TRUE, stretch = "lin", q = 0:1) +
geom_vline(aes(xintercept = 50)) + ggtitle("Img_a vs. Img_b")
library(RStoolbox)
library(ggplot2)
library(raster)
library(RStoolbox)
library(ggplot2)
library(raster)
data(rlogo)
## Original image a (+1 to prevent log(0))
img_a <- rlogo + 1
## Degraded image b
img_b <- log(img_a)
## Cut-off half the image (just for better display)
img_b[, 1:50] <- NA
## Compare Images before histMatching
ggRGB(img_a,1,2,3) +
ggRGB(img_b, 1,2,3, ggLayer = TRUE, stretch = "lin", q = 0:1) +
geom_vline(aes(xintercept = 50)) + ggtitle("Img_a vs. Img_b")
## Do histogram matching
img_b_matched <- histMatch(img_b, img_a)
## Compare Images after histMatching
ggRGB(img_a, 1, 2, 3) +
ggRGB(img_b_matched, 1, 2, 3, ggLayer = TRUE, stretch = "lin", q = 0:1) +
geom_vline(aes(xintercept = 50)) + ggtitle("Img_a vs. Img_b_matched")
## Compare Images before histMatching
ggRGB(img_a,1,2,3) +
ggRGB(img_b, 1,2,3, ggLayer = TRUE, stretch = "lin", q = 0:1) +
geom_vline(aes(xintercept = 50)) + ggtitle("Img_a vs. Img_b")
## Compare Images after histMatching
ggRGB(img_a, 1, 2, 3) +
ggRGB(img_b_matched, 1, 2, 3, ggLayer = TRUE, stretch = "lin", q = 0:1) +
geom_vline(aes(xintercept = 50)) + ggtitle("Img_a vs. Img_b_matched")
hist(redLayers)
## Histogram comparison
opar <- par(mfrow = c(1, 3), no.readonly = TRUE)
img_a[, 1:50] <- NA
redLayers <- stack(img_a, img_b, img_b_matched)[[c(1,4,7)]]
names(redLayers) <- c("img_a", "img_b", "img_b_matched")
hist(redLayers)
## Reset par
par(opar)
??ggRGB
?RStoolbox::ggRGB
ggR(img_a)
dev.off()
ggR(img_a)
dev.off()
ggRGB(img_a)
im1 <- rlogo
ggRGB(im1)
size(im1)
dim(im1)
View(im1)
type(im1)
class(im1)
ggRGB(im1)
ggRGB(log(im1 + 1))
ggRGB(log(im1 + 0))
ggRGB(im1)
image(im1)
View(im1)
m1
im1
ggRGB(im1)
ggRGB(im1, r = 3, g = 2, b = 1)
ggRGB(im1, r = 1, g = 2, b = 3)
install.packages("installr")
installr::updateR()
library(ks)
installr::updateR()
installr::updateR()
installr::updateR()
q()
library(ks)
update.packages(ask = FALSE)
library(ks)
update.packages()
install.packages(ks)
install.packages("ks")
library(ks)
install.packages("ks", dependencies = TRUE)
library(ks)
install.packages("mclust", dependencies = TRUE)
library(ks)
install.packages("mvtnorm", dependencies = TRUE)
library(ks)
library(randomForest)
install.packages("randomForest", dependencies = TRUE)
library(randomForest)
library(KernSmooth)
library(stats)
library(ggplot2)
install.packages("gtable", dependencies = TRUE)
library(ggplot2)
library(ggplot2)
install.packages("lifecycle", dependencies = TRUE)
library(ggplot2)
install.packages("munsell", dependencies = TRUE)
library(ggplot2)
library(ggpubr)
install.packages("ggpubr", dependencies = TRUE)
library(ggpubr)
install.packages("ggsignif", dependencies = TRUE)
library(ggpubr)
install.packages("curl", dependencies = TRUE)
library(ggpubr)
install.packages("forcats", dependencies = TRUE)
library(ggpubr)
install.packages("readxl", dependencies = TRUE)
library(ggpubr)
install.packages("cellranger", dependencies = TRUE)
library(ggpubr)
library(biomaRt)
BiocManager::install("biomaRt")
install.packages("BiocManager")
BiocManager::install("biomaRt")
BiocManager::install("biomaRt")
warnings()
q()
q()
c(sum(results.all$NRMSE$DMTL >= 1), sum(results.all$NMAE$DMTL >= 1), sum(abs(results.all$SCC$DMTL) <= 0.2))
## Set-up system path...
PATH <- if (Sys.getenv("USERNAME") == "SRDhruba") {
"\\Users\\SRDhruba\\Dropbox (Personal)\\ResearchWork\\Rtest\\"
} else {
sprintf("%s\\Dropbox\\ResearchWork\\Rtest\\", Sys.getenv("HOMEPATH"))
}
setwd(PATH); cat("Current system path = ", getwd(), "\n")
## Packages...
library(progress)
#### Functions...
printf <- function(..., end = "\n") {
if ((nargs() > 1) & (grepl(list(...)[1], pattern = "%")))
cat(sprintf(...), end)
else
cat(..., end)
}
norm01 <- function(z) { z <- if (min(z)) z - min(z) else z; z <- z / max(z); z }
norm.data <- function(df) as.data.frame(apply(df, MARGIN = 2, norm01))
### Pick top genes...
get.top.genes <- function(ranks, m.top = 150, verbose = FALSE) {
## Initialization...
nI <- 0; nGN <- 300
gene.rank <- intersect(ranks[1:nGN, 1], ranks[1:nGN, 2])
m <- length(gene.rank); m0 <- if (verbose) m
## Run iterations...
while(m < m.top) {
nI <- nI + 1; nGN <- nGN + 100
gene.rank <- intersect(ranks[1:nGN, 1], ranks[1:nGN, 2])
m <- length(gene.rank)
}
gene.rank <- sort(gene.rank, decreasing = FALSE) # Sort ranks
## Print results...
if (verbose)
printf("#top genes chosen = %d (nGN = %d, nI = %d, m0 = %d)", m, nGN, nI, m0)
gene.rank
}
### Get model performance...
calc.perf <- function(y, y.pred, measures = c("NRMSE", "NMAE", "SCC")) {
## Initialize results array...
perf.vals <- c("sq.err" = NA, "abs.err" = NA, "cor.coef" = NA)
for (mes in measures) {
## Calculate squared error...
if (grepl(pattern = "MSE", mes, ignore.case = TRUE)) {
num <- mean((y - y.pred)^2)
den <- if (mes == "NRMSE") mean((y - mean(y))^2) else 1
pow <- if (mes == "MSE") 1 else 0.5
perf.vals["sq.err"] <- (num / den)^pow
}
## Calculate absolute error...
else if (grepl(pattern = "MAE", mes, ignore.case = TRUE)) {
num <- mean(abs(y - y.pred))
den <- if (mes == "NMAE") mean(abs(y - mean(y))) else 1
perf.vals["abs.err"] <- num / den
}
## Calculate similarity measures...
else if (grepl(pattern = "CC", mes, ignore.case = TRUE)) {
alg <- if (mes == "SCC") "spearman" else "pearson"
perf.vals["cor.coef"] <- cor(y, y.pred, method = alg)
}
## Doesn't match any...
else
stop("Invalid performance measure! Please use common variants of MSE, MAE or CC (correlation coefficient).")
}
perf.vals
}
#### Read tumor-cell line data...
Xdata1 <- read.table("Data/LUAD_gene_expression_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
Xdata2 <- read.table("Data/LUSC_gene_expression_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
Xdata3 <- read.table("Data/NSCLC_gene_expression_CCLE_06_Dec_2020.txt", sep = "\t", header = TRUE)
Xdata4 <- read.table("Data/NSCLC_gene_expression_GDSC_06_Dec_2020.txt", sep = "\t", header = TRUE)
Ydata1 <- read.table("Data/LUAD_biomarker_expression_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
Ydata2 <- read.table("Data/LUSC_biomarker_expression_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
Ydata3 <- read.table("Data/NSCLC_biomarker_expression_CCLE_06_Dec_2020.txt", sep = "\t", header = TRUE)
Ydata4 <- read.table("Data/NSCLC_biomarker_expression_GDSC_06_Dec_2020.txt", sep = "\t", header = TRUE)
rank1 <- read.table("Data/LUAD_biomarker_ranks_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
rank2 <- read.table("Data/LUSC_biomarker_ranks_TCGA_06_Dec_2020.txt", sep = "\t", header = TRUE)
rank3 <- read.table("Data/NSCLC_biomarker_ranks_CCLE_06_Dec_2020.txt", sep = "\t", header = TRUE)
rank4 <- read.table("Data/NSCLC_biomarker_ranks_GDSC_06_Dec_2020.txt", sep = "\t", header = TRUE)
biomarkers <- colnames(Ydata1); q <- length(biomarkers)
run <- function(q.run, n.feat, random.seed, method.opt) {
# q.run <- 1 # drug idx
# random.seed <- 4321 # 0, 654321, 4321
# method.opt <- "dens" # hist, dens
## Save performance measures...
perf.mes <- c("NRMSE", "NMAE", "SCC")
results.all <- list(data.frame("DMTL" = double(), "DMTL_SS" = double(), "BL" = double()),
data.frame("DMTL" = double(), "DMTL_SS" = double(), "BL" = double()),
"genes" = data.frame("num.genes" = double()))
names(results.all)[1:3] <- perf.mes
pb <- progress_bar$new(format = " running [:bar] :percent eta: :eta", total = length(q.run), clear = FALSE, width = 64)
pb$tick(0)
for (k in q.run) {
pb$tick()
## Select biomarker...
bmChosen <- biomarkers[k]; #printf("\nChosen biomarker = %s", bmChosen)
ranks <- cbind(rank1[, bmChosen], rank2[, bmChosen], rank3[, bmChosen], rank4[, bmChosen])
gnRank <- get.top.genes(ranks[, 3:4], m.top = n.feat, verbose = FALSE); m <- length(gnRank)
## Prepare datasets...
X1 <- rbind(Xdata1[, gnRank], Xdata2[, gnRank]); X2 <- rbind(Xdata3[, gnRank], Xdata4[, gnRank])
Y1 <- norm01(c(Ydata1[, bmChosen], Ydata2[, bmChosen])); Y2 <- norm01(c(Ydata3[, bmChosen], Ydata4[, bmChosen]))
## DMTL model...
prediction <- DMTL(target_set = list("X" = X1, "y" = Y1), source_set = list("X" = X2, "y" = Y2),
method = method.opt, seed = random.seed, pred_all = TRUE)
Y1.pred <- prediction$mapped; Y1.pred.src <- prediction$unmapped
## Baseline model...
source("RF_predict.R") # Random forest modeling
Y1.pred.base <- RF_predict(x_train = norm.data(X2), y_train = Y2, x_test = norm.data(X1),
n_tree = 200, m_try = 0.4, random_seed = random.seed)
## Generate & save results...
results <- data.frame("DMTL" = calc.perf(Y1, Y1.pred, measures = perf.mes),
"DMTL_SS" = calc.perf(Y1, Y1.pred.src, measures = perf.mes),
"BL" = calc.perf(Y1, Y1.pred.base, measures = perf.mes), row.names = perf.mes)
## Print option...
if (length(q.run) == 1) { printf("\nResults for %s using top %d features = ", bmChosen, n.feat); print(results) }
results.all[[perf.mes[1]]][bmChosen, ] <- results[perf.mes[1], ]
results.all[[perf.mes[2]]][bmChosen, ] <- results[perf.mes[2], ]
results.all[[perf.mes[3]]][bmChosen, ] <- results[perf.mes[3], ]
results.all$genes[bmChosen, ] <- m
}
## Calculate mean performance...
results.all[[perf.mes[1]]]["Mean", ] <- colMeans(results.all[[perf.mes[1]]][biomarkers, ], na.rm = TRUE)
results.all[[perf.mes[2]]]["Mean", ] <- colMeans(results.all[[perf.mes[2]]][biomarkers, ], na.rm = TRUE)
results.all[[perf.mes[3]]]["Mean", ] <- colMeans(results.all[[perf.mes[3]]][biomarkers, ], na.rm = TRUE)
results.all$genes["Mean", ] <- mean(results.all$genes[biomarkers, ], na.rm = TRUE)
results.all[["table"]] <- rbind(results.all[[perf.mes[1]]]["Mean", ], results.all[[perf.mes[2]]]["Mean", ],
results.all[[perf.mes[3]]]["Mean", ])
rownames(results.all$table) <- perf.mes
## Print options...
if (length(q.run) > 1) { printf("\nResults summary for top %d features = ", n.feat); print(results.all$table) }
results.all
}
source("dist_match_trans_learn.R") ## Load function
results.all <- run(q.run = 1:q, n.feat = 50, random.seed = 97531, method.opt = "hist")