diff --git a/DESCRIPTION b/DESCRIPTION index e8b69b0..9d6420d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,13 @@ Package: simDeNet Type: Package -Title: Simulation study on deconvolution for network estimate -Version: 0.0.2 -Date: 2017-02-03 -Author: Yun Zhang +Title: Simulation study on deconvolution for co-expression network +Version: 1.0.0 +Date: 2019-04-22 +Author: Yun Zhang, Jonavelle Cuerdo, Matthew McCall Maintainer: Yun Zhang Description: This package is built for reproducibility of the simulation study. -Depends: R (>= 3.3.0) -Imports: mvtnorm, preprocessCore, ISOpureR, ROCR, WGCNA, minet, bnlearn +Depends: R (>= 3.5.0) +Imports: methods, mvtnorm, preprocessCore, ISOpureR, ROCR, shiny VignetteBuilder: knitr -Suggests: knitr, rmarkdown +Suggests: knitr, rmarkdown, shinydashboard, DT, GeneNet, abind License: GPL-3 diff --git a/NAMESPACE b/NAMESPACE index 9dc824f..11decc1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,9 +4,9 @@ importFrom(ISOpureR, ISOpure.step1.CPE, ISOpure.step2.PPE) importFrom(ROCR, prediction, performance, plot) importClassesFrom(ROCR, performance, prediction) importMethodsFrom(ROCR, plot) -importFrom(WGCNA, adjacency) -importFrom(minet, minet) -importFrom(bnlearn, hc, bn.fit) +importFrom("graphics", "legend") +importFrom("methods", "slot", "slot<-") +importFrom("stats", "runif") +importFrom("shiny", "runApp") - -export(oneStepSim, generate.Sigma, sim.expr, deconv, eval.ROC, netEstByMethod) +export(oneStepSim, generate.Sigma, sim.expr, deconv, eval.ROC, runShiny) diff --git a/R/eval.ROC.R b/R/eval.ROC.R index 1d7724e..e4571eb 100644 --- a/R/eval.ROC.R +++ b/R/eval.ROC.R @@ -5,7 +5,7 @@ ############## -eval.ROC <- function(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=TRUE, ...){ +eval.ROC <- function(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=FALSE, lightPDF=FALSE, ...){ # if(sum(dim(est.str)!=dim(est.str))>0){stop("Error: est.str and true.str must have the same dimemsion.")} # if(!isSymmetric(unname(est.str))|!isSymmetric(unname(true.str))){stop("Error: est.str and true.str must be symmetric.")} @@ -23,8 +23,15 @@ eval.ROC <- function(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=TRUE, ## plot if(plot.ROC){ - if(zoom){plot(perf, xlim=c(0,xval), ylim=c(0,yval), ...)} - else plot(perf) + perf.plot <- perf + if(lightPDF){ + set.seed = 123 + sparsePoints <- c(1, sort(sample(2:(n.unique-1), 10000)), n.unique) + slot(perf.plot,"x.values")[[1]] <- slot(perf.plot,"x.values")[[1]][sparsePoints] + slot(perf.plot,"y.values")[[1]] <- slot(perf.plot,"y.values")[[1]][sparsePoints] + } + if(zoom){plot(perf.plot, xlim=c(0,xval), ylim=c(0,yval), ...)} + else plot(perf.plot, ...) if(show.AUC){legend("bottom",paste0("AUC=",round(auc.value,3)),bty = "n")} } diff --git a/R/netEstByMethod.R b/R/netEstByMethod.R deleted file mode 100644 index 7c40079..0000000 --- a/R/netEstByMethod.R +++ /dev/null @@ -1,66 +0,0 @@ -# library(WGCNA) -# library(minet) -# library(bnlearn) - - -################## -## est.Bayesian ## -################## -est.Bayesian<-function(datExpr){ - genenames <- names(datExpr) - names(datExpr) <- paste0("V",1:ncol(datExpr)) - ## find linear coeficients from bn.hc - bn.hc.fit <- bn.fit(hc(datExpr),datExpr) - coefs <- coef(bn.hc.fit) - - ## edge - child <- parent <- weight <- vector() - for (i in 1:length(coefs)){ - z <- coefs[[i]][-1] - child <- c(child, rep(names(coefs)[i],length(z))) - parent <- c(parent, names(z)) - weight <- c(weight, abs(z)) - } - child <- gsub("V","C",child) - parent <- gsub("V","P",parent) - edge <- data.frame(child, parent, weight) - - ## estimated weight on edges - nGenes <- ncol(datExpr) - est.bn0 <- matrix(0, nGenes, nGenes) - rownames(est.bn0) <- paste0("C",1:nGenes) #row=child - colnames(est.bn0) <- paste0("P",1:nGenes) #col=parent - for (i in 1:nrow(edge)){ - est.bn0[child[i],parent[i]] <- weight[i] - } - est.bn <- est.bn0 + t(est.bn0) - colnames(est.bn) <- rownames(est.bn) <- genenames - - return(est.bn) -} - - -###################### -## netEstByMethod() ## -###################### - -netEstByMethod <- function(data.list,method,softPower=1){ - est.str.list <- vector("list",length=length(data.list)) - names(est.str.list) <- names(data.list) - if(method=="WGCNA"){ - for(k in 1:length(data.list)){ - est.str.list[[k]] <- adjacency(as.data.frame(t(data.list[[k]])), power=softPower) - } - } - if(method=="ARACNE"){ - for(k in 1:length(data.list)){ - est.str.list[[k]] <- minet(as.data.frame(t(data.list[[k]])), method = "aracne") - } - } - if(method=="Bayesian"){ - for(k in 1:length(data.list)){ - est.str.list[[k]] <- est.Bayesian(as.data.frame(t(data.list[[k]]))) - } - } - return(est.str.list) -} diff --git a/R/oneStepSim.R b/R/oneStepSim.R index 2881ba0..701ec55 100644 --- a/R/oneStepSim.R +++ b/R/oneStepSim.R @@ -34,7 +34,7 @@ oneStepSim <- function(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T="s return(list("m.gene"=m.gene, "Sigma.T"=Sigma.T, "Sigma.N"=Sigma.N, "true.str.T"=true.str.T, "expr.pure.T"=out.expr$expr.pure.T, "expr.pure.N"=out.expr$expr.pure.N, - "expr.mixed"=out.expr$expr.mixed, "true.prop"=prop.T)) + "expr.mixed"=out.expr$expr.mixed, "true.prop"=out.expr$true.prop)) } @@ -95,6 +95,7 @@ generate.Sigma <- function(m.gene, block.size, rho, dd=NULL, str.type="interchan if(sum(block.size)>m.gene){stop("Error: sum of block.size must be smaller than m.gene.")} if(length(rho)!=length(block.size)){stop("Error: rho and block.size must be have the same length.")} if(!is.null(dd)&length(dd)!=m.gene){stop("Error: dd must have length equal to m.gene.")} + if(length(str.type)!=length(block.size)&length(str.type)!=1){stop("Error: either specify one str.type for all the blocks or specify different str.type for each block.")} ## weight matrix if(is.null(dd)){dd <- rep(1,m.gene)} diff --git a/R/runShiny.R b/R/runShiny.R new file mode 100644 index 0000000..3415117 --- /dev/null +++ b/R/runShiny.R @@ -0,0 +1,8 @@ +runShiny <- function() { + appDir <- system.file("shinyapp", package = "simDeNet") + if (appDir == "") { + stop("Could not find example directory. Try re-installing `simDeNet`.", call. = FALSE) + } + + shiny::runApp(appDir, display.mode = "normal") +} \ No newline at end of file diff --git a/README.md b/README.md index 2f8474e..27a6669 100644 --- a/README.md +++ b/README.md @@ -1 +1,25 @@ -# simDeNet-R-Package +# Interactive exploration of the effect of tissue composition on gene co-expression + +## Getting Started + +Install package: +```R +install.packages("devtools") +devtools::install_github("yunzhang813/simDeNet-R-Package-Shiny") +``` + +Launch Shiny application for interactive exploration using pre-uploaded pure cell type data: +```R +library(simDeNet) +runShiny() +``` +![](vignettes/Shiny-steps.png) + + +Browse vignette for other useful functions included in the pakcage: +```R +browseVignettes("simDeNet") +``` + +## Citation +Yun Zhang, Jonavelle Cuerdo, Marc K Halushka, Matthew N McCall, 2019. The effect of tissue composition on gene co-expression, *Briefings in Bioinformatics*, bbz135, https://doi.org/10.1093/bib/bbz135 diff --git a/data/celltype.rda b/data/celltype.rda old mode 100644 new mode 100755 diff --git a/data/datalist b/data/datalist index 95bf6ce..975aa18 100644 --- a/data/datalist +++ b/data/datalist @@ -1 +1 @@ -celltype \ No newline at end of file +celltype diff --git a/inst/shinyapp/app.R b/inst/shinyapp/app.R new file mode 100644 index 0000000..017ca8b --- /dev/null +++ b/inst/shinyapp/app.R @@ -0,0 +1,220 @@ +library(shiny) +library(shinydashboard) +library(simDeNet) +library(DT) +library(GeneNet) +library(abind) + +# function for generating beta distributions +estBetaParams <- function(mu, var) { + alpha <- ((1 - mu) / var - 1 / mu) * mu ^ 2 + beta <- alpha * (1 / mu - 1) + return(params = list(alpha = alpha, beta = beta)) +} + +# load in data files +data("celltype") +data("microRNAome_avg_exprs") + +ui <- dashboardPage( + dashboardHeader(title="Cell type mixture"), + dashboardSidebar(disable=TRUE), + dashboardBody( + fluidRow( + column(width=6, + box( + title="Dataset", status="info", width = NULL, + actionButton("generate", "Load data to your workspace") + ), + box( + title="Parameters", status="info", width=NULL, + wellPanel(style="overflow-y:scroll; max-height:800px", + p("One Step Simulation"), + p("This function simulates pure and mixed cell type expression data for two cell types, namely 1 (target) and 2 (null), for your picked cell types and designed correlation structure for the target cell type. Set your parameters for the variables below!"), + textInput(inputId="nSamp", label="Enter # of samples to simulate for each celltype: ", value="20"), + selectInput(inputId="muT", label="Enter cell type 1 (Target): ", c("Choose your dataset first!"), selected="Choose your dataset first!"), + selectInput(inputId="muN", label="Enter cell type 2 (Null): ", c("Choose your dataset first!"), selected="Choose your dataset first!"), + selectInput(inputId="propT", label="Choose vector of mixing proportions", + c("seq", "unif", "customize", "beta distribution"), selected="seq"), + conditionalPanel( + condition="input.propT=='customize'", + textInput("customProp", "Enter customized prop: ") + ), + conditionalPanel( + condition="input.propT=='beta distribution'", + sliderInput("beta_mu", "Mean", min = 0, max = 1, value = 0), + sliderInput("beta_var", "Variance", min = 0, max = 1, value = 0) + ), + textInput(inputId="blocksizeT", label="Enter # of genes for each block (separate by comma): ", value="30,30,30"), + textInput(inputId="rhoT", label="Enter corr. coefficients for each block (separate by comma): ", value="0.7,0.7,0.7"), + selectInput(inputId="selectedGenes", label="Gene selection", + c("random", + "most differentially expressed", + "least differentially expressed"), selected="random")) + ) + ), + column(width=6, + actionButton(inputId="OSSButton", label= "Run OneStepSim"), + textInput(inputId="niter", label="Num. of Iterations: ", value="5"), + plotOutput(outputId = "ROC.Plot", width="100%", height="400px"), + downloadButton("dld.ROC", label="Download ROC plot") + ) + + ) + ) + ) + +server <- function(input, output, session) { + + # modal dialog asks user to choose a dataset before proceeding with application + dataModal <- function(failed=FALSE){ + modalDialog( + selectInput(inputId='ds', label='Select dataset to work with:', c('celltype', 'microRNAome_avg_exprs'), selected='celltype'), + + # if the dataset can't be found + if(failed) + div(tags$b("Invalid name of data object", style="color: red;")), + + footer = tagList( + modalButton("Cancel"), + actionButton("ok", "OK") + ) + ) + } + + # brings up the modal for choosing datasets + observeEvent(input$generate, { + showModal(dataModal()) + }) + + data <- reactive({paste(getwd(),"/data/",input$ds,'.rda', sep='')}) + vars <- reactive({load(data())}) # loads in correct data file + + ###################################### + ######## Choosing the dataset ######## + ###################################### + observeEvent(input$ok, { + + if(input$ds == "celltype") { + ctype_choices <- as.list(ctab$Full_name) # retrieve the 'Full_Name' column in ctab table for clear names + } + else if(input$ds == "microRNAome_avg_exprs") { + ctype_choices <- as.list(colnames(get(vars()))) # retrieve column names in microRNAome_avg_exprs + } + + # functions updates the celltype options according to what dataset is entered + updateSelectInput(session, "muT", label = "Enter cell type 1 (Target): ", choices = ctype_choices) + updateSelectInput(session, "muN", label = "Enter cell type 2 (Null): ", choices = ctype_choices) + + removeModal() + } + ) + + N <-reactive(as.numeric(input$nSamp)) + num_rows <- reactive(nrow(get(vars()))) + niter <- reactive(as.numeric(input$niter)) + + MUT <- reactive({ + if(input$ds == 'celltype'){ + get(vars())[,ctab$Fastq_file_name[which(ctab$Full_name==input$muT)]] + } + else if(input$ds == 'microRNAome_avg_exprs'){ + get(vars())[, input$muT] + } + }) + + MUN <- reactive({ + if(input$ds == 'celltype'){ + get(vars())[,ctab$Fastq_file_name[which(ctab$Full_name==input$muN)]] + } + else if(input$ds == 'microRNAome_avg_exprs'){ + get(vars())[, input$muN] + } + }) + + + TProp <- reactive({ + if(input$propT=="seq"){ + seq(0,1, length=N()) + } + else if(input$propT=="unif"){ + runif(N(), 0, 1) + } + else if(input$propT=="customize"){ + as.numeric(unlist(strsplit(input$customProp, ","))) + } + else if(input$propT == "beta distribution"){ + params <- estBetaParams(mu = input$beta_mu, var = input$beta_var) + rbeta(N(), params$alpha, params$beta) + } + + }) + + BS <- reactive({as.numeric(unlist(strsplit(input$blocksizeT, ",")))}) + RHO <- reactive({as.numeric(unlist(strsplit(input$rhoT, ",")))}) + SG <- reactive({unlist(input$selectedGenes)}) + gene_selection_options <- c("random", "DEG", "non-DEG") + names(gene_selection_options) <- c("random", + "most differentially expressed", + "least differentially expressed") + SG <- reactive({gene_selection_options[unlist(input$selectedGenes)]}) + + # our own functions: + acor <- function(m){abs(cor(t(m)))} + apcor <- function(x){abs(ggm.estimate.pcor(t(x), verbose=FALSE))} + # The palette with grey: + cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") + + observeEvent(input$OSSButton, { + reactives <- reactiveValues( + true.str.pooled = array(numeric(), c(num_rows(), num_rows(), 0)), + acor.pure.pooled = array(numeric(), c(num_rows(), num_rows(), 0)), + acor.mixed.pooled=array(numeric(), c(num_rows(), num_rows(), 0)) + ) + + for(i in 1:niter()){ + oss <- reactive({oneStepSim(N(), MUT(), MUN(), Sigma.T=NULL, Sigma.N=NULL, prop.T=TProp(), dd=NULL, + rho=RHO(), block.size=BS(), str.type='interchangeable', select.gene=SG())}) + + true.iter <- reactive({oss()$true.str.T}) + pure.iter <- reactive({acor(oss()$expr.pure.T)}) + mixed.iter <- reactive({acor(oss()$expr.mixed)}) + + reactives$true.str.pooled <- abind(isolate(reactives$true.str.pooled), true.iter(), along=3) + reactives$acor.pure.pooled <- abind(isolate(reactives$acor.pure.pooled), isolate(pure.iter()), along=3) + reactives$acor.mixed.pooled <- abind(isolate(reactives$acor.mixed.pooled), isolate(mixed.iter()), along=3) + } + + output$ROC.Plot <- renderPlot({ + input$OSSButton + pure = eval.ROC(est.str=reactives$acor.pure.pooled, true.str=reactives$true.str.pooled, plot.ROC=TRUE, show.AUC=FALSE, lightPDF=TRUE, lwd=2, col=cbPalette[1]) + mixed = eval.ROC(est.str=reactives$acor.mixed.pooled, true.str=reactives$true.str.pooled, plot.ROC=TRUE, show.AUC=FALSE, lightPDF=TRUE, lwd=2, col=cbPalette[2], add=TRUE) + abline(a=0,b=1,lty=3,lwd=3) + legend("bottomright", title='AUC', fill=c(cbPalette[1], cbPalette[2]), legend=c(paste('Pure cell type 1:', format(round(pure[['AUC']], 3))),paste('Mixed:', format(round(mixed[['AUC']],3))))) + + }) + + Rplot <- function(){ + pure = eval.ROC(est.str=reactives$acor.pure.pooled, true.str=reactives$true.str.pooled, plot.ROC=TRUE, show.AUC=FALSE, lightPDF=TRUE, lwd=2, col=cbPalette[1]) + mixed = eval.ROC(est.str=reactives$acor.mixed.pooled, true.str=reactives$true.str.pooled, plot.ROC=TRUE, show.AUC=FALSE, lightPDF=TRUE, lwd=2, col=cbPalette[2], add=TRUE) + abline(a=0,b=1,lty=3,lwd=3) + legend("bottomright", title='AUC', fill=c(cbPalette[1], cbPalette[2]), legend=c(paste('Pure cell type 1:', format(round(pure[['AUC']], 3))),paste('Mixed:', format(round(mixed[['AUC']],3))))) + + } + + output$dld.ROC <- downloadHandler( + filename = function(){ + paste(Sys.Date(),'.png', sep='') + }, + content = function(file){ + png(file) + print(Rplot()) + dev.off() + } + ) + + }) +} + + +shinyApp(ui, server) \ No newline at end of file diff --git a/inst/shinyapp/data/celltype.rda b/inst/shinyapp/data/celltype.rda new file mode 100755 index 0000000..1c36b48 Binary files /dev/null and b/inst/shinyapp/data/celltype.rda differ diff --git a/inst/shinyapp/data/datalist b/inst/shinyapp/data/datalist new file mode 100644 index 0000000..e5a89a4 --- /dev/null +++ b/inst/shinyapp/data/datalist @@ -0,0 +1,2 @@ +celltype +microRNAome_avg_exprs \ No newline at end of file diff --git a/inst/shinyapp/data/microRNAome_avg_exprs.rda b/inst/shinyapp/data/microRNAome_avg_exprs.rda new file mode 100755 index 0000000..cea6cdc Binary files /dev/null and b/inst/shinyapp/data/microRNAome_avg_exprs.rda differ diff --git a/man/celltype.Rd b/man/celltype.Rd index 48c5d84..ee09411 100644 --- a/man/celltype.Rd +++ b/man/celltype.Rd @@ -5,7 +5,7 @@ The cell type data } \description{ -%% ~~ A concise (1-5 lines) description of the dataset. ~~ +Sample dataset of pure cell type microRNA abundance } \usage{data("celltype")} \format{ @@ -15,15 +15,6 @@ The cell type data \item{\code{ctab}}{column information of \code{expr}.} } } -\details{ -%% ~~ If necessary, more details than the __description__ above ~~ -} -\source{ -%% ~~ reference to a publication or URL from which the data were obtained ~~ -} -\references{ -%% ~~ possibly secondary sources and usages ~~ -} \examples{ data(celltype) } diff --git a/man/deconv.Rd b/man/deconv.Rd index 8d5a808..d85c323 100644 --- a/man/deconv.Rd +++ b/man/deconv.Rd @@ -1,75 +1,69 @@ -\name{deconv} -\alias{deconv} -%- Also NEED an '\alias' for EACH other topic documented here. -\title{ -Deconvolution -} -\description{ -An integrated function for deconvolution of mixed cell-type samples, based on the \code{ISOpureR} package. -} -\usage{ -deconv(mixed, ref, seed=123, ...) -} -%- maybe also 'usage' for other objects documented here. -\arguments{ - \item{mixed}{data matrix (at the log2-transformed scale) for mixed samples, with genes in rows and samples in columns.} - \item{ref}{data matrix (at the log2-transformed scale) for reference samples, with genes in rows and samples in columns.} - \item{seed}{random seed for reproducible result.} - \item{...}{arguments passed to \code{ISOpure.step1.CPE()}.} -} -\details{ -%% ~~ If necessary, more details than the description above ~~ -} -\value{ -A list of the following components: - \item{expr.deconv}{estimated expression profiles (at the log2-transformed scale) for the targeted pure samples after deconvolution.} - \item{est.prop}{estimated mixing proportions for the targeted pure samples.} - -} -\references{ - G Quon, S Haider, AG Deshwar, A Cui, PC Boutros, QD Morris. \emph{Computational purification of - individual tumor gene expression profiles}. Genome Medicine (2013) 5:29, - \url{http://genomemedicine.com/content/5/3/29}. - - G Quon, QD Morris. \emph{ISOLATE: a computational strategy for identifying the primary origin of - cancers using high-thoroughput sequencing}. Bioinformatics 2009, 25:2882-2889 - \url{http://bioinformatics.oxfordjournals.org/content/25/21/2882}. -} -\author{ -%% ~~who you are~~ -} -\note{ -The original functions in the \code{ISOpureR} package input data at the raw scale (i.e. 2^x) and return the estimated profiles also at the raw scale. Our integrated function takes care the data transformation internally, so that it inputs and returns data at the log2-transformed scale, keeping consistancy with other functions in our package. -} - -\section{Warning }{ -Use \code{warnings()} to see warnings. Warnings are expected in \code{ISOpureR} from the optimization calculations. -} - -\seealso{ -\code{\link[ISOpureR]{ISOpure.step1.CPE}} and \code{\link[ISOpureR]{ISOpure.step2.PPE}} from the \code{ISOpureR} package. -} -\examples{ -## Firstly, let's generate some data. -set.seed(999) -data("celltype") -mu.T <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="ASM")]] -mu.N <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="AEC")]] -## number of samples to simulate -n.samp <- 5 -## parameters for correlation design of cell type T -rho <- c(0.9,0.8,0.7) -block.size <- c(5,10,15) -str.type <- c("interchangeable","decaying","star") -## one-step simulation -out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, rho=rho, block.size=block.size, str.type=str.type) - -## Deconvolution. Pure samples for cell type N is used as reference. -\dontrun{ -out.deconv <- deconv(mixed=out.oneStepSim$expr.mixed, ref=out.oneStepSim$expr.pure.N) -} - -} -% Add one or more standard keywords, see file 'KEYWORDS' in the -% R documentation directory. -\keyword{ methods }% use one of RShowDoc("KEYWORDS") +\name{deconv} +\alias{deconv} +%- Also NEED an '\alias' for EACH other topic documented here. +\title{ +Deconvolution +} +\description{ +An integrated function for deconvolution of mixed cell-type samples, based on the \code{ISOpureR} package. +} +\usage{ +deconv(mixed, ref, seed=123, ...) +} +%- maybe also 'usage' for other objects documented here. +\arguments{ + \item{mixed}{data matrix (at the log2-transformed scale) for mixed samples, with genes in rows and samples in columns.} + \item{ref}{data matrix (at the log2-transformed scale) for reference samples, with genes in rows and samples in columns.} + \item{seed}{random seed for reproducible result.} + \item{...}{arguments passed to \code{ISOpure.step1.CPE()}.} +} +\value{ +A list of the following components: + \item{expr.deconv}{estimated expression profiles (at the log2-transformed scale) for the targeted pure samples after deconvolution.} + \item{est.prop}{estimated mixing proportions for the targeted pure samples.} + +} +\references{ + G Quon, S Haider, AG Deshwar, A Cui, PC Boutros, QD Morris. \emph{Computational purification of + individual tumor gene expression profiles}. Genome Medicine (2013) 5:29, + \url{http://genomemedicine.com/content/5/3/29}. + + G Quon, QD Morris. \emph{ISOLATE: a computational strategy for identifying the primary origin of + cancers using high-thoroughput sequencing}. Bioinformatics 2009, 25:2882-2889 + \url{http://bioinformatics.oxfordjournals.org/content/25/21/2882}. +} +\note{ +The original functions in the \code{ISOpureR} package input data at the raw scale (i.e. 2^x) and return the estimated profiles also at the raw scale. Our integrated function takes care the data transformation internally, so that it inputs and returns data at the log2-transformed scale, keeping consistancy with other functions in our package. +} + +\section{Warning }{ +Use \code{warnings()} to see warnings. Warnings are expected in \code{ISOpureR} from the optimization calculations. +} + +\seealso{ +\code{\link[ISOpureR]{ISOpure.step1.CPE}} and \code{\link[ISOpureR]{ISOpure.step2.PPE}} from the \code{ISOpureR} package. +} +\examples{ +## Firstly, let's generate some data. +set.seed(999) +data("celltype") +mu.T <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="ASM")]] +mu.N <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="AEC")]] +## number of samples to simulate +n.samp <- 5 +## parameters for correlation design of cell type T +rho <- c(0.9,0.8,0.7) +block.size <- c(5,10,15) +str.type <- c("interchangeable","decaying","star") +## one-step simulation +out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, rho=rho, block.size=block.size, str.type=str.type) + +## Deconvolution. Pure samples for cell type N is used as reference. +\dontrun{ +out.deconv <- deconv(mixed=out.oneStepSim$expr.mixed, ref=out.oneStepSim$expr.pure.N) +} + +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{ methods }% use one of RShowDoc("KEYWORDS") diff --git a/man/eval.ROC.Rd b/man/eval.ROC.Rd index 72cdd00..fed4caa 100644 --- a/man/eval.ROC.Rd +++ b/man/eval.ROC.Rd @@ -8,7 +8,7 @@ Evaluate ROC and AUC This function performs ROC analysis for network estimation based on the \code{ROCR} package. } \usage{ -eval.ROC(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=TRUE, ...) +eval.ROC(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=FALSE, lightPDF=FALSE, ...) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -16,12 +16,11 @@ eval.ROC(est.str, true.str, plot.ROC=TRUE, show.AUC=TRUE, zoom=TRUE, ...) \item{true.str}{symmetric matrix or array of symmetric matrices of true structure, usually with binary elements of 1 = edge and 0 = no edge. It should have the same dimension as \code{est.str}.} \item{plot.ROC}{logical value indicating if to plot the ROC curve. Default: \code{TRUE}.} \item{show.AUC}{logical value indicating if to show AUC on the plot. Default: \code{TRUE}.} - \item{zoom}{logical value indicating if to zoom-in the plot. Default: \code{TRUE}.} + \item{zoom}{logical value indicating if to zoom-in the plot. Default: \code{FALSE}.} + \item{lightPDF}{logical value indicating if to subsample points for plotting in a PDF. Default: \code{FALSE}.} \item{...}{arguments passed to \code{plot()}.} } -\details{ -%% ~~ If necessary, more details than the description above ~~ -} + \value{ A list with the following components: \item{perf}{object of \code{performence-class}.} @@ -29,21 +28,10 @@ A list with the following components: \item{xval}{maximum value plotted in the x-axis.} \item{yval}{maximum value plotted in the y-axis.} } -\references{ -%% ~put references to the literature/web site here ~ -} -\author{ -%% ~~who you are~~ -} -\note{ -%% ~~further notes~~ -} %% ~Make other sections like Warning with \section{Warning }{....} ~ -\seealso{ -\code{\link[ROCR]{performence-class}} from the \code{ROCR} package. -} + \examples{ ## Firstly, let's generate some data. set.seed(999) diff --git a/man/generate.Sigma.Rd b/man/generate.Sigma.Rd index d2fd597..3e92a87 100644 --- a/man/generate.Sigma.Rd +++ b/man/generate.Sigma.Rd @@ -8,7 +8,7 @@ Generate covariance matrix This function generates a matrix with block-wise customized structure. } \usage{ -generate.Sigma(m.gene, block.size, rho, dd=NULL, str.type="interchangeable", multiplier=1) +generate.Sigma(m.gene, block.size, rho, dd=NULL, str.type="interchangeable") } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -18,29 +18,13 @@ generate.Sigma(m.gene, block.size, rho, dd=NULL, str.type="interchangeable", mul \item{dd}{diagnal entries of the weight matrix. It should have length equal to \code{m.gene}. If \code{NULL}, all 1's will be assigned.} \item{str.type}{types of block structure. Options: \code{"interchangeable"} (default) assumes an interchangeable correlation in the block; \code{"decaying"} is an AR(1) model; \code{"star"} gives a star-shape structure. It can also be a vector of mixed types, but should have the same length as \code{rho}.} } -\details{ -%% ~~ If necessary, more details than the description above ~~ -} + \value{ A list with the following components: \item{Sigma}{a covariance matrix with customized structure.} \item{true.str}{true structure in generated \code{Sigma}. A matrix with 0 (no structure) and 1 (an edge).} } -\references{ -%% ~put references to the literature/web site here ~ -} -\author{ -%% ~~who you are~~ -} -\note{ -%% ~~further notes~~ -} - -%% ~Make other sections like Warning with \section{Warning }{....} ~ -\seealso{ -%% ~~objects to See Also as \code{\link{help}}, ~~~ -} \examples{ ## a correlation matrix with three designed blocks Sigma.str1 <- generate.Sigma(m.gene=35, block.size=c(5,10,15), rho=c(0.9,0.8,0.7), diff --git a/man/netEstByMethod.Rd b/man/netEstByMethod.Rd deleted file mode 100644 index 5b6be0f..0000000 --- a/man/netEstByMethod.Rd +++ /dev/null @@ -1,57 +0,0 @@ -\name{netEstByMethod} -\alias{netEstByMethod} -%- Also NEED an '\alias' for EACH other topic documented here. -\title{ -Network estimation function -} -\description{ -This function takes simulated data and estimates network based on WGCNA (correlation-based), ARACNE (mutual information-based) or Bayesian algorithms. -} -\usage{ -netEstByMethod(data.list, method, softPower=1) -} -\arguments{ - \item{data.list}{a list of simulated data, e.g. \code{list(data.pure, data.mixed, data.deconvoluted)}. The output of this function will be a list of estimated networks of the same order.} - \item{method}{method used to estimate network. Options: \code{WGCNA} is correlation-based, \code{ARACNE} is mutual information-base, \code{Bayesian} is Bayesian network, and \code{GLASSO}.} - \item{softPower}{soft power used in WGCNA. Default: \code{softPower=1}.} -} -\details{ -This function uses \code{adjacency()} for \code{method="WGCNA"}, \code{minet()} for \code{method="ARACNE"}, \code{hc(),bn.fit()} for \code{method="Bayesian"}, and simply \code{var()} for \code{method="GLASSO"} for network estimation. -} -\value{ -This function returns a list of estimated networks, coresponding to the input data list. -} -\references{ -%% ~put references to the literature/web site here ~ -} -\author{ -%% ~~who you are~~ -} -\note{ -%% ~~further notes~~ -} - -%% ~Make other sections like Warning with \section{Warning }{....} ~ - -\seealso{ -%% ~~objects to See Also as \code{\link{help}}, ~~~ -} - -\examples{ -\dontrun{ -## simulated data -data.list <- list(out.oneStepSim$expr.pure.T, out.oneStepSim$expr.mixed, out.deconv$expr.deconv) -names(data.list) <- c("pure", "mixed", "deconvoluted") - -## one step analysis -net.WGCNA <- netEstByMethod(data.list, method="WGCNA") -net.ARACNE <- netEstByMethod(data.list, method="ARACNE") -net.Bayesian <- netEstByMethod(data.list, method="Bayesian") -net.GLASSO <- netEstByMethod(data.list, method="GLASSO") -} -} - -% Add one or more standard keywords, see file 'KEYWORDS' in the -% R documentation directory. -\keyword{ methods }% use one of RShowDoc("KEYWORDS") - diff --git a/man/oneStepSim.Rd b/man/oneStepSim.Rd index 73d2164..d4d004d 100644 --- a/man/oneStepSim.Rd +++ b/man/oneStepSim.Rd @@ -44,15 +44,7 @@ A list with the following components: \item{expr.mixed}{expression matrix for mixed cell types.} \item{prop.T}{true proportions of cell type T in mixed samples.} } -\references{ -%% ~put references to the literature/web site here ~ -} -\author{ -%% ~~who you are~~ -} -\note{ -%% ~~further notes~~ -} + %% ~Make other sections like Warning with \section{Warning }{....} ~ @@ -84,15 +76,10 @@ prop.T <- runif(n.samp) ## one-step simulation out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T=prop.T, - # structure for Sigma.T - dd=NULL, rho=rho, block.size=block.size, str.type=str.type, - # selected genes to add structure - select.gene=select.gene) - -## If Sigma.T and Sigma.N are given as identity matrices, and use default mixing proportions -out.oneStepSim2 <- oneStepSim(n.samp, mu.T, mu.N, Sigma.T=diag(length(mu.T)), Sigma.N=diag(length(mu.N))) -## the default mixing proportions for cell type T -out.oneStepSim2$prop.T + # structure for Sigma.T + dd=NULL, rho=rho, block.size=block.size, str.type=str.type, + # selected genes to add structure + select.gene=select.gene) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. diff --git a/man/runShiny.Rd b/man/runShiny.Rd new file mode 100644 index 0000000..53b3d2f --- /dev/null +++ b/man/runShiny.Rd @@ -0,0 +1,14 @@ +\name{runShiny} +\alias{runShiny} +%- Also NEED an '\alias' for EACH other topic documented here. +\title{ +Launch Shiny application +} +\description{ +This function lauches Shiny application for this package. +} +\usage{ +runShiny() +} + +\keyword{ dplot }% use one of RShowDoc("KEYWORDS") diff --git a/man/sim.expr.Rd b/man/sim.expr.Rd index 7f6ad56..811bc68 100644 --- a/man/sim.expr.Rd +++ b/man/sim.expr.Rd @@ -31,15 +31,7 @@ A list with the following components: \item{expr.mixed}{expression matrix for mixed cell types.} } -\references{ -%% ~put references to the literature/web site here ~ -} -\author{ -%% ~~who you are~~ -} -\note{ -%% ~~further notes~~ -} + %% ~Make other sections like Warning with \section{Warning }{....} ~ @@ -67,7 +59,7 @@ str.type <- c("interchangeable","decaying","star") prop.T <- seq(0, 1, length=n.samp) ## generate covariance matrices -out.Sigma.T <- generate.Sigma(m.gene=m.gene, dd=rep(1,m.gene), rho=rho, block.size=block.size, str.type=str.type, multiplier=multiplier) +out.Sigma.T <- generate.Sigma(m.gene=m.gene, dd=rep(1,m.gene), rho=rho, block.size=block.size, str.type=str.type) Sigma.T <- out.Sigma.T$Sigma Sigma.N <- diag(m.gene) # identity matrix diff --git a/vignettes/Shiny-steps.pdf b/vignettes/Shiny-steps.pdf new file mode 100644 index 0000000..32bbd0e Binary files /dev/null and b/vignettes/Shiny-steps.pdf differ diff --git a/vignettes/Shiny-steps.png b/vignettes/Shiny-steps.png new file mode 100644 index 0000000..ea39860 Binary files /dev/null and b/vignettes/Shiny-steps.png differ diff --git a/vignettes/simDeNet.Rmd b/vignettes/simDeNet.Rmd index c643cf5..17708ef 100644 --- a/vignettes/simDeNet.Rmd +++ b/vignettes/simDeNet.Rmd @@ -1,5 +1,5 @@ --- -title: "Vignette for simDeNet" +title: "Simulation Study Using 'simDeNet'" author: "Yun Zhang" date: "`r Sys.Date()`" output: rmarkdown::html_vignette @@ -9,36 +9,52 @@ vignette: > %\VignetteEncoding{UTF-8} --- -# Introduction +This package documents the functions for reproducing the simualation study for cell type mixture and deconvolution using pure cell type. Co-expression is evaluated based on absolute value of Pearson correlation. -```{r, package} -## The package can be installed using the following code -# library(devtools) -# install_github("yunzhang813/???", build_vignettes=TRUE) +## Installation + +This package can be installed from the GitHub repository using the following code. +```{r, installation, eval=FALSE} +library(devtools) +install_github("yunzhang813/simDeNet-R-Package-Shiny", build_vignettes=TRUE) +``` -## Load the package +Load the package. +```{r, package} library(simDeNet) ``` -# Sample data +## Shiny application + +To lauch the Shiny application, please use the following code. + +```{r, shiny, eval=FALSE} +runShiny() +``` + +Follow the steps below to run your own simulation study of cell type mixture. + +![Steps to run Shiny app.](Shiny-steps.png){width=600px} +The Shiny only app shows pure and mixed samples. Due to computational cost, interested users may follow this vignette and use the `deconv()` function from this package to get the deconvolution results by 'ISOpureR'. + +## One-step simulation + +Load the working dataset for this vignette. More information see `help("celltype")`. ```{r, data, cache=TRUE} data("celltype") ``` -# One-step simulation +Set parameters, and generage simulated dataset. ```{r, sim, cache=TRUE} ## get two cell types mu.T <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="ASM")]] mu.N <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="AEC")]] ## parameters -n.samp <- 5 -rho <- c(0.9,0.8,0.7) -block.size <- c(5,10,15) -dd <- NULL -str.type <- "interchangeable" -multiplier <- 1 +n.samp <- 20 +rho <- c(0.7,0.7,0.7) +block.size <- c(30,30,30) select.gene <- "random" ## mixing proportion of cell type T @@ -48,111 +64,37 @@ prop.T <- seq(0, 1, length=n.samp) set.seed(999) out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T=prop.T, # structure for Sigma.T - block.size=block.size, rho=rho, dd=dd, str.type=str.type, multiplier=1, + block.size=block.size, rho=rho, dd=NULL, str.type="interchangeable", # selected genes to add structure select.gene=select.gene) ``` -# Deconvolution +## Deconvolution +'ISOpureR' deconvolution is customized here. This step may take time (YMMV). ```{r, deconv, cache=TRUE, warning=FALSE, results="hide"} ## deconvolution -tt <- system.time(out.deconv <- deconv(mixed=out.oneStepSim$expr.mixed, ref=out.oneStepSim$expr.pure.N)) +out.deconv <- deconv(mixed=out.oneStepSim$expr.mixed, ref=out.oneStepSim$expr.pure.N) ``` -# Correlation-based network +## ROC plot -## One-step analysis for WGCNA -```{r, onestep-wgcna, cache=TRUE, results="hide", message=FALSE, fig.align="center", fig.height=5, fig.width=5, fig.retina=2} -## simulated data -data.list <- list(out.oneStepSim$expr.pure.T, out.oneStepSim$expr.mixed, out.deconv$expr.deconv) -names(data.list) <- c("pure","mixed","deconvoluted") -## ture structure +Calculate absolute value of Pearson correlation, and plot the ROC curves. +```{r, plot, cache=TRUE, fig.align="center", fig.width=5, fig.height=5} +## true structure true.str <- out.oneStepSim$true.str.T -## one step analysis -out.WGCNA <- oneStepAnalysis(data.list,true.str,method="WGCNA") - -## plot ROC curves -plot(out.WGCNA$pure$perf, lwd=2) -plot(out.WGCNA$mixed$perf, add=TRUE, col=2, lwd=2) -plot(out.WGCNA$deconvoluted$perf, add=TRUE, col=3, lwd=2) -legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.WGCNA$pure$AUC, out.WGCNA$mixed$AUC, out.WGCNA$deconvoluted$AUC),3)), col=1:3, lty=1, lwd=5) -title(paste("WGCNA")) -``` - - -## Step-by-step analysis for WGCNA - -### Network estimation -```{r, wgcna, cache=TRUE, results="hide"} -library(WGCNA) -## If softPower = 1, the adjacency matrix is simply the absolute correlation matrix -softPower <- 1 -## pure samples -datExpr.pure <- as.data.frame(t(out.oneStepSim$expr.pure.T)) # NOTE: rows=samples, columns=genes -est.str.pure <- adjacency(datExpr.pure, power = softPower) -## mixed samples -datExpr.mixed <- as.data.frame(t(out.oneStepSim$expr.mixed)) # NOTE: rows=samples, columns=genes -est.str.mixed <- adjacency(datExpr.mixed, power = softPower) -## deconvoluted samples -datExpr.deconv <- as.data.frame(t(out.deconv$expr.deconv)) # NOTE: rows=samples, columns=genes -est.str.deconv <- adjacency(datExpr.deconv, power = softPower) -``` - -### ROC analysis -```{r, roc-wgcna, cache=FALSE, message=FALSE, fig.align="center", fig.height=5, fig.width=5, fig.retina=2} -## evaluate ROC and AUC -out.ROC.pure <- eval.ROC(est.str=est.str.pure, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, main="Pure samples") -out.ROC.mixed <- eval.ROC(est.str=est.str.mixed, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, col=2, main="Mixed samples") -out.ROC.deconv <- eval.ROC(est.str=est.str.deconv, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, col=3, main="Deconvoluted samples") - -## combined plot -library(ROCR) -plot(out.ROC.pure$perf, lwd=2) -plot(out.ROC.mixed$perf, add=TRUE, col=2, lwd=2) -plot(out.ROC.deconv$perf, add=TRUE, col=3, lwd=2) -legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.ROC.pure$AUC, out.ROC.mixed$AUC, out.ROC.deconv$AUC),3)), col=1:3, lty=1, lwd=5) -title(paste("WGCNA", paste0("S",n.samp), str.type, select.gene, sep = ", ")) -abline(0,1,col="grey") -``` - -# Other networks - -## Mutual information network - -### Network estimation -```{r, aracne, cache=TRUE, results="hide"} -library(minet) - -## pure tumor samples -net.pure <- minet(datExpr.pure, method = "aracne") -## mixed samples -net.mixed <- minet(datExpr.mixed, method = "aracne") -## ISOpure tumor samples -net.deconv <- minet(datExpr.deconv, method = "aracne") -``` - -### ROC analysis -```{r, roc-aracne, cache=TRUE, fig.align="center", fig.height=5, fig.width=5, fig.retina=2} -## evaluate ROC and AUC -out.ROC.pure <- eval.ROC(est.str=net.pure, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, main="Pure samples") -out.ROC.mixed <- eval.ROC(est.str=net.mixed, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, main="Mixed samples", col=2) -out.ROC.deconv <- eval.ROC(est.str=net.deconv, true.str=out.oneStepSim$true.str.T, - plot.ROC=TRUE, main="Deconvoluted samples", col=3) - -## combined plot -plot(out.ROC.pure$perf, - # xlim=c(0,max(out.ROC.pure$xval,out.ROC.mixed$xval,out.ROC.deconv$xval)), - # ylim=c(0,max(out.ROC.pure$yval,out.ROC.mixed$yval,out.ROC.deconv$yval)), - lwd=2) -plot(out.ROC.mixed$perf, lwd=2, add=TRUE, col=2) -plot(out.ROC.deconv$perf, lwd=2, add=TRUE, col=3) -legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.ROC.pure$AUC, out.ROC.mixed$AUC, out.ROC.deconv$AUC),3)), col=1:3, lwd=5) -title(paste("ARACNE", paste0("S",n.samp), str.type, select.gene, sep = ", ")) +## correlation estimations +acor <- function(x){abs(cor(t(x)))} +acor.pure <- acor(out.oneStepSim$expr.pure.T) +acor.mixed <- acor(out.oneStepSim$expr.mixed) +acor.deconv <- acor(out.deconv$expr.deconv) + +## plot +cbPalette <- c("#999999", "#E69F00", "#56B4E9") +temp1 <- eval.ROC(est.str=acor.pure, true.str=true.str, plot.ROC=TRUE, show.AUC=FALSE, lwd=2, col=cbPalette[1]) +temp2 <- eval.ROC(est.str=acor.mixed, true.str=true.str, plot.ROC=TRUE, show.AUC=FALSE, add=TRUE, col=cbPalette[2], lwd=2) +temp3 <- eval.ROC(est.str=acor.deconv, true.str=true.str, plot.ROC=TRUE, show.AUC=FALSE, add=TRUE, col=cbPalette[3], lwd=2) +abline(0, 1, lty=3, lwd=2) +legend("bottomright", paste0(c("pure","mixed","deconv"), ": AUC = ", round(c(temp1$AUC, temp2$AUC, temp3$AUC),3)), col=cbPalette[1:3], lty=1, lwd=5, bty="n") ``` diff --git a/vignettes/simDeNet.html b/vignettes/simDeNet.html index 9af4842..eb37c44 100644 --- a/vignettes/simDeNet.html +++ b/vignettes/simDeNet.html @@ -4,7 +4,7 @@ - + @@ -12,54 +12,287 @@ - + -Vignette for simDeNet +Simulation Study Using ‘simDeNet’ - + + + + + - @@ -68,158 +301,84 @@ -

