annotate test-data/test.r @ 0:a8705df7c57f draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
author rnateam
date Wed, 21 Dec 2016 17:30:57 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
1 library("methylKit")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
2
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
3 file.list = list("input_test1.myCpG.txt", "input_test2.myCpG.txt", "input_control1.myCpG.txt", "input_control2.myCpG.txt")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
4
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
5 myobj=methRead( file.list,
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
6 sample.id=list("test 1","test 2","control 1","control 2"),assembly="hg18",pipeline="amp",treatment=c(1,1,0,0))
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
7
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
8 pdf('output_statistics.pdf')
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
9 for (obj in myobj){
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
10 getMethylationStats(obj,plot=TRUE,both.strands=FALSE)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
11 getCoverageStats(obj,plot=TRUE,both.strands=FALSE)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
12 }
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
13 devname = dev.off()
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
14
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
15 # unite function
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
16 methidh = unite(myobj)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
17
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
18 pdf("output_correlation.pdf")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
19 getCorrelation(object = methidh, plot=TRUE, method = "pearson")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
20 devname = dev.off()
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
21
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
22 # differential methylation
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
23 myDiff = calculateDiffMeth(methidh, overdispersion="none",
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
24 adjust="SLIM", effect="wmean", test="Chisq",
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
25 slim=FALSE, weighted.mean=FALSE)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
26
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
27 bedgraph(myDiff, file.name="output_myDiff.bedgraph", col.name="meth.diff",
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
28 unmeth=FALSE, log.transform=FALSE, negative=FALSE, add.on="")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
29
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
30 MethPerChr = diffMethPerChr(myDiff, plot=FALSE,
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
31 qvalue.cutoff=0.01,
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
32 meth.cutoff=25)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
33 write.table(MethPerChr, sep="\t", row.names=FALSE, quote=FALSE, file="output_MethPerChr.tsv")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
34
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
35 MethylDiff = getMethylDiff(myDiff, difference=25,
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
36 qvalue=0.01, type="all")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
37 bedgraph(MethylDiff, file.name="output_MethylDiff.bedgraph", col.name="meth.diff",
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
38 unmeth=FALSE,log.transform=FALSE,negative=FALSE,add.on="")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
39
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
40 pdf( "output_clustering.pdf" )
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
41 methClust = clusterSamples(methidh, dist="correlation", method="ward")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
42 devname = dev.off()
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
43
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
44 pdf( "output_PCA.pdf" )
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
45 PCASamples(methidh)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
46 devname = dev.off()
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
47
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
48 ## methSeg works for methylRaw or methylDiff with resolution region,
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
49 ## so methylBase has to be tiled before
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
50 tileRaw = tileMethylCounts(myobj[[1]])
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
51 tileBase = tileMethylCounts(methidh)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
52 tileDiff = calculateDiffMeth(tileBase)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
53
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
54 ## methseg generates Granges
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
55 segRaw = methSeg(tileRaw, diagnostic.plot = FALSE)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
56 segDiff = methSeg(tileDiff, diagnostic.plot = FALSE)
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
57
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
58 ## and can be exported as BED
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
59 methSeg2bed(segments = segRaw, filename = "output_seg_raw.bed")
a8705df7c57f planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methylkit commit 14f0b39f64982773ef0367379b915f742eabcc1b
rnateam
parents:
diff changeset
60 methSeg2bed(segments = segDiff, filename = "output_seg_diff.bed")