参数< -列表(种子= 29221 ) ## ---- eval = FALSE -------------------------------------------------------------- # 如果(!需要(“BiocManager”))# install.packages (BiocManager) # BiocManager::安装(“glmSparseNet ") ## ---- 包,消息= FALSE,警告= FALSE ----------------------------------- 库(dplyr)库(ggplot2)图书馆(生存)图书馆(futile.logger)图书馆(curatedTCGAData)图书馆(TCGAutils) #库(glmSparseNet) # #一些通用选项徒劳的。记录调试包。最后。值<- flag .layout(布局。format('[~l] ~m'))。值< - glmSparseNet::: show.message (FALSE) #设置ggplot2默认主题最小theme_set (ggplot2:: theme_minimal ()) ## ---- 包括= TRUE,结果=“隐藏”,消息= FALSE,警告= FALSE ------------------ brca < - curatedTCGAData (diseaseCode =“brca化验=“RNASeq2GeneNorm version = " 1.1.38 " dry.run = FALSE ) ## ---- curated_data_non_eval eval = FALSE ---------------------------------------- # brca < - curatedTCGAData (diseaseCode =“brca化验=“RNASeq2GeneNorm”,# version = " 1.1.38 ",dry.run = FALSE) ## ----数据。秀,警告= FALSE,错误= FALSE ------------------------------------ brca < - TCGAutils:: TCGAsplitAssays (brca c (' 1 ', ' 11 ')) xdata。raw <- t(cbind(assay(brca[[1]]), assay(brca[[2]])))) #获取生存数据和检测数据类别之间的匹配。v <- TCGAbiospec(rownames(xdata.raw))$sample_definition %>% factor names(class.v) <- rownames(xdata.raw) #保留标准偏差> 0 xdata的特征。Raw <- xdata。原始%>%{(应用(。, 2, sd) != 0)} %>% {xdata。Raw [, .]} %>% scale set.seed(params$seed)小。子集<- c('CD5', 'CSF2RB', 'HSF1', 'IRGC', 'LRRC37A6P', 'NEUROG2', 'NLRC4', 'PDE11A', 'PIK3CB', 'QARS', 'RPGRIP1L', 'SDC1', 'TMEM31', 'YME1L1', 'ZBTB11', sample(colnames(xdata.raw), 100) xdata <- xdata。生(small.subset[小。% colnames(xdata.raw)中的子集%V ## ----适合。show----------------------------------------------------------------- fitted <- cv.glmHub(xdata, ydata, family = 'binomial', network = 'correlation', nlambda = 1000, network.options = networkOptions(cutoff = .6, min.degree = .2)) ## ----results------------------------------------------------------------------ plot(fitted) ## ----show_coefs--------------------------------------------------------------- coefs.v <- coef(fitted, s = 'lambda.min')[,1] %>% { .[. != 0]} coefs.v %>% { data.frame(ensembl.id = names(.), gene.name = geneNames(names(.))$external_gene_name, coefficient = ., stringsAsFactors = FALSE) } %>% arrange(gene.name) %>% knitr::kable() ## ----hallmarks---------------------------------------------------------------- geneNames(names(coefs.v)) %>% { hallmarks(.$external_gene_name)$heatmap } ## ----accuracy, echo=FALSE----------------------------------------------------- resp <- predict(fitted, s = 'lambda.min', newx = xdata, type = 'class') flog.info('Misclassified (%d)', sum(ydata != resp)) flog.info(' * False primary solid tumour: %d', sum(resp != ydata & resp == 'Primary Solid Tumor')) flog.info(' * False normal : %d', sum(resp != ydata & resp == 'Solid Tissue Normal')) ## ----predict, echo=FALSE, warning=FALSE--------------------------------------- response <- predict(fitted, s = 'lambda.min', newx = xdata, type = 'response') qplot(response, bins = 100) ## ----roc, echo=FALSE---------------------------------------------------------- roc_obj <- pROC::roc(ydata, as.vector(response)) data.frame(TPR = roc_obj$sensitivities, FPR = 1 - roc_obj$specificities) %>% ggplot() +geom_line(aes(FPR,TPR), color = 2, size = 1, alpha = 0.7)+ labs(title= sprintf("ROC curve (AUC = %f)", pROC::auc(roc_obj)), x = "False Positive Rate (1-Specificity)", y = "True Positive Rate (Sensitivity)") ## ----sessionInfo-------------------------------------------------------------- sessionInfo()