Skip to content

Instantly share code, notes, and snippets.

@willtownes
Created April 25, 2018 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willtownes/3fb06b305d2db70476404d677e308cca to your computer and use it in GitHub Desktop.
Save willtownes/3fb06b305d2db70476404d677e308cca to your computer and use it in GitHub Desktop.
Splatter experiments
#splatter experimenting with cell-specific dropouts
#pertains to https://github.com/Oshlack/splatter/issues/25
#devtools::install_github("Oshlack/splatter@dropout")
library(splatter)
data("sc_example_counts")
# Estimate parameters from example data
params <- splatEstimate(sc_example_counts)
# Simulate data using estimated parameters
sim1 <- splatSimulate(params, dropout.type = "experiment")
assay(sim1,"logcounts")<-log2(1+assay(sim1,"counts"))
tlc<-log2(1+assay(sim1,"TrueCounts"))
pz<-assay(sim1,"DropProb")
plot(tlc[,1],pz[,1],xlab="log true counts",ylab="dropout prob")
plotPCA(sim1) #no obvious separation
N<-ncol(sc_example_counts) #40
ref<-data.frame(grp=rep(c("a","b"),each=N/2))
ref$det_shift<-rep(c(2,8),each=N/2)+rnorm(N,0,.5)
ref$det_slope<-rnorm(N,-.9,.01)
params2<-setParams(params,list(dropout.mid=ref$det_shift,
dropout.shape=ref$det_slope))
sim2<-splatSimulate(params2,dropout.type="cell")
assay(sim2,"logcounts")<-log2(1+assay(sim2,"counts"))
tlc<-log2(1+assay(sim2,"TrueCounts"))
pz<-assay(sim2,"DropProb")
plot(tlc[,1],pz[,1],xlab="log true counts",ylab="dropout prob")
cm<-colData(sim2)
cm$detection_group<-ref$grp
colData(sim2)<-cm
#false clusters due to detection rates
plotPCA(sim2,colour_by="detection_group")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment