rbronste
12/26/2017 - 8:34 PM

SummarizedExperiment from DiffBind matrix

Creating a Ranged Summarized Experiment object from DiffBind matrix output.

R packages: DiffBind, BiocParallel

# Create a dba.count object

library("BiocParallel")
library("DiffBind")

parallel=TRUE
BPPARAM=MulticoreParam(4)

ATAC_adult_BNST<- dba(sampleSheet = "Adult_ATAC_BNST1.csv", config=data.frame(AnalysisMethod=DBA_DESEQ2, fragmentSize = 0, th=.05),peakFormat="narrow")

ATAC_Adult_BNST_count<-dba.count(ATAC_adult_BNST, score = DBA_SCORE_READS, fragmentSize = 0)

# Retrieve counts from dba.count

rangedCounts <- dba.peakset(ATAC_Adult_BNST_count, bRetrieve=TRUE)

# Retrieve counts from dba.count without the site interval ranges

counts <- as.matrix(mcols(rangedCounts))

# Construct a SummarizedExperiment

nrows <- 1054182
ncols <- 16
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges<-GRanges(rangedCounts)

sampleNames<-c("MBV1",	"MBV2",	"MBV3",	"FBV1",	"FBV2",	"FBV3", "MBE7", "MBE8", "MBE9", "FBE1", "FBE2", "FBE3")
sampleSex<-c("male", "male", "male", "female", "female", "female", "male", "male", "male", "female", "female", "female")
sampleTreatment<-c("vehicle", "vehicle", "vehicle", "vehicle", "vehicle", "vehicle", "EB", "EB", "EB", "EB", "EB", "EB")
colData<-data.frame(sampleName=sampleNames, sex=sampleSex, treatment=sampleTreatment)

se<-SummarizedExperiment(assays=list(counts=counts),rowRanges=rowRanges, colData=colData)