Vignette for simDeNet

-

Yun Zhang

-

2017-02-07

- +

Simulation Study Using ‘simDeNet’

+

Yun Zhang

+

2019-04-22

-
-

Introduction

-
## The package can be installed using the following code
-# library(devtools)
-# install_github("yunzhang813/???", build_vignettes=TRUE)
 
-## Load the package
-library(simDeNet)
-
## 
-
-
-

Sample data

-
data("celltype")
-
-
-

One-step simulation

-
## get two cell types
-mu.T <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="ASM")]]
-mu.N <- expr[,ctab$Fastq_file_name[which(ctab$X3_letter_code=="AEC")]]
-
-## parameters
-n.samp <- 5
-rho <- c(0.9,0.8,0.7)
-block.size <- c(5,10,15)
-dd <- NULL
-str.type <- "interchangeable"
-multiplier <- 1
-select.gene <- "random"
-
-## mixing proportion of cell type T
-prop.T <- seq(0, 1, length=n.samp)
-
-## one-step simulation
-set.seed(999)
-out.oneStepSim <- oneStepSim(n.samp, mu.T, mu.N, Sigma.T=NULL, Sigma.N=NULL, prop.T=prop.T, 
-                      # structure for Sigma.T
-                      block.size=block.size, rho=rho, dd=dd, str.type=str.type, multiplier=1,
-                      # selected genes to add structure
-                      select.gene=select.gene)
-
-
-

