-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 21.9 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
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RNA-Seq vs RPPA"
cor_df <- rbind(cor_df, cor_gene_res)
# rnaseq viper
genes <- rownames(rnaseq)
cor_res <- lapply(1:length(genes), function(k){
fit <- cor.test(as.numeric(rnaseq[rownames(rnaseq) == genes[k], ]),
as.numeric(viper[rownames(viper) == genes[k], ]),
method = "pearson",
exact = FALSE)
################################ comment: add p-value here ############################
data.frame(feature = genes[k],
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RNA-Seq vs VIPER"
cor_df <- rbind(cor_df, cor_gene_res)
# rppa viper
genes <- rownames(rppa)
cor_res <- lapply(1:length(genes), function(k){
fit <- cor.test(as.numeric(rppa[rownames(rppa) == genes[k], ]),
as.numeric(viper[rownames(viper) == genes[k], ]),
method = "pearson",
exact = FALSE)
################################ comment: add p-value here ############################
data.frame(feature = genes[k],
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RPPA vs VIPER"
cor_df <- rbind(cor_df, cor_gene_res)
p_meds <- ddply(cor_df, .(type), summarise, med = round(median(cor_val), digits = 4))
cor_df$type <- factor(cor_df$type , levels=c("RNA-Seq vs VIPER", "RNA-Seq vs RPPA", "RPPA vs VIPER"))
p <- ggplot(cor_df, aes(x = type, y = cor_val, fill = type)) +
geom_boxplot(color = "black", width = 0.5) +
labs(x = "Data", y = "Pearson Correlation Value") +
theme(axis.text.x = element_text(size = 8), legend.position = "none") +
geom_text(data = p_meds, aes(x = type, y = med, label = med),
size = 3, vjust = -1)
return(p)
}
options(timeout = 200)
# ccle and gcsi rnaseq -> gencode v33
gencode_basic <- getGencodeFile(file = "gencode.\\{v}\\.basic.annotation.gtf.gz", version = "33")
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=TRUE)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("BiocStyle")
library(BiocStyle)
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=TRUE)
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=FALSE)
library(AnnotationGx)
options(timeout = 200)
# ccle and gcsi rnaseq -> gencode v33
gencode_basic <- getGencodeFile(file = "gencode.\\{v}\\.basic.annotation.gtf.gz", version = "33")
load("C:/DrugVIPER/Data/Gencode.v33.annotation.RData")
ls()
rm(list=ls())
load("C:/DrugVIPER/Data/Gencode.v33.annotation.RData")
ls()
gencode_entrez <- getGencodeFile(file = "gencode\\.{v}\\.metadata.EntrezGene.gz", version = "33")
# ccle and gcsi rnaseq -> gencode v33
gencode_basic <- getGencodeFile(file = "gencode.\\{v}\\.basic.annotation.gtf.gz", version = "33")
rm(list=ls())
g
# ccle and gcsi rnaseq -> gencode v33
gencode_basic <- getGencodeFile(file = "gencode.\\{v}\\.basic.annotation.gtf.gz", version = "33")
gencode_entrez <- getGencodeFile(file = "gencode\\.{v}\\.metadata.EntrezGene.gz", version = "33")
colnames(gencode_entrez) <- c("transcript_id", "entrez_id")
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by = join_by("transcript_id"))
library(join_by)
library(dplyr)
join_by
left_join
head(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")])
head(gencode_entrez)
join_by("transcript_id")
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by = join_by("transcript_id"))
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by = join_by("transcript_id"))
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by =join_by("transcript_id"))
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by ="transcript_id")
head(gene_entrez)
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez, by =join_by("transcript_id"))
# map gencode_entrez to gene_id (include gene_name for naming later)
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez) # , by=join_by("transcript_id")
head(gene_entrez)
table(gene_entrez$entrez_id)
gene_entrez <- na.omit(distinct(gene_entrez[, c("gene_name", "gene_id", "entrez_id")]))
head(gene_entrez)
# add entrez ids
ccle_rnaseq_mapped <- map_entrez(ccle_rnaseq_gene_annot, ccle_rnaseq_exp, gene_entrez)
map_entrez <- function(gene_annot, exp, gene_entrez) {
# add row numbers to retain order later
gene_annot$id <- seq.int(nrow(gene_annot))
# add entrez
gene_annot_entrez <- left_join(as.data.frame(gene_annot), gene_entrez[ , c("gene_id", "entrez_id")], by = join_by("gene_id"))
# remove rows with NA for entrez
gene_annot_entrez <- gene_annot_entrez[!is.na(gene_annot_entrez$entrez_id), ]
# matching assays for rows with entrez id
exp_entrez <- exp[gene_annot_entrez$id, ]
# make entrez id the rownames
row.names(exp_entrez) <- gene_annot_entrez$entrez_id
return (list(gene_annot_entrez, exp_entrez))
}
############################################################
## Computing viper scores (pan-cancer)
############################################################
corr_pancancer <- function(viper_pancancer, exp_entrez, label) {
# get matching cell_lines and genes
matching_cell_lines <- intersect(colnames(viper_pancancer), colnames(exp_entrez))
matching_genes <- intersect(row.names(viper_pancancer), row.names(exp_entrez))
viper_exp <- viper_pancancer[matching_genes, matching_cell_lines]
exp <- exp_entrez[matching_genes, matching_cell_lines]
# scaling
viper_exp <- t(scale(t(viper_exp)))
exp <- t(scale(t(exp)))
to_keep <- as.vector(which(rowSums(!is.na(exp)) >= 20 & rowSums(!is.na(viper_exp)) >= 20))
viper_exp <- viper_exp[to_keep, ]
exp <- exp[to_keep, ]
genes <- rownames(viper_exp)
cor_res <- lapply(1:length(genes), function(k){
tryCatch({
fit <- cor.test(as.numeric(viper_exp[rownames(viper_exp) == genes[k], ]),
as.numeric(exp[rownames(exp) == genes[k], ]),
method = "pearson")
data.frame(feature = genes[k],
cor_val = fit$estimate,
################# comment: keep p-value ##########################
pval = fit$p.value
)
}, error = function(e) {
# don't add to cor_res
}
)
})
cor_gene_res <- do.call(rbind, cor_res)
cor_gene_res <- na.omit(cor_gene_res)
################# comment: do adjustment for multiple test ##########################
cor_gene_res$padj = p.adjust(cor_gene_res$pval, "fdr")
med <- round(median(cor_gene_res$cor_val), digits = 6)
# boxplot
ggplot(data = cor_gene_res,aes(y=cor_val)) +
geom_boxplot() +
labs(title=label, x="", y = "Pearson correlation") +
annotate("text", x=Inf, y=Inf, label=paste("median correlation = ", med), angle=0, size=4, color="blue", vjust = 2, hjust = 1.1) +
theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
}
cor_all_data <- function(rnaseq, rppa, viper) {
# scale all
rnaseq <- t(scale(t(rnaseq)))
rppa <- t(scale(t(rppa)))
viper <- t(scale(t(viper)))
cor_df <- data.frame(feature = character(),
cor_val = numeric(),
pval = numeric(),
type = character())
# rnaseq rppa
genes <- rownames(rnaseq)
cor_res <- lapply(1:length(genes), function(k){
fit <- cor.test(as.numeric(rnaseq[rownames(rnaseq) == genes[k], ]),
as.numeric(rppa[rownames(rppa) == genes[k], ]),
method = "pearson",
exact = FALSE)
################################ comment: add p-value here ############################
data.frame(feature = genes[k],
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RNA-Seq vs RPPA"
cor_df <- rbind(cor_df, cor_gene_res)
# rnaseq viper
genes <- rownames(rnaseq)
cor_res <- lapply(1:length(genes), function(k){
fit <- cor.test(as.numeric(rnaseq[rownames(rnaseq) == genes[k], ]),
as.numeric(viper[rownames(viper) == genes[k], ]),
method = "pearson",
exact = FALSE)
################################ comment: add p-value here ############################
data.frame(feature = genes[k],
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RNA-Seq vs VIPER"
cor_df <- rbind(cor_df, cor_gene_res)
# rppa viper
genes <- rownames(rppa)
cor_res <- lapply(1:length(genes), function(k){
fit <- cor.test(as.numeric(rppa[rownames(rppa) == genes[k], ]),
as.numeric(viper[rownames(viper) == genes[k], ]),
method = "pearson",
exact = FALSE)
################################ comment: add p-value here ############################
data.frame(feature = genes[k],
cor_val = fit$estimate,
pval = fit$p.value
)
})
cor_gene_res <- do.call(rbind, cor_res)
#################### comment: compute adjusted p-value ##########################
cor_gene_res$padj <- p.adjust(cor_gene_res$pval, "fdr")
cor_gene_res$type <- "RPPA vs VIPER"
cor_df <- rbind(cor_df, cor_gene_res)
p_meds <- ddply(cor_df, .(type), summarise, med = round(median(cor_val), digits = 4))
cor_df$type <- factor(cor_df$type , levels=c("RNA-Seq vs VIPER", "RNA-Seq vs RPPA", "RPPA vs VIPER"))
p <- ggplot(cor_df, aes(x = type, y = cor_val, fill = type)) +
geom_boxplot(color = "black", width = 0.5) +
labs(x = "Data", y = "Pearson Correlation Value") +
theme(axis.text.x = element_text(size = 8), legend.position = "none") +
geom_text(data = p_meds, aes(x = type, y = med, label = med),
size = 3, vjust = -1)
return(p)
}
args(map_entrez)
gene_annot <- ccle_rnaseq_gene_annot
load(file = "C:/DrugVIPER/Data/Analysis_Tasks_data.rda")
gene_annot <- ccle_rnaseq_gene_annot
exp <- ccle_rnaseq_exp
gene_entrez <- gene_entrez
# add row numbers to retain order later
gene_annot$id <- seq.int(nrow(gene_annot))
head(gene_annot)
# add entrez
gene_annot_entrez <- left_join(as.data.frame(gene_annot), gene_entrez[ , c("gene_id", "entrez_id")], by = join_by("gene_id"))
# add entrez by = join_by("gene_id")
gene_annot_entrez <- left_join(as.data.frame(gene_annot), gene_entrez[ , c("gene_id", "entrez_id")])
head(gene_annot_entrez)
# remove rows with NA for entrez
gene_annot_entrez <- gene_annot_entrez[!is.na(gene_annot_entrez$entrez_id), ]
# matching assays for rows with entrez id
exp_entrez <- exp[gene_annot_entrez$id, ]
# make entrez id the rownames
row.names(exp_entrez) <- gene_annot_entrez$entrez_id
return (list(gene_annot_entrez, exp_entrez))
map_entrez <- function(gene_annot, exp, gene_entrez) {
# add row numbers to retain order later
gene_annot$id <- seq.int(nrow(gene_annot))
# add entrez by = join_by("gene_id")
gene_annot_entrez <- left_join(as.data.frame(gene_annot), gene_entrez[ , c("gene_id", "entrez_id")])
# remove rows with NA for entrez
gene_annot_entrez <- gene_annot_entrez[!is.na(gene_annot_entrez$entrez_id), ]
# matching assays for rows with entrez id
exp_entrez <- exp[gene_annot_entrez$id, ]
# make entrez id the rownames
row.names(exp_entrez) <- gene_annot_entrez$entrez_id
return (list(gene_annot_entrez, exp_entrez))
}
####################### comment: error by using by = join_by("transcript_id") #################################
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez) # , by=join_by("transcript_id")
gene_entrez <- na.omit(distinct(gene_entrez[, c("gene_name", "gene_id", "entrez_id")]))
# add entrez ids
ccle_rnaseq_mapped <- map_entrez(ccle_rnaseq_gene_annot, ccle_rnaseq_exp, gene_entrez)
ccle_rnaseq_gene_annot_entrez <- ccle_rnaseq_mapped[[1]] # gene_annot
ccle_rnaseq_exp_entrez <- ccle_rnaseq_mapped[[2]] # exp
gcsi_rnaseq_mapped <- map_entrez(gcsi_rnaseq_gene_annot, gcsi_rnaseq_exp, gene_entrez)
gcsi_rnaseq_gene_annot_entrez <- gcsi_rnaseq_mapped[[1]] # gene_annot
gcsi_rnaseq_exp_entrez <- gcsi_rnaseq_mapped[[2]] # exp
# map gencode_entrez to gene_id (include gene_name for naming later)
################### comment: , by = join_by("transcript_id")
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez)
gene_entrez <- na.omit(distinct(gene_entrez[, c("gene_name", "gene_id", "entrez_id")]))
# add entrez ids
ccle_rppa_mapped <- map_entrez(ccle_rppa_gene_annot, ccle_rppa_exp, gene_entrez)
ccle_rppa_gene_annot_entrez <- ccle_rppa_mapped[[1]] # gene_annot
ccle_rppa_exp_entrez <- ccle_rppa_mapped[[2]] # exp
# aggregate ccle rppa by row names (take median)
ccle_rppa_exp_entrez <- aggregate(ccle_rppa_exp_entrez, list(row.names(ccle_rppa_exp_entrez)), median, na.rm = TRUE)
row.names(ccle_rppa_exp_entrez) <- ccle_rppa_exp_entrez$Group.1
ccle_rppa_exp_entrez <- ccle_rppa_exp_entrez[, -1]
# map gencode_entrez to gene_id (include gene_name for naming later)
################################### comment , by = join_by("transcript_id")
gene_entrez <- left_join(as.data.frame(gencode_basic)[, c("gene_name", "gene_id", "transcript_id")], gencode_entrez)
gene_entrez <- na.omit(distinct(gene_entrez[, c("gene_name", "gene_id", "entrez_id")]))
# add entrez ids
mclp_rppa_mapped <- map_entrez(mclp_rppa_gene_annot, mclp_rppa_exp, gene_entrez)
mclp_rppa_gene_annot_entrez <- mclp_rppa_mapped[[1]] # gene_annot
mclp_rppa_exp_entrez <- mclp_rppa_mapped[[2]] # exp
# Will replace using hgnc_complete_set.txt
# hgnc annotations
hgnc.complete.set <- read.delim("C:/DrugVIPER/Data/hgnc_complete_set.txt")
sub.hgnc.complete.set <- hgnc.complete.set[!is.na(hgnc.complete.set$entrez_id), ]
# ccle rnaseq
# ensembl to entrez id
ensembl_entrez_gene_id <- sapply(1:nrow(ccle_rnaseq_gene_annot), function(k){
# splitting to remove version number
hgnc.complete.set[hgnc.complete.set$ensembl_gene_id == unlist(strsplit(ccle_rnaseq_gene_annot$gene_id[k], ".", fixed = TRUE))[1], "entrez_id"]
})
# ccle rnaseq
# ensembl to entrez id
ensembl_entrez_gene_id <- sapply(1:nrow(ccle_rnaseq_gene_annot), function(k){
# splitting to remove version number
hgnc.complete.set[hgnc.complete.set$ensembl_gene_id == unlist(strsplit(ccle_rnaseq_gene_annot$gene_id[k], ".", fixed = TRUE))[1], "entrez_id"]
})
rownames(ccle_rnaseq_exp) <- as.numeric(ensembl_entrez_gene_id)
# ccle rppa - some ensembl_gene_ids are missing
ensembl_entrez_gene_id <- sapply(1:nrow(ccle_rppa_gene_annot), function(k){
if (ccle_rppa_gene_annot$gene_id[k] == "") {
# ensembl id missing in gene annotations, will use symbol to match
hgnc.complete.set[hgnc.complete.set$symbol == ccle_rppa_gene_annot$Target_Genes[k], "entrez_id"]
} else {
hgnc.complete.set[hgnc.complete.set$ensembl_gene_id == unlist(strsplit(ccle_rppa_gene_annot$gene_id[k], ".", fixed = TRUE))[1], "entrez_id"]
}
})
rownames(ccle_rppa_exp) <- as.numeric(ensembl_entrez_gene_id)
# mclp rppa
ensembl_entrez_gene_id <- sapply(1:nrow(mclp_rppa_gene_annot), function(k){
hgnc.complete.set[hgnc.complete.set$ensembl_gene_id == unlist(strsplit(mclp_rppa_gene_annot$gene_id[k], ".", fixed = TRUE))[1], "entrez_id"]
})
rownames(mclp_rppa_exp) <- as.numeric(ensembl_entrez_gene_id)
# list of available regulons from aracne.networks
available_regulons <- data(package="aracne.networks")$results[, "Item"] # regulons in aracne.networks
all_regulons <- lapply(available_regulons, base::get)
all_regulons
dim(ccle_rnaseq_exp)
ccle_rnaseq_exp[1:3,1:4]
dim(gcsi_rnaseq_exp)
ccle_viper_scores <- viper(ccle_rnaseq_exp, all_regulons, verbose = FALSE)
ccle_viper_scores <- viper(ccle_rnaseq_exp, all_regulons, verbose = FALSE)
ccle_viper_scores <- viper(ccle_rnaseq_exp, all_regulons, verbose = FALSE)
ls()
rm(list=ls())
library(ggplot2)
library(tidyverse)
library(dplyr)
library(SummarizedExperiment)
library(miscTools)
library(corrplot)
library(reshape2)
library(ggvenn)
library(PharmacoGx)
library(gridExtra)
library(AnnotationGx)
knitr::opts_chunk$set(echo = TRUE)
rem <- function(x){
x <- as.matrix(x)
x <- t(apply(x,1,as.numeric))
# data is log2(TPM+0.001)
r <- as.numeric(apply(x, 1, function(i) sum(round(i, 6) == round(log2(0.001), 6)) ))
remove <- which(r > dim(x)[2]*0.5) # should be 0.5 or less or more for our data?
return(remove)
}
CCLE_RPPA_SE <- readRDS("C:/DrugVIPER/results/CCLE_RPPA_SE.rds")
CCLE_RNAseq_SE <- readRDS("C:/DrugVIPER/Data/CCLE_RNAseq.rds")
MCLP_RPPA_SE <- readRDS("C:/DrugVIPER/results/MCLP_RPPA_SE.rds")
gCSI_RNAseq_SE <- readRDS("C:/DrugVIPER/Data/gCSI_RNAseq.rds")
# Note: replacing CCLE_RNAseq_SE and gCSI_RNAseq_SE with local downloads (downloading timeouts)
#CCLE <- downloadPSet("CCLE_2015")
#gCSI <- downloadPSet("gCSI_2019")
CCLE_RNAseq_SE <- summarizeMolecularProfiles(CCLE, mDataType="Kallisto_0.46.1.rnaseq", fill.missing = FALSE)
CCLE <- readRDS("C:/DrugVIPER/Data/CCLE_RNAseq.rds")
gCSI <- readRDS("C:/DrugVIPER/Data/gCSI_RNAseq.rds")
# Note: replacing CCLE_RNAseq_SE and gCSI_RNAseq_SE with local downloads (downloading timeouts)
#CCLE <- downloadPSet("CCLE_2015")
#gCSI <- downloadPSet("gCSI_2019")
CCLE_RNAseq_SE <- summarizeMolecularProfiles(CCLE, mDataType="Kallisto_0.46.1.rnaseq", fill.missing = FALSE)
library(PharmacoGx)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("PharmacoGx")
library(PharmacoGx)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("CoreGx")
library(CoreGx)
install.packages("htmltools")
library(htmltools)
library(CoreGx)
install.packages("rlang")
install.packages("rlang")
library(rlang)
library(CoreGx)
library(CoreGx)
install.packages("rlang")
library(rlang)
library(CoreGx)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("CoreGx")
library(CoreGx)
library(PharmacoGx)
library(ggplot2)
library(tidyverse)
library(dplyr)
library(SummarizedExperiment)
library(miscTools)
library(corrplot)
library(reshape2)
library(ggvenn)
library(PharmacoGx)
library(gridExtra)
knitr::opts_chunk$set(echo = TRUE)
library(AnnotationGx)
install.packages("cli")
install.packages("cli")
library(AnnotationGx)
library(cli)
library(AnnotationGx)
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=TRUE)
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=TRUE, force = TRUE)
library(AnnotationGx)
remotes::install_github("bhklab/AnnotationGx", build_manual=TRUE, build_vignettes=TRUE)
remotes::install_github("bhklab/AnnotationGx@development", build_manual=TRUE, build_vignettes=TRUE)
library(PharmacoGx)
knitr::opts_chunk$set(echo = TRUE)
rem <- function(x){
x <- as.matrix(x)
x <- t(apply(x,1,as.numeric))
# data is log2(TPM+0.001)
r <- as.numeric(apply(x, 1, function(i) sum(round(i, 6) == round(log2(0.001), 6)) ))
remove <- which(r > dim(x)[2]*0.5) # should be 0.5 or less or more for our data?
return(remove)
}
install_github("DeveloperName/PackageName")
library(devtools)
install_github("DeveloperName/PackageName")
install_github("bhklab/PredictioR")
devtools::install_github("bhklab/PredictioR")
rm(list=ls())
library(devtools)
library(roxygen2)
library(testthat)
library(usethis)
getwd()
devtools::create("PredictioR")
devtools::create("C:/ImmuneData/PredictioR")
devtools::create("C:/ImmuneData")
x <- c(1:10)
devtools::use_data(x)
getwd()
library(devtools)
library(roxygen2)
devtools::document()
devtools::document("C:/SignatureSets")
devtools::document("C:/SignatureSets/ADO")
roxygen2::roxygenise("C:/SignatureSets")
usethis::use_package_doc()
getwd("C:/SignatureSets")
setwd("C:/SignatureSets")
usethis::use_package_doc()
?roxygen2
roxygen2::roxygenise("ADO")
roxygen2::roxygenise()
rlang::last_trace()
roxygen2::roxygenise()
roxygen2::roxygenise("ADO")
getwd()
usethis::use_vignette()
usethis::use_vignette("SignatureSets")
app_dir <- str_split(rstudioapi::getActiveDocumentContext()$path,'SignatureSets')[[1]][1]
library(stringr)
app_dir <- str_split(rstudioapi::getActiveDocumentContext()$path,'SignatureSets')[[1]][1]
dir_GeneSig <- file.path(app_dir, 'SignatureSets', 'data')
dir_GeneSig_info <- file.path(app_dir, 'SignatureSets', 'data-raw')
signature <- read.csv( file.path(dir_GeneSig_info, "signature_INFO.csv"))
signature$Signature <- as.character( signature$Signature )
signature$method <- as.character( signature$method )
i<- which(signature$Signature == "APM_Thompson")
load(file.path(dir_GeneSig, "APM_Thompson.rda"))
sig
knitr::kable(sig, format="html",
table.attr = "style='width:30%;'", row.names = FALSE) %>% kableExtra::kable_styling()
i<- which(signature$Signature == "T_cell_exclusion")
load(file.path(dir_GeneSig, "T_cell_exclusion.rda"))
sig
signature
i<-10
i<- which(signature$Signature == "APM_Thompson")
load(file.path(dir_GeneSig, "APM_Thompson.rda"))
i<- which(signature$Signature == "COX_IS")
load(file.path(dir_GeneSig, "COX_IS.rda"))
knitr::kable(sig, format="html",
table.attr = "style='width:30%;'", row.names = FALSE) %>% kableExtra::kable_styling()
i<- which(signature$Signature == "APM_Thompson")
load(file.path(dir_GeneSig, "APM_Thompson.rda"))
knitr::kable(sig, format="html",
table.attr = "style='width:30%;'", row.names = FALSE) %>% kableExtra::kable_styling()
file.path(dir_GeneSig_info, "clustering_signatures.JPG")
knitr::include_graphics(file.path(dir_GeneSig_info, "clustering_signatures.JPG"))
i<- which(signature$Signature == "APM_Thompson")
load(file.path(dir_GeneSig, "APM_Thompson.rda"))
sig
class(sig)
load(file.path(dir_GeneSig, "APM_Thompson.rda"))
sig
knitr::kable(sig, format="html", row.names = FALSE) %>% kableExtra::kable_styling()