Mercurial > repos > rnateam > chipseeker
changeset 1:2019b4dd86a8 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/chipseeker commit 3419a5a5e19a93369c8c20a39babe5636a309292
| author | rnateam |
|---|---|
| date | Tue, 29 May 2018 15:07:04 -0400 |
| parents | 313332cb7745 |
| children | 195cba35110e |
| files | chipseeker.R chipseeker.xml test-data/cached_locally/gene_sets.loc test-data/cached_locally/ref.gtf test-data/in.bed test-data/in.diffbind test-data/in.gtf test-data/in.interval test-data/out.int test-data/out.pdf test-data/out.tab test-data/outflank.tab test-data/outint.int test-data/outint.tab test-data/outtss.tab tool-data/gene_sets.loc.sample tool_data_table_conf.xml.sample tool_data_table_conf.xml.test |
| diffstat | 18 files changed, 333 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chipseeker.R Tue May 29 15:07:04 2018 -0400 @@ -0,0 +1,69 @@ +options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) + +# we need that to not crash galaxy with an UTF8 error on German LC settings. +loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") + +suppressPackageStartupMessages({ + library(ChIPseeker) + library(GenomicFeatures) + library(optparse) +}) + +option_list <- list( + make_option(c("-i","--infile"), type="character", help="Peaks file to be annotated"), + make_option(c("-G","--gtf"), type="character", help="GTF to create TxDb."), + make_option(c("-u","--upstream"), type="integer", help="TSS upstream region"), + make_option(c("-d","--downstream"), type="integer", help="TSS downstream region"), + make_option(c("-F","--flankgeneinfo"), type="logical", help="Add flanking gene info"), + make_option(c("-D","--flankgenedist"), type="integer", help="Flanking gene distance"), + make_option(c("-f","--format"), type="character", help="Output format (interval or tabular)."), + make_option(c("-p","--plots"), type="character", help="PDF of plots.") + ) + +parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) +args = parse_args(parser) + +peaks = args$infile +gtf = args$gtf +up = args$upstream +down = args$downstream +format = args$format +plots = args$plots + +peaks <- readPeakFile(peaks) + +# Make TxDb from GTF +txdb <- makeTxDbFromGFF(gtf, format="gtf") +if (!is.null(args$flankgeneinfo)) { + peakAnno <- annotatePeak(peaks, TxDb=txdb, tssRegion=c(-up, down), addFlankGeneInfo=args$flankgeneinfo, flankDistance=args$flankgenedist) +} else { + peakAnno <- annotatePeak(peaks, TxDb=txdb, tssRegion=c(-up, down)) +} + +# Convert from 1-based to 0-based format +res <- as.GRanges(peakAnno) +metacols <- mcols(res) +if (format == "interval") { + metacols <- apply(as.data.frame(metacols), 1, function(col) paste(col, collapse="|")) + resout <- data.frame(Chrom=seqnames(res), + Start=start(res) - 1, + End=end(res), + Comment=metacols) +} else { + resout <- data.frame(Chrom=seqnames(res), + Start=start(res) - 1, + End=end(res), + metacols) +} + +write.table(resout, file="out.tab", sep="\t", row.names=FALSE, quote=FALSE) + +if (!is.null(plots)) { + pdf("out.pdf", width=14) + plotAnnoPie(peakAnno) + plotAnnoBar(peakAnno) + vennpie(peakAnno) + upsetplot(peakAnno) + plotDistToTSS(peakAnno, title="Distribution of transcription factor-binding loci\nrelative to TSS") + dev.off() +} \ No newline at end of file
--- a/chipseeker.xml Thu May 24 18:22:53 2018 -0400 +++ b/chipseeker.xml Tue May 29 15:07:04 2018 -0400 @@ -1,89 +1,75 @@ -<tool id="chipseeker" name="ChIPseeker" version="1.14.2"> +<tool id="chipseeker" name="ChIPseeker" version="1.14.2.1"> <description>for ChIP peak annotation and visualization</description> <requirements> <requirement type="package" version="1.14.2">bioconductor-chipseeker</requirement> - <requirement type="package" version="3.4.0">bioconductor-txdb.hsapiens.ucsc.hg38.knowngene</requirement> - <requirement type="package" version="3.2.2">bioconductor-txdb.hsapiens.ucsc.hg19.knowngene</requirement> - <requirement type="package" version="3.4.0">bioconductor-txdb.Mmusculus.UCSC.mm10.knownGene</requirement> - <requirement type="package" version="3.5.0">bioconductor-org.hs.eg.db</requirement> - <requirement type="package" version="3.5.0">bioconductor-org.mm.eg.db</requirement> + <requirement type="package" version="1.4.4">r-optparse</requirement> </requirements> <version_command><![CDATA[ -echo $(R --version | grep version | grep -v GNU)", ChIPseeker version" $(R --vanilla --slave -e "library(ChIPseeker); cat(sessionInfo()\$otherPkgs\$ChIPseeker\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", TxDb.Hsapiens.UCSC.hg38.knownGene version" $(R --vanilla --slave -e "library(TxDb.Hsapiens.UCSC.hg38.knownGene); cat(sessionInfo()\$otherPkgs\$TxDb.Hsapiens.UCSC.hg38.knownGene\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", TxDb.Hsapiens.UCSC.hg19.knownGene version" $(R --vanilla --slave -e "library(TxDb.Hsapiens.UCSC.hg19.knownGene); cat(sessionInfo()\$otherPkgs\$TxDb.Hsapiens.UCSC.hg19.knownGene\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", TxDb.Mmusculus.UCSC.mm10.knownGene version" $(R --vanilla --slave -e "library(TxDb.Mmusculus.UCSC.mm10.knownGene); cat(sessionInfo()\$otherPkgs\$TxDb.Mmusculus.UCSC.mm10.knownGene\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", org.Hs.eg.db version" $(R --vanilla --slave -e "library(org.Hs.eg.db); cat(sessionInfo()\$otherPkgs\$org.Hs.eg.db\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", org.Mm.eg.db version" $(R --vanilla --slave -e "library(org.Mm.eg.db); cat(sessionInfo()\$otherPkgs\$org.Mm.eg.db\$Version)" 2> /dev/null | grep -v -i "WARNING: ") +echo $(R --version | grep version | grep -v GNU)", ChIPseeker version" $(R --vanilla --slave -e "library(ChIPseeker); cat(sessionInfo()\$otherPkgs\$ChIPseeker\$Version)" 2> /dev/null | grep -v -i "WARNING: ")", optparse version" $(R --vanilla --slave -e "library(optparse); cat(sessionInfo()\$otherPkgs\$optparse\$Version)" 2> /dev/null | grep -v -i "WARNING: ") ]]></version_command> <command detect_errors="exit_code"><![CDATA[ + #set gtf = "refgtf" + #if $gtf_source.gtf_source_select == "history": + ln -s '${gtf_source.gtf_hist}' $gtf && + #else if $gtf_source.gtf_source_select == "cached": + ln -s '${gtf_source.gtf_builtin.fields.path}' $gtf && + #end if + #if $rscript: - cp '${chipseeker_script}' '${out_rscript}' && + cp '$__tool_directory__/chipseeker.R' '$out_rscript' && #end if - Rscript '${chipseeker_script}' + + Rscript '$__tool_directory__/chipseeker.R' + + -i '$peaks' + -G '$gtf' + -u $upstream + -d $downstream + #if $flankgeneinfo: + -F $flankgeneinfo + -D $flankgenedist + #end if + -f $format + -p $pdf ]]> </command> - <configfiles> - <configfile name="chipseeker_script"><![CDATA[ -options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) - -# we need that to not crash galaxy with an UTF8 error on German LC settings. -loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") - -suppressPackageStartupMessages(library(ChIPseeker)) - -genome <- "${genome}" - -if (genome == "hg38") { - suppressPackageStartupMessages({ - library(TxDb.Hsapiens.UCSC.hg38.knownGene) - library(org.Hs.eg.db) - }) - txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene - annodb <- "org.Hs.eg.db" -} else if (genome == "hg19") { - suppressPackageStartupMessages({ - library(TxDb.Hsapiens.UCSC.hg19.knownGene) - library(org.Hs.eg.db) - }) - txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene - annodb <- "org.Hs.eg.db" -} else if (genome == "mm10") { - suppressPackageStartupMessages({ - library(TxDb.Mmusculus.UCSC.mm10.knownGene) - library(org.Mm.eg.db) - }) - txdb <- TxDb.Mmusculus.UCSC.mm10.knownGene - annodb <- "org.Mm.eg.db" -} else { - cat(paste("Genome not supported", genome)) -} - -peaks <- readPeakFile('$peaks_file') -peakAnno <- annotatePeak(peaks, TxDb=txdb, annoDb=annodb) -write.table(peakAnno, file='$out_tab', sep="\t", row.names=FALSE, quote=FALSE) - -if (!is.null("${pdf}")) { - pdf("out.pdf", width=14) - plotAnnoPie(peakAnno) - plotAnnoBar(peakAnno) - vennpie(peakAnno) - upsetplot(peakAnno) - plotDistToTSS(peakAnno, title="Distribution of transcription factor-binding loci\nrelative to TSS") - dev.off() -} - ]]></configfile> - </configfiles> - <inputs> - <param name="peaks_file" type="data" format="bed" label="Peaks file" help="A peaks file in BED format." /> - <param name="genome" type="select" label="Genome" help="Select the genome. Options are hg38, hg19 or mm10."> - <option value="hg38">hg38</option> - <option value="hg19">hg19</option> - <option value="mm10">mm10</option> + <param name="peaks" type="data" format="bed,interval" label="Peaks file" help="A peaks file in BED format." /> + <conditional name="gtf_source"> + <param name="gtf_source_select" type="select" label="Annotation source" help="Select a GTF to use for annotation source."> + <option value="cached" selected="true">Use a built-in GTF</option> + <option value="history">Use a GTF from history</option> + </param> + <when value="cached"> + <param name="gtf_builtin" type="select" label="Select a built-in GTF" help="If the GTF file for your transcriptome of interest is not listed, contact your Galaxy administrator"> + <options from_data_table="gene_sets"> + <filter type="sort_by" column="2" /> + <validator type="no_options" message="No GTF file is available." /> + </options> + </param> + </when> + <when value="history"> + <param name="gtf_hist" type="data" format="gtf" label="Select a history GTF" /> + </when> + </conditional> + <param name="upstream" type="integer" min="0" value="3000" label="TSS upstream region" help="User can define TSS (transcription start site) region, by default TSS is defined from -3kb to +3kb." /> + <param name="downstream" type="integer" min="0" value="3000" label="TSS downstream region" help="User can define TSS (transcription start site) region, by default TSS is defined from -3kb to +3kb."/> + <param name="flankgeneinfo" type="boolean" truevalue="True" falsevalue="False" checked="False" label="Add flanking gene information?" help="If specified all genes within the flanking gene distance are reported for each peak. Default: No."/> + <param name="flankgenedist" type="integer" min="0" value="5000" label="Flanking gene distance" help="If flanking gene info is turned on the flanking distance can be specified. Default: 5000."/> + <param name="format" type="select" label="Output Format"> + <option value="interval" selected="True">Interval</option> + <option value="tabular">Tabular (tab-separated)</option> </param> - - <param name="pdf" type="boolean" truevalue="True" falsevalue="" checked="True" label="Output a PDF file of plots?" help="Default: Yes" /> + <param name="pdf" type="boolean" truevalue="True" falsevalue="" checked="True" label="Output PDF of plots?" help="Default: Yes" /> <param name="rscript" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="False" label="Output Rscript?" help="If this option is set to Yes, the Rscript used to annotate the IDs will be provided as a text file in the output. Default: No" /> </inputs> <outputs> - <data name="out_tab" format="tabular" from_work_dir="out.tab" label="${tool.name} on ${on_string}: Annotated Peaks" /> + <data name="out_tab" format="interval" from_work_dir="out.tab" label="${tool.name} on ${on_string}: Annotated Peaks" > + <change_format> + <when input="format" value="tabular" format="tabular" /> + </change_format> + </data> <data name="out_plots" format="pdf" from_work_dir="out.pdf" label="${tool.name} on ${on_string}: Plots"> <filter>pdf</filter> </data> @@ -93,12 +79,13 @@ </outputs> <tests> - <!-- Ensure outputs work --> + <!-- Ensure bed and GTF inputs and all outputs work --> <test expect_num_outputs="3"> - <param name="peaks_file" value="in.diffbind" ftype="bed"/> - <param name="genome" value="hg19"/> + <param name="peaks" value="in.bed" ftype="bed"/> + <param name="gtf_source_select" value="history"/> + <param name="gtf_hist" value="in.gtf"/> <param name="rscript" value="True"/> - <output name="out_tab" file="out.tab" /> + <output name="out_tab" ftype="interval" file="out.int" /> <output name="out_plots" file="out.pdf" compare="sim_size"/> <output name="out_rscript" > <assert_contents> @@ -106,6 +93,43 @@ </assert_contents> </output> </test> + <!-- Ensure built-in GTF works --> + <test expect_num_outputs="2"> + <param name="peaks" value="in.interval" ftype="interval"/> + <param name="gtf_source_select" value="cached"/> + <output name="out_tab" ftype="interval" file="outint.int" /> + <output name="out_plots" file="out.pdf" compare="sim_size"/> + </test> + <!-- Ensure tabular output works --> + <test expect_num_outputs="2"> + <param name="peaks" value="in.interval" ftype="interval"/> + <param name="gtf_source_select" value="history"/> + <param name="gtf_hist" value="in.gtf"/> + <param name="format" value="tabular"/> + <output name="out_tab" ftype="tabular" file="outint.tab" /> + <output name="out_plots" file="out.pdf" compare="sim_size"/> + </test> + <!-- Ensure TSS region specification works --> + <test expect_num_outputs="2"> + <param name="peaks" value="in.interval" ftype="interval"/> + <param name="gtf_source_select" value="history"/> + <param name="gtf_hist" value="in.gtf"/> + <param name="upstream" value="1000" /> + <param name="downstream" value="1000" /> + <param name="format" value="tabular"/> + <output name="out_tab" ftype="tabular" file="outtss.tab" /> + <output name="out_plots" file="out.pdf" compare="sim_size"/> + </test> + <!-- Ensure flanking genes works --> + <test expect_num_outputs="2"> + <param name="peaks" value="in.interval" ftype="interval"/> + <param name="gtf_source_select" value="history"/> + <param name="gtf_hist" value="in.gtf"/> + <param name="flankgeneinfo" value="True" /> + <param name="format" value="tabular"/> + <output name="out_tab" ftype="tabular" file="outflank.tab" /> + <output name="out_plots" file="out.pdf" compare="sim_size"/> + </test> </tests> <help><