annotate chipseeker.R @ 7:1b9a9409831d draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
author rnateam
date Sat, 27 Apr 2019 11:04:35 -0400
parents b418a1d3585d
children 8bd92f2404dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
1 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
2
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
3 # we need that to not crash galaxy with an UTF8 error on German LC settings.
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
4 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
5
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
6 suppressPackageStartupMessages({
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
7 library(ChIPseeker)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
8 library(GenomicFeatures)
3
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
9 library(rtracklayer)
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
10 library(optparse)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
11 })
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
12
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
13 option_list <- list(
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
14 make_option(c("-i","--infile"), type="character", help="Peaks file to be annotated"),
7
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
15 make_option(c("-H","--header"), type="logical", help="Peaks file contains header row"),
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
16 make_option(c("-G","--gtf"), type="character", help="GTF to create TxDb."),
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
17 make_option(c("-u","--upstream"), type="integer", help="TSS upstream region"),
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
18 make_option(c("-d","--downstream"), type="integer", help="TSS downstream region"),
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
19 make_option(c("-F","--flankgeneinfo"), type="logical", help="Add flanking gene info"),
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
20 make_option(c("-D","--flankgenedist"), type="integer", help="Flanking gene distance"),
6
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
21 make_option(c("-j","--ignoreUpstream"), type="logical", help="Ignore upstream"),
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
22 make_option(c("-k","--ignoreDownstream"), type="logical", help="Ignore downstream"),
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
23 make_option(c("-f","--format"), type="character", help="Output format (interval or tabular)."),
3
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
24 make_option(c("-p","--plots"), type="logical", help="PDF of plots."),
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
25 make_option(c("-r","--rdata"), type="logical", help="Output RData file.")
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
26 )
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
27
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
28 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
29 args = parse_args(parser)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
30
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
31 peaks = args$infile
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
32 gtf = args$gtf
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
33 up = args$upstream
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
34 down = args$downstream
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
35 format = args$format
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
36
6
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
37 if (!is.null(args$flankgeneinfo)) {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
38 flankgeneinfo <- TRUE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
39 } else {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
40 flankgeneinfo <- FALSE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
41 }
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
42
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
43 if (!is.null(args$ignoreUpstream)) {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
44 ignoreUpstream <- TRUE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
45 } else {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
46 ignoreUpstream <- FALSE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
47 }
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
48
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
49 if (!is.null(args$ignoreDownstream)) {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
50 ignoreDownstream <- TRUE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
51 } else {
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
52 ignoreDownstream <- FALSE
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
53 }
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
54
7
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
55 if (!is.null(args$header)) {
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
56 header <- TRUE
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
57 } else {
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
58 header <- FALSE
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
59 }
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
60
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
61 peaks <- readPeakFile(peaks, header=header)
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
62
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
63 # Make TxDb from GTF
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
64 txdb <- makeTxDbFromGFF(gtf, format="gtf")
6
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
65
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
66 # Annotate peaks
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
67 peakAnno <- annotatePeak(peaks, TxDb=txdb,
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
68 tssRegion=c(-up, down),
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
69 addFlankGeneInfo=flankgeneinfo,
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
70 flankDistance=args$flankgenedist,
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
71 ignoreUpstream=ignoreUpstream,
b418a1d3585d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit d83142dbe2432fcb0f56dcd6311a05c061628ecc
rnateam
parents: 4
diff changeset
72 ignoreDownstream=ignoreDownstream)
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
73
3
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
74 # Add gene name
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
75 features <- import(gtf, format="gtf")
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
76 ann <- unique(mcols(features)[, c("gene_id", "gene_name")])
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
77 res <- as.data.frame(peakAnno)
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
78 res <- merge(res, ann, by.x="geneId", by.y="gene_id")
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
79 names(res)[names(res) == "gene_name"] <- "geneName"
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
80
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
81 #Extract metadata cols, 1st is geneId, rest should be from col 7 to end
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
82 metacols <- res[, c(7:ncol(res), 1)]
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
83 # Convert from 1-based to 0-based format
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
84 if (format == "interval") {
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
85 metacols <- apply(as.data.frame(metacols), 1, function(col) paste(col, collapse="|"))
4
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
86 resout <- data.frame(res$seqnames,
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
87 res$start - 1,
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
88 res$end,
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
89 metacols)
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
90 colnames(resout)[1:4] <- c("Chrom", "Start", "End", "Comment")
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
91 } else {
4
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
92 resout <- data.frame(res$seqnames,
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
93 res$start - 1,
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
94 res$end,
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
95 metacols)
4
90fe78a19b55 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 6f594126ac7369cc80c30a02a6df57e785dfb45a
rnateam
parents: 3
diff changeset
96 colnames(resout)[1:3] <- c("Chrom", "Start", "End")
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
97 }
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
98 write.table(resout, file="out.tab", sep="\t", row.names=FALSE, quote=FALSE)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
99
3
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
100 if (!is.null(args$plots)) {
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
101 pdf("out.pdf", width=14)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
102 plotAnnoPie(peakAnno)
7
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
103 p1 <- plotAnnoBar(peakAnno)
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
104 print(p1)
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
105 vennpie(peakAnno)
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
106 upsetplot(peakAnno)
7
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
107 p2 <- plotDistToTSS(peakAnno, title="Distribution of transcription factor-binding loci\nrelative to TSS")
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
108 print(p2)
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
109 dev.off()
7
1b9a9409831d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chipseeker commit e07ee851144e07fde91877727d6a39a1906f7639
rnateam
parents: 6
diff changeset
110 rm(p1, p2)
3
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
111 }
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
112
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
113 ## Output RData file
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
114
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
115 if (!is.null(args$rdata)) {
535321abf9a4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 861db0d1f76bb320f49c2501f4e656cf88d389ce
rnateam
parents: 1
diff changeset
116 save.image(file = "ChIPseeker_analysis.RData")
1
95f779f4adb7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
rnateam
parents:
diff changeset
117 }