Skip to content

Commit

Permalink
Upgrade mircounts tools (#666)
Browse files Browse the repository at this point in the history
* Upgrade conda packages. IUC format

* lint R, py and xml codes

* update tests in Mississippi

* add  expect_num_outputs

* reduce test sizes
  • Loading branch information
drosofff authored Feb 10, 2024
1 parent 2661225 commit 5eb8570
Show file tree
Hide file tree
Showing 21 changed files with 6,059 additions and 572,650 deletions.
35 changes: 20 additions & 15 deletions tools/mircounts/coverage_plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ hlp_output <- "--output\tFILE\tFile to output the pdf to\n"
hlp <- paste(hlp_description, hlp_usage, hlp_dataframe, hlp_type, hlp_output, sep = "\n")

# Setup R error handling to go to stderr
options(show.error.messages = F,
options(show.error.messages = FALSE,
error = function() {
cat(geterrmessage(), file = stderr()); q("no", 1, F)
cat(geterrmessage(), file = stderr())
q("no", 1, FALSE)
}
)

Expand All @@ -26,7 +27,7 @@ option_list <- list(
make_option(c("-t", "--type"), type = "character", default = "relative",
help = "Type of plotting, either relative or absoute coverage values (default = 'relative')"),
make_option(c("-o", "--output"), type = "character", help = "File to output the pdf to")
)
)
parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
args <- parse_args(parser)

Expand All @@ -35,22 +36,26 @@ if (!("dataframe" %in% names(args)) || !("output" %in% names(args))) {
}

# Plot
coverage <- read.delim(args$dataframe, header = T)
coverage <- read.delim(args$dataframe, header = TRUE)
if (args$type == "relative") {
graph <- xyplot(Norm_count ~ Norm_offset | Mir_hairpin, data = coverage, col = c("darkblue"), type = "l", lwd = 1.5,
scales = list(x = list(cex = .5), y = list(cex = .5)), par.strip.text = list(cex = .5),
strip = strip.custom(which.given = 1, bg = "lightblue"), layout = c(4, 15),
as.table = T, xlab = "Normalized Counts", ylab = "Normalized coordinates",
main = "miRNA coverage maps")
graph <- xyplot(
Norm_count ~ Norm_offset | Mir_hairpin, data = coverage, col = c("darkblue"), type = "l", lwd = 1.5,
scales = list(x = list(cex = .5), y = list(cex = .5)), par.strip.text = list(cex = .5),
strip = strip.custom(which.given = 1, bg = "lightblue"), layout = c(4, 15),
as.table = TRUE, xlab = "Normalized Counts", ylab = "Normalized coordinates",
main = "miRNA coverage maps"
)
} else {
graph <- xyplot(Count ~ Offset | Mir_hairpin, data = coverage, col = c("darkblue"), type = "l", lwd = 1.5,
scales = list(x = list(cex = .5), y = list(cex = .5)), par.strip.text = list(cex = .5),
strip = strip.custom(which.given = 1, bg = "lightblue"), layout = c(4, 15),
as.table = T, xlab = "Counts", ylab = "Coordinates",
main = "miRNA coverage plots")
graph <- xyplot(
Count ~ Offset | Mir_hairpin, data = coverage, col = c("darkblue"), type = "l", lwd = 1.5,
scales = list(x = list(cex = .5), y = list(cex = .5)), par.strip.text = list(cex = .5),
strip = strip.custom(which.given = 1, bg = "lightblue"), layout = c(4, 15),
as.table = TRUE, xlab = "Counts", ylab = "Coordinates",
main = "miRNA coverage plots"
)
}

# PDF output
pdf(file = args$output, paper = "special", height = 11.69, width = 8.2677)
plot(graph, newpage = T)
plot(graph, newpage = TRUE)
dev.off()
71 changes: 38 additions & 33 deletions tools/mircounts/mircounts.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
<tool id="mircounts" name="miRcounts" version="1.5.1">
<tool id="mircounts" name="miRcounts" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description> Counts miRNA alignments from small RNA sequence data</description>
<macros>
<token name="@TOOL_VERSION@">1.6</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@PROFILE@">23.0</token>
</macros>
<requirements>
<requirement type="package" version="1.34=ha1f6473_0">tar</requirement>
<requirement type="package" version="1.3.0=py39h176da8b_2">bowtie</requirement>
<requirement type="package" version="1.12=h9aed4be_1">samtools</requirement>
<requirement type="package" version="0.16.0.1=py39h051187c_3">pysam</requirement>
<requirement type="package" version="1.6.6=r40h6115d3f_1">r-optparse</requirement>
<requirement type="package" version="0.20_44=r40hcfec24a_0">r-lattice</requirement>
<requirement type="package" version="1.34">tar</requirement>
<requirement type="package" version="1.3.1">bowtie</requirement>
<requirement type="package" version="1.19.2">samtools</requirement>
<requirement type="package" version="0.22.0">pysam</requirement>
<requirement type="package" version="1.7.4">r-optparse</requirement>
<requirement type="package" version="0.22_5">r-lattice</requirement>
</requirements>
<stdio>
<exit_code range="1:" level="warning" description="Tool exception" />
</stdio>
<command detect_errors="exit_code"><![CDATA[
tar -xf '$__tool_directory__'/mirbase.tar.gz &&
python '$__tool_directory__'/mature_mir_gff_translation.py
--gff_path mirbase/${mirbase_version}/genomes/${genomeKey}.gff3
--output $gff3 && ## transcode the mature miR genome coordinates into coordinates relative to the corresponding "miRNA_primary_transcript".
--gff_path mirbase/'${mirbase_version}'/genomes/'${genomeKey}'.gff3
--output '$gff3' && ## transcode mature miR genome coordinates relative to "miRNA_primary_transcript"
python '$__tool_directory__'/format_fasta_hairpins.py
--hairpins_path mirbase/${mirbase_version}/hairpin.fa.gz
--basename ${genomeKey}
--hairpins_path mirbase/'${mirbase_version}'/hairpin.fa.gz
--basename '${genomeKey}'
--output hairpin.fa &&
#if $cutadapt.cutoption == "yes":
python '$__tool_directory__'/yac.py --input $cutadapt.input
python '$__tool_directory__'/yac.py --input '$cutadapt.input'
--output clipped_input.fastq
--output_format fastq
--adapter_to_clip $cutadapt.clip_source.clip_sequence
--min $cutadapt.min
--max $cutadapt.max
--Nmode $cutadapt.Nmode &&
--adapter_to_clip '$cutadapt.clip_source.clip_sequence'
--min '$cutadapt.min'
--max '$cutadapt.max'
--Nmode '$cutadapt.Nmode' &&
#else:
ln -f -s '$cutadapt.clipped_input' clipped_input.fastq &&
#end if
bowtie-build hairpin.fa hairpin &&
bowtie -v $v -M 1 --best --strata --norc -p \${GALAXY_SLOTS:-4} --sam hairpin -q clipped_input.fastq | samtools sort -@ \${GALAXY_SLOTS:-4} -O bam -o '$output' &&
bowtie -v '$v' -M 1 --best --strata --norc -p \${GALAXY_SLOTS:-4} --sam hairpin -q clipped_input.fastq | samtools sort -@ \${GALAXY_SLOTS:-4} -O bam -o '$output' &&
samtools index $output &&
python '$__tool_directory__'/mircounts.py --alignment $output --gff $gff3 --quality_threshold 10 --pre_mirs $pre_mir_count_file --mirs $mir_count_file --lattice $coverage_dataframe
python '$__tool_directory__'/mircounts.py --alignment '$output' --gff '$gff3' --quality_threshold 10 --pre_mirs '$pre_mir_count_file' --mirs '$mir_count_file' --lattice '$coverage_dataframe'
#if $plotting.plottingOption == 'yes':
&& Rscript '$__tool_directory__'/coverage_plotting.R --dataframe $coverage_dataframe --type $plotting.display --output $latticePDF
&& Rscript '$__tool_directory__'/coverage_plotting.R --dataframe '$coverage_dataframe' --type '$plotting.display' --output '$latticePDF'
#end if
]]></command>
<inputs>
Expand Down Expand Up @@ -135,12 +140,12 @@
</data>
</outputs>
<tests>
<test>
<param name="cutoption" value="no" />
<test expect_num_outputs="6">
<param name="cutoption" value="no"/>
<param name="v" value="1"/>
<param name="genomeKey" value="aga"/>
<param name="mirbase_version" value="22"/>
<param name="clipped_input" value="aga.fastqsanger" ftype="fastqsanger"/>
<param name="clipped_input" value="aga.fastqsanger.gz" ftype="fastqsanger.gz"/>
<param name="plottingOption" value="yes"/>
<param name="display" value="relative"/>
<param name="output_premir_counts" value="True"/>
Expand All @@ -152,8 +157,8 @@
<output name="latticePDF" file="aga_mir_coverage.pdf" ftype="pdf" />
<output name="coverage_dataframe" file="aga_lattice_dataframe.tab" ftype="tabular" />
</test>
<test>
<param name="cutoption" value="yes" />
<test expect_num_outputs="6">
<param name="cutoption" value="yes"/>
<param name="min" value="18"/>
<param name="max" value="32"/>
<param name="Nmode" value="reject"/>
Expand All @@ -173,8 +178,8 @@
<output name="latticePDF" file="mouse_mir_coverage.pdf" ftype="pdf" />
<output name="coverage_dataframe" file="mouse_lattice_dataframe.tab" ftype="tabular" />
</test>
<test>
<param name="cutoption" value="yes" />
<test expect_num_outputs="4">
<param name="cutoption" value="yes"/>
<param name="min" value="15"/>
<param name="max" value="25"/>
<param name="Nmode" value="reject"/>
Expand All @@ -191,8 +196,8 @@
<output name="pre_mir_count_file" file="pre_mirs_unclipped_count.22.tab" ftype="tabular" />
<output name="mir_count_file" file="mirs_unclipped_count.22.tab" ftype="tabular" />
</test>
<test>
<param name="cutoption" value="yes" />
<test expect_num_outputs="4">
<param name="cutoption" value="yes"/>
<param name="min" value="15"/>
<param name="max" value="25"/>
<param name="Nmode" value="reject"/>
Expand All @@ -209,8 +214,8 @@
<output name="pre_mir_count_file" file="pre_mirs_unclipped_count.tab" ftype="tabular" />
<output name="mir_count_file" file="mirs_unclipped_count.tab" ftype="tabular" />
</test>
<test>
<param name="cutoption" value="yes" />
<test expect_num_outputs="6">
<param name="cutoption" value="yes"/>
<param name="min" value="15"/>
<param name="max" value="25"/>
<param name="Nmode" value="reject"/>
Expand All @@ -230,8 +235,8 @@
<output name="latticePDF" file="mir_unclipped_coverage.pdf" ftype="pdf"/>
<output name="coverage_dataframe" file="lattice_unclipped_dataframe.tab" ftype="tabular" />
</test>
<test>
<param name="cutoption" value="no" />
<test expect_num_outputs="6">
<param name="cutoption" value="no"/>
<param name="v" value="1"/>
<param name="genomeKey" value="dme"/>
<param name="mirbase_version" value="21"/>
Expand Down Expand Up @@ -259,7 +264,7 @@

This tool uses a species-specific GFF3 file generated from mirBase_ to guide the parsing of a bam file of small RNA alignments.

.. _mirBase: ftp://mirbase.org/pub/mirbase/
.. _mirBase: https://mirbase.org/download/

------

Expand Down
2 changes: 1 addition & 1 deletion tools/mircounts/test-data/aga.22.gff3
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# rather a predicted stem-loop portion that includes the precursor
# miRNA. Mature sequences have type "miRNA".
#
# generated by mature_mir_gff_translation.py 2021-05-09 00:34:02.737449
# generated by mature_mir_gff_translation.py 2024-02-10 17:38:20.268084
#
aga-bantam . miRNA_primary_transcript 1 111 . + . ID=MI0001599;Alias=MI0001599;Name=aga-bantam
aga-bantam . miRNA 70 92 . + . ID=MIMAT0001494;Alias=MIMAT0001494;Name=aga-bantam;Derives_from=MI0001599;Parent_mir_Name=aga-bantam
Expand Down
Binary file modified tools/mircounts/test-data/aga.bam
Binary file not shown.
Loading

0 comments on commit 5eb8570

Please sign in to comment.