From 0997adf59b9e631e1b61a62b48419e3adde03320 Mon Sep 17 00:00:00 2001 From: Brett Copeland Date: Wed, 23 Jun 2021 01:32:34 -0700 Subject: [PATCH] Added wrapper for rsem-generate-data-matrix. (#374) * Added wrapper for rsem-generate-data-matrix. * Added a second results file to demonstrate merging. --- bio/rsem/generate-data-matrix/environment.yaml | 4 ++++ bio/rsem/generate-data-matrix/meta.yaml | 11 +++++++++++ bio/rsem/generate-data-matrix/test/Snakefile | 14 ++++++++++++++ .../generate-data-matrix/test/a.genes.results | 2 ++ .../generate-data-matrix/test/b.genes.results | 2 ++ bio/rsem/generate-data-matrix/wrapper.py | 17 +++++++++++++++++ test.py | 8 ++++++++ 7 files changed, 58 insertions(+) create mode 100644 bio/rsem/generate-data-matrix/environment.yaml create mode 100644 bio/rsem/generate-data-matrix/meta.yaml create mode 100644 bio/rsem/generate-data-matrix/test/Snakefile create mode 100644 bio/rsem/generate-data-matrix/test/a.genes.results create mode 100644 bio/rsem/generate-data-matrix/test/b.genes.results create mode 100644 bio/rsem/generate-data-matrix/wrapper.py diff --git a/bio/rsem/generate-data-matrix/environment.yaml b/bio/rsem/generate-data-matrix/environment.yaml new file mode 100644 index 00000000000..2637f709fbc --- /dev/null +++ b/bio/rsem/generate-data-matrix/environment.yaml @@ -0,0 +1,4 @@ +channels: + - bioconda +dependencies: + - rsem ==1.3.3 diff --git a/bio/rsem/generate-data-matrix/meta.yaml b/bio/rsem/generate-data-matrix/meta.yaml new file mode 100644 index 00000000000..9780957febb --- /dev/null +++ b/bio/rsem/generate-data-matrix/meta.yaml @@ -0,0 +1,11 @@ +name: rsem generate data matrix +description: | + Run rsem-generate-data-matrix to combine a set of single-sample rsem results into a single matrix. +authors: + - Brett Copeland +input: + - a list of rsem results files +output: + - Quantification results summarized by allele/gene/isoform per sample +notes: | + * For more information, see https://github.com/deweylab/RSEM. diff --git a/bio/rsem/generate-data-matrix/test/Snakefile b/bio/rsem/generate-data-matrix/test/Snakefile new file mode 100644 index 00000000000..1701cd1ab8d --- /dev/null +++ b/bio/rsem/generate-data-matrix/test/Snakefile @@ -0,0 +1,14 @@ +rule rsem_generate_data_matrix: + input: + # one or more expression files created by rsem-calculate-expression + ["a.genes.results", "b.genes.results"], + output: + # a tsv containing each sample in the input as a column + "genes.results", + params: + # optional additional parameters + extra="", + log: + "logs/rsem/generate_data_matrix.log", + wrapper: + "master/bio/rsem/generate-data-matrix" diff --git a/bio/rsem/generate-data-matrix/test/a.genes.results b/bio/rsem/generate-data-matrix/test/a.genes.results new file mode 100644 index 00000000000..b9772cd16d1 --- /dev/null +++ b/bio/rsem/generate-data-matrix/test/a.genes.results @@ -0,0 +1,2 @@ +gene_id transcript_id(s) length effective_length expected_count TPM FPKM +Sheila Sheila 20.00 20.00 0.00 0.00 0.00 diff --git a/bio/rsem/generate-data-matrix/test/b.genes.results b/bio/rsem/generate-data-matrix/test/b.genes.results new file mode 100644 index 00000000000..ebdf3046fec --- /dev/null +++ b/bio/rsem/generate-data-matrix/test/b.genes.results @@ -0,0 +1,2 @@ +gene_id transcript_id(s) length effective_length expected_count TPM FPKM +Sheila Sheila 20.00 20.00 1.00 1.00 1.00 diff --git a/bio/rsem/generate-data-matrix/wrapper.py b/bio/rsem/generate-data-matrix/wrapper.py new file mode 100644 index 00000000000..f6f5a09299e --- /dev/null +++ b/bio/rsem/generate-data-matrix/wrapper.py @@ -0,0 +1,17 @@ +__author__ = "Brett Copeland" +__copyright__ = "Copyright 2021, Brett Copeland" +__email__ = "brcopeland@ucsd.edu" +__license__ = "MIT" + + +import os + +from snakemake.shell import shell + +extra = snakemake.params.get("extra", "") +log = snakemake.log_fmt_shell(stdout=False, stderr=True) +shell( + "rsem-generate-data-matrix {extra} " + "{snakemake.input} > {snakemake.output} " + "{log}" +) diff --git a/test.py b/test.py index 6cf757787d5..674b097af6f 100644 --- a/test.py +++ b/test.py @@ -3935,3 +3935,11 @@ def test_rsem_prepare_reference(): "bio/rsem/prepare-reference", ["snakemake", "--cores", "1", "--use-conda", "-F"], ) + + +@skip_if_not_modified +def test_generate_data_matrix(): + run( + "bio/rsem/generate-data-matrix", + ["snakemake", "--cores", "1", "--use-conda", "-F"], + )