# # - eval = FALSE --------------------------------------------------------------- # # 没有评估# simdata < - readRDS (simdata_directory / sim812.rds) # sim10 < - simdata [[10 ]] ## ---- 消息= FALSE,警告= FALSE, fig.wide = TRUE, fig.asp = 1, fig.cap = '微分模拟网络分析。左上至右下:用于模拟的原始调节网络;由ADR1和UME6敲除(KDs)产生的真诱导差分网络;预测的ADR1击倒差分网络;预测的UME6击倒差分网络。调节网络中的Reg和绿色边分别代表激活和抑制。微分网络中的边是根据导致它们的微分共表达式的敲除来着色的。在预测网络中的真阳性是基于他们的击倒着色,而假阳性是灰色'----库(dcanr) #加载数据:一个模拟数据(sim102) #运行一个标准管道与z-score方法dcnets <- dcPipeline(sim102, dc。Func = 'zscore') #绘制源网络,真差分网络和推断网络op <- par(no。readonly = TRUE) par(mfrow = c(2,2)) plotSimNetwork(sim102, main = '监管网络')plotSimNetwork(sim102, what = 'association', main = '真差分关联网络')plot(dcnets$ADR1, main = 'ADR1 KD预测网络')plot(dcnets$UME6, main = 'UME6 KD预测网络')par(op) ## ----------------------------------------------------------------------------- #使用自定义参数的z-score方法运行标准管道dcnets_sp <- dcPipeline(sim102, dc。func = ' zscore ' cor.method =“枪兵”,#用斯皮尔曼相关打= 0.2)#截止为创建网络 ## ----------------------------------------------------------------------------- sim102_lambdas = c (0.5145742607781790267651, 0.3486682118540171959609) dcnets_ldgm < - dcPipeline (sim102特区。Func = 'ldgm', cond。Args = list(ldgm. list)lambda = sim102_lambdas)) ## ----eval=FALSE--------------------------------------------------------------- ## emat,一个命名矩阵,列为样本,行为基因##条件,一个二进制命名向量,由1和2组成##返回一个命名邻接矩阵或一个igraph对象# myInference <- function(emat,条件, ...) { # #your code here # return(dcnet) # } ## ----------------------------------------------------------------------------- #custom pipeline function analysisInbuilt <- function(emat, condition, dc.method = 'zscore', ...) { #compute scores score = dcScore(emat, condition, dc.method, ...) #perform statistical test pvals = dcTest(score, emat, condition, ...) #adjust tests for multiple testing adjp = dcAdjust(pvals, ...) #threshold and generate network dcnet = dcNetwork(score, adjp, ...) return(dcnet) } #call the custom pipeline custom_nets <- dcPipeline(sim102, dc.func = analysisInbuilt) ## ----message=FALSE, warning=FALSE--------------------------------------------- #retrieve results of applying all available methods allnets <- lapply(dcMethods(), function(m) { dcPipeline(sim102, dc.func = m, precomputed = TRUE) }) names(allnets) <- dcMethods() #name the results based on methods #get the size of the UME6 KD differential network netsizes <- lapply(allnets, function(net) { length(igraph::E(net$UME6)) }) print(unlist(netsizes)) ## ----------------------------------------------------------------------------- #available performance metrics print(perfMethods()) ## ----message=FALSE, warning=FALSE--------------------------------------------- #compute the F1-measure for the prediction made by each method f1_scores <- lapply(allnets, function (net) { dcEvaluate(sim102, net, truth.type = 'association', combine = TRUE) }) print(sort(unlist(f1_scores), decreasing = TRUE)) #compute the Matthew's correlation coefficient of the z-score inference z_mcc <- dcEvaluate(sim102, dcnets, perf.method = 'MCC') print(z_mcc) ## ----message=FALSE, warning=FALSE--------------------------------------------- #compute precision dcprec <- lapply(allnets, function (net) { dcEvaluate(sim102, net, perf.method = 'precision') }) #compute recall dcrecall <- lapply(allnets, function (net) { dcEvaluate(sim102, net, perf.method = 'recall') }) ## ----echo=FALSE, message=FALSE, warning=FALSE, fig.small=TRUE----------------- #plot the precision and recall plot( unlist(dcprec), unlist(dcrecall), type = 'n', main = 'Precision v recall', xlab = 'Precision', ylab = 'Recall', xlim = c(-0.25, 1), ylim = c(0, 1) ) text( unlist(dcprec), unlist(dcrecall), labels = names(allnets), type = 'n', cex = 1.2 ) ## ----sessionInfo, echo=FALSE-------------------------------------------------- sessionInfo()