Deconvolution

-
## deconvolution
-tt <- system.time(out.deconv <- deconv(mixed=out.oneStepSim$expr.mixed, ref=out.oneStepSim$expr.pure.N))
-
-
-

Correlation-based network

-
-

One-step analysis for WGCNA

-
## simulated data
-data.list <- list(out.oneStepSim$expr.pure.T, out.oneStepSim$expr.mixed, out.deconv$expr.deconv)
-names(data.list) <- c("pure","mixed","deconvoluted")
-## ture structure
-true.str <- out.oneStepSim$true.str.T
-
-## one step analysis
-out.WGCNA <- oneStepAnalysis(data.list,true.str,method="WGCNA")
-
-## plot ROC curves
-plot(out.WGCNA$pure$perf, lwd=2)
-plot(out.WGCNA$mixed$perf, add=TRUE, col=2, lwd=2)
-plot(out.WGCNA$deconvoluted$perf, add=TRUE, col=3, lwd=2)
-legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.WGCNA$pure$AUC, out.WGCNA$mixed$AUC, out.WGCNA$deconvoluted$AUC),3)), col=1:3, lty=1, lwd=5)
-title(paste("WGCNA"))
-

-
-
-

Step-by-step analysis for WGCNA

-
-

Network estimation

-
library(WGCNA)
-## If softPower = 1, the adjacency matrix is simply the absolute correlation matrix
-softPower <- 1
-## pure samples
-datExpr.pure <- as.data.frame(t(out.oneStepSim$expr.pure.T)) # NOTE: rows=samples, columns=genes
-est.str.pure <- adjacency(datExpr.pure, power = softPower)
-## mixed samples
-datExpr.mixed <- as.data.frame(t(out.oneStepSim$expr.mixed)) # NOTE: rows=samples, columns=genes
-est.str.mixed <- adjacency(datExpr.mixed, power = softPower)
-## deconvoluted samples
-datExpr.deconv <- as.data.frame(t(out.deconv$expr.deconv)) # NOTE: rows=samples, columns=genes
-est.str.deconv <- adjacency(datExpr.deconv, power = softPower)
-
-
-

