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”
URL: https://deeptools.readthedocs.io/en/develop/content/tools/computeMatrix.html
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"]),
# Optional blacklist file
# blacklist="",
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:
"v7.7.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.
Notes
[‘Bigwig DeepBlue URL, if any, should be given in params.extra, or downloaded separately.’]
Software dependencies
deeptools=3.5.6
Input/Output
Input:
bed: Path to BED or GTF files (.bed or .gtf) ANDbigwig: Path to bigWig files (.bw)
Output:
matrix_gz: gzipped matrix file (.gz) AND/ORmatrix_tab: tab-separated table of matrix file (.tab) AND/ORmatrix_bed: BED matrix file with sorted regions after skiping zeros or min/max threshold values (.bed)
Params
command: Either scale-regions or reference-pointextra: Optional parameters given to computeMatrix
Code
__author__ = "Antonie Vietor"
__copyright__ = "Copyright 2020, Antonie Vietor"
__email__ = "antonie.v@gmx.de"
__license__ = "MIT"
from snakemake.shell import shell
from tempfile import TemporaryDirectory
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
blacklist = snakemake.input.get("blacklist", "")
if blacklist:
blacklist = f"--blackListFileName {blacklist}"
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)
with TemporaryDirectory() as tempdir:
temp = ""
if "deepBlueURL" in snakemake.params.extra:
temp = f"--deepBlueTempDir {tempdir}"
shell(
"computeMatrix "
"{snakemake.params.command} "
"{snakemake.params.extra} "
"--numberOfProcessors {snakemake.threads} "
"-R {snakemake.input.bed} "
"-S {snakemake.input.bigwig} "
"-o {snakemake.output.matrix_gz} "
"{blacklist} {optional_output} {temp} {log}"
)