# NOT RUN {
# Built-in simulated dataset
Data = makeExampleBASiCS_Data()
# Only a short run of the MCMC algorithm for illustration purposes
# Longer runs migth be required to reach convergence
MCMC_Output <- BASiCS_MCMC(Data, N = 10000, Thin = 10, Burn = 5000, PrintProgress = FALSE)
head(displayChainBASiCS(MCMC_Output, Param = "mu"))
head(displayChainBASiCS(MCMC_Output, Param = "delta"))
head(displayChainBASiCS(MCMC_Output, Param = "phi"))
head(displayChainBASiCS(MCMC_Output, Param = "s"))
head(displayChainBASiCS(MCMC_Output, Param = "nu"))
head(displayChainBASiCS(MCMC_Output, Param = "theta"))
# Traceplots
plot(MCMC_Output, Param = "mu", Gene = 1)
plot(MCMC_Output, Param = "delta", Gene = 1)
plot(MCMC_Output, Param = "phi", Cell = 1)
plot(MCMC_Output, Param = "s", Cell = 1)
plot(MCMC_Output, Param = "nu", Cell = 1)
plot(MCMC_Output, Param = "theta", Batch = 1)
# Calculating posterior medians and 95% HPD intervals
MCMC_Summary <- Summary(MCMC_Output)
head(displaySummaryBASiCS(MCMC_Summary, Param = "mu"))
head(displaySummaryBASiCS(MCMC_Summary, Param = "delta"))
head(displaySummaryBASiCS(MCMC_Summary, Param = "phi"))
head(displaySummaryBASiCS(MCMC_Summary, Param = "s"))
head(displaySummaryBASiCS(MCMC_Summary, Param = "nu"))
head(displaySummaryBASiCS(MCMC_Summary, Param = "theta"))
# Graphical display of posterior medians and 95% HPD intervals
plot(MCMC_Summary, Param = "mu", main = "All genes")
plot(MCMC_Summary, Param = "mu", Genes = 1:10, main = "First 10 genes")
plot(MCMC_Summary, Param = "delta", main = "All genes")
plot(MCMC_Summary, Param = "delta", Genes = c(2,5,10,50,100), main = "5 customized genes")
plot(MCMC_Summary, Param = "phi", main = "All cells")
plot(MCMC_Summary, Param = "phi", Cells = 1:5, main = "First 5 cells")
plot(MCMC_Summary, Param = "s", main = "All cells")
plot(MCMC_Summary, Param = "s", Cells = 1:5, main = "First 5 cells")
plot(MCMC_Summary, Param = "nu", main = "All cells")
plot(MCMC_Summary, Param = "nu", Cells = 1:5, main = "First 5 cells")
plot(MCMC_Summary, Param = "theta")
# To constrast posterior medians of cell-specific parameters
plot(MCMC_Summary, Param = "phi", Param2 = "s")
plot(MCMC_Summary, Param = "phi", Param2 = "nu")
plot(MCMC_Summary, Param = "s", Param2 = "nu")
# To constrast posterior medians of gene-specific parameters
plot(MCMC_Summary, Param = "mu", Param2 = "delta", log = "x")
# Highly and lowly variable genes detection
#DetectHVG <- BASiCS_DetectHVG(Data, MCMC_Output, VarThreshold = 0.70, Plot = TRUE)
#DetectLVG <- BASiCS_DetectLVG(Data, MCMC_Output, VarThreshold = 0.40, Plot = TRUE)
#plot(MCMC_Summary, Param = "mu", Param2 = "delta", log = "x", col = 8)
#points(DetectHVG$Table[DetectHVG$Table$HVG==1,2], DetectHVG$Table[DetectHVG$Table$HVG==1,3],
# pch = 16, col = "red", cex = 1)
#points(DetectLVG$Table[DetectLVG$Table$LVG==1,2], DetectLVG$Table[DetectLVG$Table$LVG==1,3],
# pch = 16, col = "blue", cex = 1)
# If variance thresholds are not fixed
#BASiCS_VarThresholdSearchHVG(Data, MCMC_Output, VarThresholdsGrid = seq(0.70,0.75,by=0.01))
#BASiCS_VarThresholdSearchLVG(Data, MCMC_Output, VarThresholdsGrid = seq(0.40,0.45,by=0.01))
# }
Run the code above in your browser using DataLab