ROC analysis

-
## evaluate ROC and AUC
-out.ROC.pure <- eval.ROC(est.str=est.str.pure, true.str=out.oneStepSim$true.str.T, 
-                         plot.ROC=TRUE, main="Pure samples")
-

-
out.ROC.mixed <- eval.ROC(est.str=est.str.mixed, true.str=out.oneStepSim$true.str.T,
-                          plot.ROC=TRUE, col=2, main="Mixed samples")
-

-
out.ROC.deconv <- eval.ROC(est.str=est.str.deconv, true.str=out.oneStepSim$true.str.T,
-                           plot.ROC=TRUE, col=3, main="Deconvoluted samples")
-

-
## combined plot
-library(ROCR)
-plot(out.ROC.pure$perf, lwd=2)
-plot(out.ROC.mixed$perf, add=TRUE, col=2, lwd=2)
-plot(out.ROC.deconv$perf, add=TRUE, col=3, lwd=2)
-legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.ROC.pure$AUC, out.ROC.mixed$AUC, out.ROC.deconv$AUC),3)), col=1:3, lty=1, lwd=5)
-title(paste("WGCNA", paste0("S",n.samp), str.type, select.gene, sep = ", "))
-abline(0,1,col="grey")
-

-
+

This package documents the functions for reproducing the simualation study for cell type mixture and deconvolution using pure cell type. Co-expression is evaluated based on absolute value of Pearson correlation.

