COOLTOOLS EXPECTED_CIS

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/cooltools/expected_cis?label=version%20update%20pull%20requests

Calculate cis 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_cis:
    input:
        cooler="CN.mm9.1000kb.mcool",  ## Multiresolution cooler file
        view="mm9_view.txt",  ## File with the region names and coordinates
    output:
        "CN_{resolution,[0-9]+}.cis.expected.tsv",
    params:
        ## Add optional parameters
        extra="",  ## File with the chromosome names and lengths
    threads: 4
    log:
        "logs/CN_{resolution}_cis_expected.log",
    wrapper:
        "v3.12.1/bio/cooltools/expected_cis"

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.7.0

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 at each diagonal. 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-cis"
    " {snakemake.input.cooler}::resolutions/{resolution} "
    " {view} "
    " {extra} "
    " -p {snakemake.threads} "
    " -o {snakemake.output}) {log}"
)