DEEPTOOLS COMPUTEMATRIX

deepTools computeMatrix calculates scores per genomic region. The matrix file can be used as input for other tools or for the generation of a deepTools plotHeatmap or deepTools plotProfiles. For usage information about deepTools computeMatrix, please see the documentation. For more information about deepTools, also see the source code.

computeMatrix option Output format

Name of output

variable to be used

Recommended

extension

–outFileName, -out, -o gzipped matrix file

matrix_gz

(required)

“.gz”
–outFileNameMatrix

tab-separated table of

matrix file

matrix_tab “.tab”
–outFileSortedRegions

BED matrix file with sorted

regions after skipping zeros

or min/max threshold values

matrix_bed “.bed”

Example

This wrapper can be used in the following way:

rule compute_matrix:
    input:
         # Please note that the -R and -S options are defined via input files
         bed=expand("{sample}.bed", sample=["a", "b"]),
         bigwig=expand("{sample}.bw", sample=["a", "b"])
    output:
        # Please note that --outFileName, --outFileNameMatrix and --outFileSortedRegions are exclusively defined via output files.
        # Usable output variables, their extensions and which option they implicitly call are listed here:
        #         https://snakemake-wrappers.readthedocs.io/en/stable/wrappers/deeptools/computematrix.html.
        matrix_gz="matrix_files/matrix.gz",   # required
        # optional output files
        matrix_tab="matrix_files/matrix.tab",
        matrix_bed="matrix_files/matrix.bed"
    log:
        "logs/deeptools/compute_matrix.log"
    params:
        # required argument, choose "scale-regions" or "reference-point"
        command="scale-regions",
        # optional parameters
        extra="--regionBodyLength 200 --verbose"
    wrapper:
        "0.72.0/bio/deeptools/computematrix"

Note that input, output and log file paths can be chosen freely. When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • deeptools==3.4.3

Input/Output

Input:

  • BED or GTF files (.bed or .gtf) AND
  • bigWig files (.bw)

Output:

  • gzipped matrix file (.gz) AND/OR
  • tab-separated table of matrix file (.tab) AND/OR
  • BED matrix file with sorted regions after skiping zeros or min/max threshold values (.bed)

Authors

  • Antonie Vietor

Code

__author__ = "Antonie Vietor"
__copyright__ = "Copyright 2020, Antonie Vietor"
__email__ = "antonie.v@gmx.de"
__license__ = "MIT"

from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=True, stderr=True)

out_tab = snakemake.output.get("matrix_tab")
out_bed = snakemake.output.get("matrix_bed")

optional_output = ""

if out_tab:
    optional_output += " --outFileNameMatrix {out_tab} ".format(out_tab=out_tab)

if out_bed:
    optional_output += " --outFileSortedRegions {out_bed} ".format(out_bed=out_bed)

shell(
    "(computeMatrix "
    "{snakemake.params.command} "
    "{snakemake.params.extra} "
    "-R {snakemake.input.bed} "
    "-S {snakemake.input.bigwig} "
    "-o {snakemake.output.matrix_gz} "
    "{optional_output}) {log}"
)