COOLTOOLS EXPECTED_TRANS

Calculate trans expected for a resolution in an .mcool file

URL: https://github.com/open2c/cooltools

Example

This wrapper can be used in the following way:

rule cooltools_expected_trans:
    input:
        cooler="CN.mm9.1000kb.mcool",  ## Multiresolution cooler file
        view="mm9_view.txt",  ## File with the region names and coordinates
    output:
        "{sample}_{resolution,[0-9]+}.trans.expected.tsv",
    params:
        ## Add optional parameters
        extra="",
    threads: 4
    log:
        "logs/{sample}_{resolution}_trans_expected.log",
    wrapper:
        "v1.9.0/bio/cooltools/expected_trans"

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

  • cooltools=0.5

Input/Output

Input:

  • a multiresolution cooler file (.mcool)
  • (optional) view, a bed-style file with region coordinates and names to use for analysis

Output:

  • A .tsv file with mean interaction frequency between chromosomes. Can have a {resolution} wildcard that specifies the resolution for the analysis, then it doesn’t need to be specified as a parameter.

Params

  • resolution: Optional, can be instead specified as a wildcard in the output
  • extra: Any additional arguments to pass

Authors

  • Ilya Flyamer

Code

__author__ = "Ilya Flyamer"
__copyright__ = "Copyright 2022, Ilya Flyamer"
__email__ = "flyamer@gmail.com"
__license__ = "MIT"

from snakemake.shell import shell

## Extract arguments
view = snakemake.input.get("view", "")
if view:
    view = f"--view {view}"
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

resolution = snakemake.params.get(
    "resolution", snakemake.wildcards.get("resolution", 0)
)
if not resolution:
    raise ValueError("Please specify resolution either as a wildcard or as a parameter")

shell(
    "(cooltools expected-trans"
    " {snakemake.input.cooler}::resolutions/{resolution} "
    " {view} "
    " -p {snakemake.threads} "
    " {extra} "
    " -o {snakemake.output}) {log}"
)