This is a modified version of the Splatter software package constructed as a class project for CMSC 701: Computational Genomics.
Since this project is an extension of an existing package, it contains a lot of code that I did not write. All of the important modifications can be found in R/splat-simulate.R (there are also some modifications to files that R uses to build packages, but those are not really worth looking at). Within that script, the modifications I made are localized to the following functions: splatSimulateMod()
, grnIsValid()
, splatSimCrisprGroupDE()
, splatSimCrisprGroupCellMeans()
, and getCrisprLNormFactors()
Package management is kind of a pain in R, and the Splatter package has a lot of dependencies. For this reason, we recommend using conda. If you have conda installed on your machine you can follow these steps to get the package up and running:
conda env create -f environment.yml
conda activate splatter-mod-env
R
into the command prompt) and enter the following lines which install packages necessary to build an R package from source (thanks to Hilary Parker for writing a clear tutorial on this topic) install.packages("devtools")
library("devtools")
devtools::install_github("klutometis/roxygen")
library(roxygen2)
NOTE: the third line in the previous block worked on my work machine but not my personal laptop for reasons that I cannot explain. Your mileage may vary. If you encounter an error with that line, try this instead: install.packages("roxygen2")
setwd("<YOUR_PARENT_DIRECTORY_HERE>")
create("splatter")
setwd("./splatter/")
document()
setwd("..")
install("splatter")
library("splatter")
#generates a figure similar to Fig 2 (left panel) of writeup
sim <- splatSimulateMod(group.prob = c(0.34, 0.33, 0.33), batchCells=500, method="crispr", grn.deg.ls = c(1000,1200))
sim <- normalize(sim)
plotPCA(sim, colour_by="Group")
#generates a figure similar to Fig 2 (right panel) of writeup
sim <- splatSimulateMod(group.prob = c(0.34, 0.33, 0.33), batchCells=500, method="crispr", grn.deg.ls = c(100,200))
sim <- normalize(sim)
plotPCA(sim, colour_by="Group")
#generates a figure similar to Fig S1 of writeup
sim <- splatSimulateMod(group.prob = c(0.5, 0.5), batchCells=c(400,400), method="crispr", grn.deg.ls = c(1000))
sim <- normalize(sim)
plotPCA(sim, colour_by="Group", shape_by="Batch")
If you are interested in testing parametrizations of the simulation other than those that can be pattern matched from the previous block of code, you may have to create and edit a splatParams object. I'll include an example but for full details see this well-written tutorial by Luke Zappia (one of the authors of the Splatter paper).
#for example, this sets the number of simulated genes to 10000
params <- newSplatParams()
params <- setParams(params, nGenes=10000)
sim <- splatSimulateMod(params, group.prob = c(0.5, 0.5), method="crispr", grn.deg.ls = c(1000))
...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.