It seems DiffBind run everything on top of dba objects. But all peak data are stored as GRanges objects in my workflow. How to make the DBA object from GRanges easily, so I do not have to read in the peaks again as DBA?
XuLong
It seems DiffBind run everything on top of dba objects. But all peak data are stored as GRanges objects in my workflow. How to make the DBA object from GRanges easily, so I do not have to read in the peaks again as DBA?
XuLong
Hi XuLong-
If you don't want to write the GRanges
objects out as peak files, you can use the dba.peakset()
function instead of dba().
You have to call dba.peakset()
once for each peakset you want to add. The first call should set DBA=NULL
, and subsequent calls should set DBA
to the DBA object returned from the previous call. You can set all the metadata for each peakset as well.
For example, if you have a samplesheet named samples
, and your peaks in a GRangesList
named peaklist
, you could call dba.peakset()
in a loop, supplying your peaks as a GRanges
object:
myDBA <- NULL samples <- read.csv("samplesheet.csv",as.is=TRUE) for(i in 1:nrow(samples)) { myDBA <- dba.peakset(DBA=myDBA,peaks=peaklist[[i]], sampID=samples$SampleName[i], tissue=samples$Tissue[i], factor=samples$Factor[i], condition=samples$Condition[i], treatment=samples$Treatment[i], replicate=samples$Replicate[i], peak.caller = "mycaller", bamReads=samples$bamReads[i], control=samples$ControlID[i], bamControl=samples$bamControl[i]) }
Cheers-
Rory
AHello, I am trying to do that, but I got an error:
g = GRanges(seqnames = "chr1", ranges = c(1, 1000));
dba.peakset(NULL, peaks=g);
Error in `[.data.frame`(peaks[[i]], , 1:4) : undefined columns selected
This happen with different GRanges (with or without strand specified etc).
Can anyone help me?
Thanks very much,
Albert
This is a bug caused by the lack of a "score" metadata column. I'll check in a fix to deal with a missing score. In the meantime, here is a workaround:
> g <- GRanges(seqnames = "chr1", ranges = c(1, 1000), score = rep(1,length(c(1,1000))))
Cheers-
Rory
Thanks Rory, it works!
Best,
Albert
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.