#' @title Save and Draw the Multi-layer Signaling Network
#'
#' @param MLnetList The output of Run_MLnet function.
#' @param LigClu character: The neighboring cell
#' @param RecClu character: The central cell
#' @param outdir The name of output folder
#' @param PyHome The path to PYTHONHOME. The PyHome parameter is invalidated if only the plotMLnet parameter is set to TRUE.
#' @param plotMLnet Whether to draw the multi-layer signaling network. The default setting is FALSE.
#'
#' @description
#' This function save the results generated by Rub_scMLnet function and visualize the results by pymnet package (python).
#' The generated multi-layer signaling network is saved in the folder named by the LigClu, RecClu and outdir parameters.
#'
#' @export
#'
#' @return NULL
DrawMLnet <- function(MLnetList,LigClu,RecClu,outdir = NULL,PyHome,plotMLnet = F){
#creat output workdir
if(!file.exists("output")){ dir.create("output") }
i <- paste(strsplit(LigClu,split = "\\W")[[1]][1],strsplit(RecClu,split = "\\W")[[1]][1],sep = "_")
if(is.null(outdir)){
wd <- paste("./output",i,sep = "/")
if(!file.exists(wd)){dir.create(wd)}
}else{
wd <- paste("./output",outdir,sep = "/")
if(!file.exists(wd)){dir.create(wd)}
wd <- paste("./output",outdir,i,sep = "/")
if(!file.exists(wd)){dir.create(wd)}
}
#output
LigRecNet <- MLnetList[[1]]
RecTFNet <- MLnetList[[2]]
TFTarNet <- MLnetList[[3]]
#output result
cat("Save Results\n")
NetLigRecFile <- paste(wd,"LigRec.net.txt",sep = "/")
NetRecTFFile <- paste(wd,"RecTF.net.txt",sep = "/")
NetTFTarFile <- paste(wd,"TFTarGene.net.txt",sep = "/")
writeLines(LigRecNet,con=NetLigRecFile,sep="\n")
writeLines(RecTFNet,con=NetRecTFFile,sep="\n")
writeLines(TFTarNet,con=NetTFTarFile,sep="\n")
#draw MLnet
if(plotMLnet){
cat("Draw MLnet!\n")
#check python home
if(is.null(PyHome)){stop("Can't find python!")}
#figure path
netPic <- paste(wd,"mulnet.pdf",sep = "/")
#draw
cmd <- paste(PyHome,"./code/DrawNetNew.py",NetLigRecFile,NetRecTFFile,NetTFTarFile,netPic,sep=" ")
system(cmd)
}
cat("Finish!\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.