+
+

Installation

+

This package can be installed from the GitHub repository using the following code.

+ +

Load the package.

+
+
+

Shiny application

+

To lauch the Shiny application, please use the following code.

+ +

Follow the steps below to run your own simulation study of cell type mixture.

+
+Steps to run Shiny app. +

Steps to run Shiny app.

-
-

Other networks

-
-

Mutual information network

-
-

Network estimation

-
library(minet)
-
-## pure tumor samples
-net.pure <- minet(datExpr.pure, method = "aracne")
-## mixed samples
-net.mixed <- minet(datExpr.mixed, method = "aracne")
-## ISOpure tumor samples
-net.deconv <- minet(datExpr.deconv, method = "aracne")
+

The Shiny only app shows pure and mixed samples. Due to computational cost, interested users may follow this vignette and use the deconv() function from this package to get the deconvolution results by ‘ISOpureR’.

-
-

ROC analysis

-
## evaluate ROC and AUC
-out.ROC.pure <- eval.ROC(est.str=net.pure, true.str=out.oneStepSim$true.str.T, 
-                         plot.ROC=TRUE, main="Pure samples")
-

-
out.ROC.mixed <- eval.ROC(est.str=net.mixed, true.str=out.oneStepSim$true.str.T, 
-                          plot.ROC=TRUE, main="Mixed samples", col=2)
-

