COOLTOOLS EIGS_TRANS
Calculate trans eigenvectors 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_eigs_trans:
input:
cooler="CN.mm9.1000kb.mcool", ## Multiresolution cooler file
track="mm9_1000000_gc.bed",
output:
vecs="CN_{resolution,[0-9]+}.trans.vecs.tsv",
lam="CN_{resolution,[0-9]+}.trans.lam.tsv",
bigwig="CN_{resolution,[0-9]+}.trans.bw",
params:
## Add optional parameters
track_col_name="GC",
extra="",
log:
"logs/CN_{resolution}_trans_eigs.log",
wrapper:
"v4.6.0/bio/cooltools/eigs_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.
Notes
[“Output files can have a {resolution} wildcard that specifies the resolution for the analysis, then it doesn’t need to be specified as a parameter.”]
Software dependencies
ucsc-bedgraphtobigwig
cooltools=0.7.0
Input/Output
Input:
a multiresolution cooler file (.mcool)
(optional) phasing track file
Output:
vecs
lams
bigwig
Params
resolution
: Optional, can be instead specified as a wildcard in the outputtrack_col_name
: Name of the column in the track file to useextra
: Any additional arguments to pass
Code
__author__ = "Ilya Flyamer"
__copyright__ = "Copyright 2022, Ilya Flyamer"
__email__ = "flyamer@gmail.com"
__license__ = "MIT"
from snakemake.shell import shell
import tempfile
## Extract arguments
# view = snakemake.input.get("view", "") # Not yet implemented
# if view:
# view = f"--view {view}"
view = ""
track = snakemake.input.get("track", "")
track_col_name = snakemake.params.get("track_col_name", "")
if track and track_col_name:
track = f"--phasing-track {track}::{track_col_name}"
elif track:
track = f"--phasing-track {track}"
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
bigwig = snakemake.output.get("bigwig", "")
if bigwig:
bigwig = "--bigwig"
resolution = snakemake.params.get("resolution", snakemake.wildcards.get("resolution"))
assert (
resolution
), "Please specify resolution either as a `wildcard` or as a `parameter`"
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"cooltools eigs-trans"
" {snakemake.input.cooler}::resolutions/{resolution} "
" {track}"
" {view} " # Not yet implemented, hardcoded to ""
" {bigwig}"
" {extra} "
" -o {tmpdir}/out"
" {log}"
)
shell("mv {tmpdir}/out.trans.vecs.tsv {snakemake.output.vecs}")
shell("mv {tmpdir}/out.trans.lam.txt {snakemake.output.lam}")
if bigwig:
shell("mv {tmpdir}/out.trans.bw {snakemake.output.bigwig}")