Skip to content

Commit

Permalink
feat: cooltools wrappers (#519)
Browse files Browse the repository at this point in the history
* First try cooltools insulation wrapper

* Fix env formatting?

* Fix test workflow

* add comments to snakefile

* Add expected, add view to insulation

* Add eigenvector wrappers

* Add forgotten tests

* Add saddle, fix so tests pass

* Remove file path for saddle

* Add pileup, small fixes

* FIx pileup meta

* Add genome binnify and gc

* Remove unnecessary empty view assignment

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>

* Remove unnecessary empty view assignment

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>

* Remove unnecessary empty view assignment

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>

* Requested fixes

* Small fixes in gc and binnify wrappers

* Simplify environment

* Requested changes - env, view input, all outputs

* Add example with track for eigs

* Remove extra newline?

* Move note to notes

* Suggested changes, and better wrapper for saddle

* Fix for no fig in saddle

* Only get fig once

* Removed unnecessary else

* Removed format

* Add cooltools dots wrapper

* Changed pinned version

* Remove unnecessary param

* Remove unnecessary import

* Add small test file for dots

* Move view description to input

* Update bio/cooltools/dots/environment.yaml

* Update bio/cooltools/dots/test/Snakefile

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
3 people committed Aug 16, 2022
1 parent eea67d4 commit d28de15
Show file tree
Hide file tree
Showing 67 changed files with 72,321 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bio/cooltools/dots/environment.yaml
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- scikit-learn==1.0 # doesn't work with 1.1
- cooltools =0.5
19 changes: 19 additions & 0 deletions bio/cooltools/dots/meta.yaml
@@ -0,0 +1,19 @@
name: cooltools dots
description: Calculate cis eigenvectors for a resolution in an .mcool file
url: https://github.com/open2c/cooltools
authors:
- Ilya Flyamer
input:
- a multiresolution cooler file (.mcool)
- an expected file
- (optional) view, a bed-style file with region coordinates and names to use for analysis
output:
- >
A .bedpe file with coordinates of detected dots.
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
notes:
15 changes: 15 additions & 0 deletions bio/cooltools/dots/test/Snakefile
@@ -0,0 +1,15 @@

rule cooltools_dots:
input:
cooler="small_test.mcool", ## Multiresolution cooler file
expected="test_expected.tsv", ## Expected file
view="test_view.txt", ## File with the region names and coordinates
output:
"HFF_{resolution,[0-9]+}.dots.bedpe",
params:
extra="", ## Add extra parameters
threads: 4
log:
"logs/HFF_{resolution}_dots.log",
wrapper:
"master/bio/cooltools/dots"
Binary file added bio/cooltools/dots/test/small_test.mcool
Binary file not shown.
2,473 changes: 2,473 additions & 0 deletions bio/cooltools/dots/test/test_expected.tsv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bio/cooltools/dots/test/test_view.txt
@@ -0,0 +1 @@
chr17 0 24714921 chr17_p
34 changes: 34 additions & 0 deletions bio/cooltools/dots/wrapper.py
@@ -0,0 +1,34 @@
__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}"

expected = snakemake.input.get("expected", "")

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 ressolution either as a wildcard or as a parameter"
)

shell(
"(cooltools dots"
" {snakemake.input.cooler}::resolutions/{resolution} "
" {expected} "
" {view} "
" -p {snakemake.threads} "
" {extra} "
" -o {snakemake.output}) {log}"
)
7 changes: 7 additions & 0 deletions bio/cooltools/eigs_cis/environment.yaml
@@ -0,0 +1,7 @@
channels:
- conda-forge
- defaults
- bioconda
dependencies:
- ucsc-bedgraphtobigwig
- cooltools =0.5
22 changes: 22 additions & 0 deletions bio/cooltools/eigs_cis/meta.yaml
@@ -0,0 +1,22 @@
name: cooltools eigs_cis
description: Calculate cis eigenvectors for a resolution in an .mcool file
url: https://github.com/open2c/cooltools
authors:
- Ilya Flyamer
input:
- a multiresolution cooler file (.mcool)
- (optional) phasing track file
- (optional) view, a bed-style file with region coordinates and names to use for analysis
output:
vecs: A .tsv file with values of cis eigenvectors at each bin.
lams: A file with eigenvalues
bigwig: A .bigwig file for visualization of the first eigenvector
params:
resolution: >
Optional, can be instead specified as a wildcard in the output
track_col_name: >
Name of the column in the track file to use
extra: Any additional arguments to pass
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.
Binary file added bio/cooltools/eigs_cis/test/CN.mm9.1000kb.mcool
Binary file not shown.
17 changes: 17 additions & 0 deletions bio/cooltools/eigs_cis/test/Snakefile
@@ -0,0 +1,17 @@
rule cooltools_eigs_cis:
input:
cooler="CN.mm9.1000kb.mcool", ## Multiresolution cooler file
view="mm9_view.txt", ## File with the region names and coordinates
track="mm9_1000000_gc.bed",
output:
vecs="CN_{resolution,[0-9]+}.cis.vecs.tsv",
lam="CN_{resolution,[0-9]+}.cis.lam.tsv",
bigwig="CN_{resolution,[0-9]+}.cis.bw",
params:
## Add optional parameters
track_col_name="GC",
extra="",
log:
"logs/CN_{resolution}_cis_eigs.log",
wrapper:
"master/bio/cooltools/eigs_cis"

0 comments on commit d28de15

Please sign in to comment.