-
out.ROC.deconv <- eval.ROC(est.str=net.deconv, true.str=out.oneStepSim$true.str.T, 
-                           plot.ROC=TRUE, main="Deconvoluted samples", col=3)
-

-
## combined plot
-plot(out.ROC.pure$perf,
-     # xlim=c(0,max(out.ROC.pure$xval,out.ROC.mixed$xval,out.ROC.deconv$xval)),
-     # ylim=c(0,max(out.ROC.pure$yval,out.ROC.mixed$yval,out.ROC.deconv$yval)),
-     lwd=2)
-plot(out.ROC.mixed$perf, lwd=2, add=TRUE, col=2)
-plot(out.ROC.deconv$perf, lwd=2, add=TRUE, col=3)
-legend("bottomright", paste(c("pure","mixed","deconv"), ": AUC =", round(c(out.ROC.pure$AUC, out.ROC.mixed$AUC, out.ROC.deconv$AUC),3)), col=1:3, lwd=5)
-title(paste("ARACNE", paste0("S",n.samp), str.type, select.gene, sep = ", "))
-

+ +
+

Deconvolution

+

‘ISOpureR’ deconvolution is customized here. This step may take time (YMMV).

+
+ @@ -229,7 +388,7 @@

ROC analysis

(function () { var script = document.createElement("script"); script.type = "text/javascript"; - script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; + script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; document.getElementsByTagName("head")[0].appendChild(script); })(); diff --git a/vignettes/simDeNet_cache/html/__packages b/vignettes/simDeNet_cache/html/__packages index cd3577e..7be9410 100644 --- a/vignettes/simDeNet_cache/html/__packages +++ b/vignettes/simDeNet_cache/html/__packages @@ -1,8 +1,2 @@ base simDeNet -dynamicTreeCut -fastcluster -WGCNA -gplots -ROCR -minet diff --git a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.RData b/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.RData deleted file mode 100644 index b981bae..0000000 Binary files a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdb b/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdb deleted file mode 100644 index 9cd19dd..0000000 Binary files a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdx b/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdx deleted file mode 100644 index c610f07..0000000 Binary files a/vignettes/simDeNet_cache/html/aracne_9f7a6fc054736d95c092289f58511988.rdx and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.RData b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.RData index 2a8d911..b78dbaf 100644 Binary files a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.RData and b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.RData differ diff --git a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdb b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdb index 91eb90d..005c2da 100644 Binary files a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdb and b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdb differ diff --git a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdx b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdx index 2da547b..0831bae 100644 Binary files a/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdx and b/vignettes/simDeNet_cache/html/data_5445f79415040d12923c4de59d7467f7.rdx differ diff --git a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.RData b/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.RData deleted file mode 100644 index 10e4ae4..0000000 Binary files a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdb b/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdb deleted file mode 100644 index facd740..0000000 Binary files a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdx b/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdx deleted file mode 100644 index 1c1df4c..0000000 Binary files a/vignettes/simDeNet_cache/html/deconv_4828faa17eea51efe6781aad9060e778.rdx and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.RData b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.RData new file mode 100644 index 0000000..868022d Binary files /dev/null and b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.RData differ diff --git a/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdb b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdb new file mode 100644 index 0000000..7cf8f12 Binary files /dev/null and b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdb differ diff --git a/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdx b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdx new file mode 100644 index 0000000..f1f92af Binary files /dev/null and b/vignettes/simDeNet_cache/html/deconv_d4cf9f57c5142d311199a5233ff8ee55.rdx differ diff --git a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.RData b/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.RData deleted file mode 100644 index c2b5a7b..0000000 Binary files a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdb b/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdb deleted file mode 100644 index e92557d..0000000 Binary files a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdx b/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdx deleted file mode 100644 index 9cbedfe..0000000 Binary files a/vignettes/simDeNet_cache/html/onestep-wgcna_1af10a198396f4a1ef7fa69ea2332160.rdx and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.RData b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.RData new file mode 100644 index 0000000..8eee677 Binary files /dev/null and b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.RData differ diff --git a/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdb b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdb new file mode 100644 index 0000000..d1e8a80 Binary files /dev/null and b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdb differ diff --git a/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdx b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdx new file mode 100644 index 0000000..ac9bb21 Binary files /dev/null and b/vignettes/simDeNet_cache/html/plot_eec52e184bc1d11f8550f5200747dfe3.rdx differ diff --git a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.RData b/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.RData deleted file mode 100644 index 7a15ec4..0000000 Binary files a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdb b/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdb deleted file mode 100644 index ae076e7..0000000 Binary files a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdx b/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdx deleted file mode 100644 index ff4b3bc..0000000 Binary files a/vignettes/simDeNet_cache/html/roc-aracne_917ba4a9b8e4dda9dfa29f170c5a51ef.rdx and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.RData b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.RData new file mode 100644 index 0000000..a7e4f04 Binary files /dev/null and b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.RData differ diff --git a/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdb b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdb new file mode 100644 index 0000000..0e5ea49 Binary files /dev/null and b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdb differ diff --git a/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdx b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdx new file mode 100644 index 0000000..8c9f427 Binary files /dev/null and b/vignettes/simDeNet_cache/html/sim_607388e3098ae87293ae08e27d6b9173.rdx differ diff --git a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.RData b/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.RData deleted file mode 100644 index 9cf29ab..0000000 Binary files a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdb b/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdb deleted file mode 100644 index e38953c..0000000 Binary files a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdx b/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdx deleted file mode 100644 index cb84738..0000000 Binary files a/vignettes/simDeNet_cache/html/sim_bc8327d010ec46489ed5fe36d576451c.rdx and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.RData b/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.RData deleted file mode 100644 index 23ce544..0000000 Binary files a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.RData and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdb b/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdb deleted file mode 100644 index e2eb9a9..0000000 Binary files a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdb and /dev/null differ diff --git a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdx b/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdx deleted file mode 100644 index d0768ca..0000000 Binary files a/vignettes/simDeNet_cache/html/wgcna_c91cf79f4c951cbbf996a65608fab824.rdx and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/onestep-wgcna-1.png b/vignettes/simDeNet_files/figure-html/onestep-wgcna-1.png deleted file mode 100644 index 81d8377..0000000 Binary files a/vignettes/simDeNet_files/figure-html/onestep-wgcna-1.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/plot-1.png b/vignettes/simDeNet_files/figure-html/plot-1.png new file mode 100644 index 0000000..6a1c3e1 Binary files /dev/null and b/vignettes/simDeNet_files/figure-html/plot-1.png differ diff --git a/vignettes/simDeNet_files/figure-html/roc-aracne-1.png b/vignettes/simDeNet_files/figure-html/roc-aracne-1.png deleted file mode 100644 index e7cabee..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-aracne-1.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-aracne-2.png b/vignettes/simDeNet_files/figure-html/roc-aracne-2.png deleted file mode 100644 index 5d44cd3..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-aracne-2.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-aracne-3.png b/vignettes/simDeNet_files/figure-html/roc-aracne-3.png deleted file mode 100644 index b1c8a08..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-aracne-3.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-aracne-4.png b/vignettes/simDeNet_files/figure-html/roc-aracne-4.png deleted file mode 100644 index cef2f45..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-aracne-4.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-wgcna-1.png b/vignettes/simDeNet_files/figure-html/roc-wgcna-1.png deleted file mode 100644 index e609253..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-wgcna-1.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-wgcna-2.png b/vignettes/simDeNet_files/figure-html/roc-wgcna-2.png deleted file mode 100644 index eea5541..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-wgcna-2.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-wgcna-3.png b/vignettes/simDeNet_files/figure-html/roc-wgcna-3.png deleted file mode 100644 index 66dc542..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-wgcna-3.png and /dev/null differ diff --git a/vignettes/simDeNet_files/figure-html/roc-wgcna-4.png b/vignettes/simDeNet_files/figure-html/roc-wgcna-4.png deleted file mode 100644 index aba112f..0000000 Binary files a/vignettes/simDeNet_files/figure-html/roc-wgcna-4.png and /dev/null differ