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.

library(devtools)
install_github("yunzhang813/simDeNet-R-Package-Shiny", build_vignettes=TRUE)

Load the package.

library(simDeNet)

Shiny application

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

runShiny()

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

Steps to run Shiny app.{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").

data("celltype")

Set parameters, and generage simulated dataset.

## 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 <- 20
rho <- c(0.7,0.7,0.7)
block.size <- c(30,30,30)
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=NULL, str.type="interchangeable",
                      # selected genes to add structure
                      select.gene=select.gene)

Deconvolution

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

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

ROC plot

Calculate absolute value of Pearson correlation, and plot the ROC curves.

## true structure
true.str <- out.oneStepSim$true.str.T

## 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")


yunzhang813/simDeNet-R-Package documentation built on Dec. 24, 2019, 3:02 p.m.