-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
512 lines (512 loc) · 22.6 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
intersect(MVM_DEGs$U,VSV_DEGs$D)
MVM_resist <- union(MVM_DEGs$U,VSV_DEGs$D)
MVM_resist <- intersect(MVM_DEGs$U,VSV_DEGs$D)
debugSource('~/Desktop/FDA meeting/MVM_susceptible.R')
debugSource('~/Desktop/FDA meeting/MVM_susceptible.R')
RNA_resist <- intersect(VSV_DEGs$D,EMCV_DEGs$D)
log2(1.5)
log2(-1.5)
log2(0.5)
load('~/Desktop/16_FDA_virus/BatchEffect_Results/MVM_DEG.rda')
rm(list=ls())
load('~/Desktop/16_FDA_virus/BatchEffect_Results/VSV_DEG.rda')
rm(list=ls())
load('~/Desktop/16_FDA_virus/BatchEffect_Results/VSV_DEG.rda')
VSV_DEG <- DEG_IDs$DEseq2_7_mouse
load('~/Desktop/16_FDA_virus/BatchEffect_Results/EMCV_DEG.rda')
EMCV_DEG <- DEG_IDs$DEseq2_7_mouse
load('~/Desktop/16_FDA_virus/BatchEffect_Results/REO_DEG.rda')
REO_DEG <- DEG_IDs$DEseq2_7_mouse
load('~/Desktop/16_FDA_virus/BatchEffect_Results/MVM_DEG.rda')
MVM_DEG <- DEG_IDs$DEseq2_7_mouse
debugSource('~/Desktop/FDA meeting/MVM_susceptible.R')
RNA_resist <- intersect(VSV_DEGs$D,EMCV_DEGs$D)
RNA_resist <- intersect(RNA_resist,REO_DEGs$D)
source('~/Desktop/FDA meeting/MVM_susceptible.R')
source('~/Desktop/FDA meeting/MVM_susceptible.R')
source('~/Desktop/FDA meeting/MVM_susceptible.R')
load('~/Desktop/16_FDA_virus/BatchEffect_Results/FDA_DEG.rda')
load('~/Desktop/16_FDA_virus/BatchEffect_Results/FDA_DEG.rda')
load('~/Desktop/16_FDA_virus/BatchEffect_Results/FDA_DE.rda')
rm(list=ls())
load('~/Desktop/16_FDA_virus/BatchEffect_Results/FDA_DE.rda')
WriteXLS(DiffExp,'~/Desktop/FDA_DE.xlsx')
library(WriteXLS)
WriteXLS(DiffExp,'~/Desktop/FDA_DE.xlsx')
?WriteXLS
WriteXLS(DiffExp,'~/Desktop/FDA_DE.xls')
FDA_DE <- DiffExp
FDA_DE$VSV <- as.data.frame(FDA_DE$VSV)
FDA_DE$EMCV <- as.data.frame(FDA_DE$EMCV)
FDA_DE$REO <- as.data.frame(FDA_DE$REO)
FDA_DE$MVM <- as.data.frame(FDA_DE$MVM)
F_vsv <- FDA_DE$VSV
View(F_vsv)
FDA_DE <- list()
FDA_DE$VSV_FC <- as.data.frame(DiffExp$VSV$FoldChange)
FDA_DE$EMCV_FC <- as.data.frame(DiffExp$EMCV$FoldChange)
FDA_DE$REO_FC <- as.data.frame(DiffExp$REO$FoldChange)
FDA_DE$MVM_FC <- as.data.frame(DiffExp$MVM$FoldChange)
FDA_DE$VSV_P <- as.data.frame(DiffExp$VSV$Sigp)
FDA_DE$EMCV_P <- as.data.frame(DiffExp$EMCV$Sigp)
FDA_DE$REO_P <- as.data.frame(DiffExp$REO$Sigp)
FDA_DE$MVM_P <- as.data.frame(DiffExp$MVM$Sigp)
F_vsv <- FDA_DE$VSV_FC
F_vsv <- FDA_DE$VSV_P
WriteXLS(FDA_DE,'~/Desktop/FDA_DE.xls')
WriteXLS(FDA_DE,'~/Desktop/FDA_DE.xlsx')
WriteXLS(FDA_DE,'~/Desktop/FDA_DE.xlsx', row.names = TRUE, col.names = TRUE)
q()
q()
q()
-log10(0.05)
install.packages("clValid")
library(clValid)
data(mouse)
express <- mouse[1:25,c("M1","M2","M3","NC1","NC2","NC3")]
rownames(express) <- mouse$ID[1:25]
intern <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="internal")
summary(intern)
optimalScores(intern)
plot(intern)
stab <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="stability")
optimalScores(stab)
plot(stab)
fc <- fc[-match( c("EST","Unknown"), names(fc))]
bio <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="biological", annotation=fc)
optimalScores(bio)
plot(bio)
fc <- tapply(rownames(express),mouse$FC[1:25], c)
fc <- fc[-match( c("EST","Unknown"), names(fc))]
bio <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="biological", annotation=fc)
optimalScores(bio)
plot(bio)
if(require("Biobase") && require("annotate") && require("GO.db") && require("moe430a.db")) {
bio2 <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="biological",annotation="moe430a.db",GOcategory="all")
optimalScores(bio2)
plot(bio2)
}
if(require("Biobase") && require("annotate") && require("GO.db") && require("moe430a.db")) {
bio2 <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="biological",annotation="moe430a.db",GOcategory="all")
optimalScores(bio2)
plot(bio2)
}
plot(bio2)
bio2 <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="biological",annotation="moe430a.db",GOcategory="all")
plot(bio2)
?clValid
summary(intern)
rownames(express) <- mouse$ID[1:25]
intern <- clValid(express, 2:6, clMethods=c("hierarchical","kmeans","pam"),
validation="internal")
intern@measures
intern@measNames
intern@clMethods
intern@metric
intern@call
View(express)
intern@nClust
intern@clusterObjs
ff <- clValid(express, nClust, clMethods = "hierarchical", validation =
"stability", maxitems = 600, metric = "euclidean", method = "average",
neighbSize = 10, annotation = NULL, GOcategory = "all",
goTermFreq=0.05, dropEvidence=NULL, verbose=FALSE, ...)
ff <- clValid(express, nClust, clMethods = "hierarchical", validation =
"stability", maxitems = 600, metric = "euclidean", method = "average",
neighbSize = 10, annotation = NULL, GOcategory = "all",
goTermFreq=0.05, dropEvidence=NULL, verbose=FALSE)
ff <- clValid(express, 2:6, clMethods = "hierarchical", validation =
"stability", maxitems = 600, metric = "euclidean", method = "average",
neighbSize = 10, annotation = NULL, GOcategory = "all",
goTermFreq=0.05, dropEvidence=NULL, verbose=FALSE)
summary(ff)
log10(0.05)
install.packages("devtools")
library(devtools)
install_github("bkellman/RegressionModelPipeline")
install_github("bkellman/RegressionModelPipeline")
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
library(RegressionModelPipeline)
setwd("~/GitHub/RegressionModelPipeline/")
iris_test<-function(){
print(str(iris))
}
mtcars_tests <- function(){
# source('~/Desktop/modeling_functions.r')
K=5
inter=NULL
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm)
out=vis(mod)
out[[1]]
out[[2]]
dev.off()
sig_vars_thresh = list(model_sel_interaction=6,model_sel_additive=7,glmnet_interaction=200,glmnet_additive=2000) # see regularization output (lower upper bound for additive model selection)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm,sig_vars_thresh=sig_vars_thresh)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',family='poisson',K=K,thresh_screen = .05)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='Wald',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',only_return_selected=FALSE,K=K)
mtcars$log_mpg = log(mtcars$mpg)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'log_mpg',interactions=inter,test='LRT',K=K)
}
glmnet_test<-function(){
sig_vars_thresh = list(model_sel_interaction=1,model_sel_additive=1,glmnet_interaction=1,glmnet_additive=1e5)
robust=TRUE
}
### main
#' model_selection
#'
#' Main function for model selection from a set of many variables
#' @param df, a data.frame containing response and observations variables. Factors with more than 2 levels have only been implimented for test='LRT'
#' @param observations, a character vector of the names of independent/observations variables in df
#' @param response, a character vector of the names of dependent/response variables in df
#' @param family, a character string indicating the family associated with the submitted model c('gaussian','binomial','poisson'...)
#' @param model, a model associated for testing the variables c(glm,lm)
#' @param interactions, a boolean indicating if interactions should be assessed. Default is NULL, by default, interactions will be examined according to the constraints set by sig_vars_thresh. If a value is set for interactions (T/F) this will override the recomendations of sig_vars_thresh
#' @param test, a character string indicating Likelihood Ratio Test ('LRT') testing likelihood improvement of a model or Wald test ('Wald') testing coefficient > 0
#' @param thresh_screen, a numeric value indicating the p-value cutoff for the univariate screening
#' @param only_return_selected, a boolean value. If true, only models with p-value less than the threshold will be returned. Otherwise, all models will be returned.
#' @param K, a numeric value indicating the number of folds to use for k-fold cross-validation. K=10 by default. K=0 to skip k-fold validation.
#' @param sig_vars_thresh a list specifying the maximal number of significant variables allowed for each final model generating method. NULL (self initializing) by default.
#' @param robust boolean indicating if regularization will be run multiple times to get a robust indication of the underlying structure
#' @param N, a numeric value, default N=1, indicating the number of cross validation iterations to perform
#' @return a list containing: univariate models, the final selected model, and crossvalidation stats.
#' @export
#' @examples
#' mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=F,test='LRT',K=5,family = 'gaussian',model=glm)
#' out=vis(mod)
#' print(out[[1]])
#' print(out[[2]])
#' @import glmnet
#' @import glinternet
model_selection <- function(df,observations,response,family='gaussian',model=glm,interactions=FALSE,test=c('Wald','LRT'),thresh_screen=.2,only_return_selected=FALSE,K=10,sig_vars_thresh=NULL,robust=FALSE,N=1){
if(length(response)!=1){stop('use multiresponse_model_selection()')}
if(!test%in%c('Wald','LRT')){stop("test is not in c(Wald,LRT)")}
#if(!interactions%in%c('signif','none','all')){stop("interactions is not in c(signif,none,all)")}
if(is.null(sig_vars_thresh)){
sig_vars_thresh = list(model_sel_interaction=6,model_sel_additive=25,glmnet_interaction=200,glmnet_additive=2000)
}
# Univariate Screen
observationsL <<- univariate_screen(df,observations,response,family,model,interactions,test,thresh=thresh_screen,only_return_selected=only_return_selected)
# Multivariate Model
obs_sign = na.omit( names(observationsL)[attr(observationsL,'Pr')<thresh_screen] )
if( length( obs_sign ) == 0 ){ stop("There are no observations that pass the threshold set by thresh_screen. Consider increasing thresh_screen.")}
# set interaction based on the number of variables passing the screening threshold
if(is.null(interactions)){
if(length(obs_sign) < sig_vars_thresh$model_sel_interaction){
interactions=TRUE
print('interactive model: selection')
}else if(length(obs_sign) < sig_vars_thresh$model_sel_additive){
interactions=FALSE
print('additive model: selection')
}else if(length(obs_sign) < sig_vars_thresh$glmnet_interaction){
#glm_reg = glinternet ## not yet implimented
glm_reg = cv.glmnet
print('interactive model: regularization')
}else if(length(obs_sign) < sig_vars_thresh$glmnet_additive){
glm_reg = cv.glmnet
print('additive model: regularization')
}
}
# construct multivariate models
if(length(obs_sign) < sig_vars_thresh$model_sel_additive){
selected_model = stepwise_multivariate_model_selection(df,obs_sign,response,family,model,interactions)
}else{
if(robust){ # run glmnet several times
selected_model_list = list()
for(i in 1:500){
indx = sample(1:nrow(df)) # randomize
indy = sample(1:length(obs_sign)) # randomize
selected_model_list[[i]] = glm_reg(y=df[indx,response],x=data.matrix(df[indx,obs_sign[indy]]),family=family) ## untested
}
}else{
selected_model = glm_reg(y=df[,response],x=data.matrix(df[,obs_sign]),family=family) ## untested
}
}
if(length(obs_sign) > sig_vars_thresh$glmnet_additive){
warning(paste(length(obs_sign),'is a large number of variables that may pose a relative challenge to glmnet'))
}
# Model Diagnostics
# Cross Validation
if(length(obs_sign) < sig_vars_thresh$model_sel_additive){
if(K>1){
cv=cross_assess_wrapper(data=df,formula=selected_model$formula,resp=response,family=family,K,model,cv_function=cross_valid_kfold,N=N)
}else{
cv=NULL
}
}else{
if(robust){
# multi-model characterization
selected_model = vis_reg(selected_model_list)
}else{
# cross validation for regularization
plot(selected_model)
cv = list(auc=selected_model$cvm[selected_model$lambda==selected_model$lambda.min],other_stats=selected_model)
}
}
return(list(screen=observationsL,final=selected_model,cv=cv))
}
#' model_selection_many_to_few
#'
#' runs regularization then model selection to reduce many variables to a small robust model TODO: Austin and Ben w/ vis_reg
#' @param ..., see model_select parameters
#' @return a list containing: univariate models, the final selected model, and crossvalidation stats.
#' @export
model_selection_many_to_few <- function(...){
# run regularization
# (optional) run interaction regularization
# identify regularization prototype models
# for each prototypical model:
# while not overfit:
# select highest magnitude contributors
# univariate screening and backward selection
# return prototypical models
}
#######################################
### Run Tests
iris_test<-function(){
print(str(iris))
}
mtcars_tests <- function(){
# source('~/Desktop/modeling_functions.r')
K=5
inter=NULL
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm)
out=vis(mod)
out[[1]]
out[[2]]
dev.off()
sig_vars_thresh = list(model_sel_interaction=6,model_sel_additive=7,glmnet_interaction=200,glmnet_additive=2000) # see regularization output (lower upper bound for additive model selection)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm,sig_vars_thresh=sig_vars_thresh)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',family='poisson',K=K,thresh_screen = .05)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='Wald',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',only_return_selected=FALSE,K=K)
mtcars$log_mpg = log(mtcars$mpg)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'log_mpg',interactions=inter,test='LRT',K=K)
}
glmnet_test<-function(){
sig_vars_thresh = list(model_sel_interaction=1,model_sel_additive=1,glmnet_interaction=1,glmnet_additive=1e5)
robust=TRUE
}
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
source("R/univariate_screen.r")
source("R/cross_validation.r")
source("R/multivariate_model.r")
source("R/vis.r")
source("R/performance_assessment.r")
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
source('~/GitHub/RegressionModelPipeline/R/RegressionModelPipeline.R')
source("R/multivariate_model.r")
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
source("R/multivariate_model.r")
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
library(MASS)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',test='LRT',K=5,family = 'gaussian',model=glm)
out[[1]]
out[[2]]
K=5
inter=NULL
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm)
out=vis(mod)
sig_vars_thresh = list(model_sel_interaction=6,model_sel_additive=7,glmnet_interaction=200,glmnet_additive=2000) # see regularization output (lower upper bound for additive model selection)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm,sig_vars_thresh=sig_vars_thresh)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',family='poisson',K=K,thresh_screen = .05)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='Wald',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=K)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',only_return_selected=FALSE,K=K)
mtcars$log_mpg = log(mtcars$mpg)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'log_mpg',interactions=inter,test='LRT',K=K)
sig_vars_thresh = list(model_sel_interaction=6,model_sel_additive=7,glmnet_interaction=200,glmnet_additive=2000) # see regularization output (lower upper bound for additive model selection)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',K=5,family = 'gaussian',model=glm,sig_vars_thresh=sig_vars_thresh)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='LRT',family='poisson',K=K,thresh_screen = .05)
mod=model_selection(df=mtcars,colnames(mtcars)[-1],response = 'mpg',interactions=inter,test='Wald',K=K)
rm(list=ls())
setwd("~/GitHub/RegressionModelPipeline/")
library(devtools)
library(MASS)
library(ggplot2)
library(fastcluster)
library(glmnet)
library(reshape)
library(data.table)
library(easyGgplot2)
source("R/vis.r")
source("R/RegressionModelPipeline.R")
source("R/univariate_screen.r")
source("R/performance_assessment.r")
source("R/cross_validation.r")
source("R/multivariate_model.r")
load(paste0('~/Desktop/FDA_Austin/VirusRegModels_run2.Rda'))
load(paste0('~/Desktop/2017 UCSD/Project02-FDAvirus/FDA_Austin/VirusRegModels_run2.Rda'))
mod <- PredResult[['mod']]
visResults <- vis_reg(mod,k=4)
visResults$p1
debugSource('~/GitHub/RegressionModelPipeline/R/test_vis.R')
p1
p2
p3
p4
visResults$p1
ggplot2.multiplot(visResults$p2,visResults$p3, cols=2)
ggplot2.multiplot(visResults$p3,visResults$p4, cols=2)
if(!require(devtools)) install.packages("devtools")
devtools::install_github("kassambara/factoextra")
pkgs <- c("cluster", "fpc", "NbClust")
install.packages(pkgs)
install.packages(pkgs)
library(factoextra)
library(cluster)
library(fpc)
library(NbClust)
data(iris)
head(iris)
nb <- NbClust(iris.scaled, distance = "euclidean", min.nc = 2,
max.nc = 10, method = "complete", index ="all")
iris.scaled <- scale(iris[, -5])
nb <- NbClust(iris.scaled, distance = "euclidean", min.nc = 2,
max.nc = 10, method = "complete", index ="all")
fviz_nbclust(nb) + theme_minimal()
km.res <- eclust(iris.scaled, "kmeans", k = 3,
nstart = 25, graph = FALSE)
km.res$cluster
View(iris.scaled)
fviz_cluster(km.res, geom = "point", frame.type = "norm")
pam.res <- eclust(iris.scaled, "pam", k = 3, graph = FALSE)
pam.res$cluster
fviz_cluster(pam.res, geom = "point", frame.type = "norm")
res.hc <- eclust(iris.scaled, "hclust", k = 3,
method = "complete", graph = FALSE)
head(res.hc$cluster, 15)
fviz_dend(res.hc, rect = TRUE, show_labels = FALSE)
fviz_dend(res.hc, rect = TRUE, show_labels = TRUE)
plot(sil, main ="Silhouette plot - K-means")
sil <- silhouette(km.res$cluster, dist(iris.scaled))
head(sil[, 1:3], 10)
plot(sil, main ="Silhouette plot - K-means")
fviz_silhouette(sil)
si.sum <- summary(sil)
si.sum$clus.avg.widths
si.sum$avg.width
si.sum$clus.sizes
head(silinfo$widths[, 1:3], 10)
head(sil$widths[, 1:3], 10)
silinfo <- km.res$silinfo
names(silinfo)
head(silinfo$widths[, 1:3], 10)
dd <- dist(iris.scaled, method ="euclidean")
km_stats <- cluster.stats(dd, km.res$cluster)
km_stats$within.cluster.ss
km_stats
species <- as.numeric(iris$Species)
clust_stats <- cluster.stats(d = dist(iris.scaled),
species, km.res$cluster)
clust_stats$corrected.rand
clust_stats$vi
table(iris$Species, pam.res$cluster)
table(iris$Species, res.hc$cluster)
cluster.stats(d = dist(iris.scaled),
species, res.hc$cluster)$vi
d = dist(iris.scaled)
?dist
fviz_dist(d)
source("https://bioconductor.org/biocLite.R")
biocLite("TCGAbiolinks")
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
library(TCGAbiolinks)
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
library('TCGAbiolinks')
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
source("https://bioconductor.org/biocLite.R")
biocLite("TCGAbiolinks")
library('TCGAbiolinks')
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
source("https://bioconductor.org/biocLite.R")
biocLite("TCGAbiolinks")
source("https://bioconductor.org/biocLite.R")
biocLite("TCGAbiolinks")
library('TCGAbiolinks')
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
source("https://bioconductor.org/biocLite.R")
source("https://bioconductor.org/biocLite.R")
biocLite() ## R version 3.0 or later
biocLite("TCGAbiolinks")
library('TCGAbiolinks')
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
library(TCGAbiolinks)
query <- GDCquery(project = "TARGET-AML",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts")
devtools::install_github("BioinformaticsFMRP/TCGAbiolinks")
install.packages("ComplexHeatmap")
biocLite("ComplexHeatmap")
devtools::install_github("BioinformaticsFMRP/TCGAbiolinks")
biocLite("ComplexHeatmap")
source("https://bioconductor.org/biocLite.R")
biocLite("ComplexHeatmap")
devtools::install_github("BioinformaticsFMRP/TCGAbiolinks")
source("https://bioconductor.org/biocLite.R")
biocLite("ComplexHeatmap")
library(ComplexHeatmap)
devtools::install_github("BioinformaticsFMRP/TCGAbiolinks")
devtools::install_github(repo = "BioinformaticsFMRP/TCGAbiolinks")
remove.packages("BiocInstaller")
remove.packages("BiocInstaller")
source("http://bioconductor.org/biocLite.R")
biocLite() ## to update old packages
biocLite("TCGAbiolinks")
library(TCGAbiolinks)
clin <- GDCquery_clinic("TCGA-ACC", type = "clinical", save.csv = TRUE)
mut <- GDCquery_Maf(tumor = "ACC")
library(TCGAbiolinks)
mut <- GDCquery_Maf(tumor = "ACC")
clin <- GDCquery_clinic("TCGA-ACC","clinical")
clin <- clin[,c("bcr_patient_barcode","disease","gender","tumor_stage","race","vital_status")]
TCGAvisualize_oncoprint(mut = mut, genes = mut$Hugo_Symbol[1:20],
filename = "onco.pdf",
annotation = clin,
color=c("background"="#CCCCCC","DEL"="purple","INS"="yellow","SNP"="brown"),
rows.font.size=10,
heatmap.legend.side = "right",
dist.col = 0,
label.font.size = 10)
query <- GDCquery(project = "TCGA-ACC",
data.category = "Copy Number Variation",
data.type = "Copy Number Segment",
barcode = c( "TCGA-OR-A5KU-01A-11D-A29H-01", "TCGA-OR-A5JK-01A-11D-A29H-01"))
GDCdownload(query)
data <- GDCprepare(query)
biocLite("TCGAbiolinks")
library(TCGAbiolinks)
clin <- GDCquery_clinic("TCGA-ACC", type = "clinical", save.csv = TRUE)
devtools::install_github(repo = "BioinformaticsFMRP/TCGAbiolinks")
print(.libPaths())
print(sessionInfo())
print(version)
q()