owd <- setwd(tempdir())
##For this example we will use a subset of the AP1 ChIP-seq data (Kaufmann et
##al., 2010)
##The data is obtained after analysis using the CSAR package available in
##Bioconductor
data("NarrowPeaks-dataset")
writeLines(wigfile_test, con="wigfile.wig")
##Write binary files with the WIG signal values for each chromosome
##independently and obtain regions of read-enrichment with score values greater
##than 't', allowing a gap of 'g'. Data correspond to enriched regions found up
##to 105Kb in the Arabidopsis thaliana genome
wigScores <- wig2CSARScore(wigfilename="wigfile.wig", nbchr = 1,
chrle=c(30427671))
gc(reset=TRUE)
library(CSAR)
candidates <- sigWin(experiment=wigScores$infoscores, t=1.0, g=30)
##Narrow down ChIPSeq enriched regions by functional PCA
shortpeaks <- narrowpeaks(inputReg=candidates,
scoresInfo=wigScores$infoscores, lmin=0, nbf=150, rpenalty=0,
nderiv=0, npcomp=2, pv=80, pmaxscor=3.0, ms=0)
###Export GRanges object with the peaks to annotation tracks in various
##formats. E.g.:
library(GenomicRanges)
names(elementMetadata(shortpeaks$broadPeaks))[3] <- "score"
names(elementMetadata(shortpeaks$narrowPeaks))[2] <- "score"
library(rtracklayer)
export.bedGraph(object=candidates, con="CSAR.bed")
export.bedGraph(object=shortpeaks$broadPeaks, con="broadPeaks.bed")
export.bedGraph(object=shortpeaks$narrowPeaks, con="narrowpeaks.bed")
setwd(owd)
Run the code above in your browser using DataLab