```
# NOT RUN {
# }
# NOT RUN {
download.file("https://dl.dropboxusercontent.com/u/1373164/H1.chr21.chr22.rds",
destfile="H1.chr21.chr22.rds",method="curl")
mbw=readRDS("H1.chr21.chr22.rds")
# it finds the optimal number of componets as 6
res=methSeg(mbw,diagnostic.plot=TRUE,maxInt=100,minSeg=10)
# however the BIC stabilizes after 4, we can also try 4 componets
res=methSeg(mbw,diagnostic.plot=TRUE,maxInt=100,minSeg=10,G=1:4)
# get segments to BED file
methSeg2bed(res,filename="H1.chr21.chr22.trial.seg.bed")
# }
# NOT RUN {
unlink(list.files(pattern="H1.chr21.chr22",full.names=TRUE))
# }
```

Run the code above in your browser using DataLab