Bayesian deconvolution
install.packages("devtools")
devtools::install_github("petedodd/baydec")
Load relevant packages:
library(baydec) #this package
library(data.table) #for handling data
library(ggplot2) #for plotting
Some example data (the darmanis
data from BEDwARS):
data(darmanis)
Run the MCMC deconvolution:
nrep <- 1e3
smps <- deconvolve(darmanis$X,darmanis$Y,chains=4,cores=4,iter=nrep,seed=1234)
Summarize the outputs:
smy <- postprocess.baydec(smps)
Plot against truth:
ggplot(smy,aes(cells,value))+
geom_point(shape=1)+
geom_point(data=darmanis$truth,shape=1,col=2)+
facet_wrap(~expts)
CF <- merge(darmanis$truth[,.(expts,cells,true=value)],
smy[,.(expts,cells,estimate=value)],
by=c('expts','cells'))
CF$cells <- as.factor(CF$cells)
ggplot(CF,aes(estimate,true,shape=cells,col=cells))+
facet_wrap(~expts)+
geom_abline(slope=1,col=2,intercept=0,lty=2)+
geom_point(size=2)+
theme(legend.position='top')