-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
303 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
!wgbs_pipeline/*/ | ||
!Cargo.* | ||
!conf/* | ||
!requirements*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
matplotlib==3.0.2 | ||
multiprocess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
beautifulsoup4==4.8.2 | ||
pandas==1.0.4 | ||
qc-utils>=20.6.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"pearson_correlation": {"pearson_correlation": 0.9446482132888102}} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"wgbs.benchmark_mode": true, | ||
"wgbs.extra_reference": "tests/data/conversion_control.fa.gz", | ||
"wgbs.fastqs": [ | ||
[ | ||
[ | ||
"tests/data/sample5_data_1_200000.fastq.gz", | ||
"tests/data/sample5_data_2_200000.fastq.gz" | ||
] | ||
], | ||
[ | ||
[ | ||
"tests/data/sample5_data_1_200000_s100_100000.fastq.gz", | ||
"tests/data/sample5_data_2_200000_s100_100000.fastq.gz" | ||
] | ||
] | ||
], | ||
"wgbs.include_conf_file": "/software/conf/IHEC_standard.conf", | ||
"wgbs.indexed_contig_sizes": "tests/data/sacCer3.contig.sizes", | ||
"wgbs.indexed_reference": "tests/data/indexes.tar.gz", | ||
"wgbs.reference": "tests/data/sacCer3.fa.gz", | ||
"wgbs.run_bsmooth": false, | ||
"wgbs.underconversion_sequence_name": "NC_001416.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
import math | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.workflow("test_wgbs_two_reps") | ||
def test_wgbs_two_reps_check_pearson_qc(workflow_dir, test_data_dir): | ||
with open(test_data_dir / "bed_pearson_correlation_qc.json") as f: | ||
expected_qc = json.load(f) | ||
|
||
result_path = next( | ||
(workflow_dir / "test-output").glob( | ||
"wgbs/*/call-calculate_bed_pearson_correlation/execution/bed_pearson_correlation_qc.json" | ||
) | ||
) | ||
with open(result_path) as f: | ||
result_qc = json.load(f) | ||
|
||
result = result_qc["pearson_correlation"]["pearson_correlation"] | ||
expected = expected_qc["pearson_correlation"]["pearson_correlation"] | ||
assert math.isclose(result, expected, rel_tol=1e-5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: test_wgbs_two_reps | ||
tags: | ||
- functional | ||
# Float output in the QC is subject to rounding errors, need custom comparison. Due | ||
# to path collisons we cannot use relative output paths for Cromwell outputs, wf | ||
# will fail otherwise. | ||
command: >- | ||
tests/caper_run.sh | ||
wgbs-pipeline.wdl | ||
tests/functional/json/test_wgbs_two_reps.json | ||
--no-relative-output-paths |
4 changes: 4 additions & 0 deletions
4
tests/integration/json/test_calculate_bed_pearson_correlation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"test_calculate_bed_pearson_correlation.bed1": "tests/data/encode_cpg_10e5.bed.gz", | ||
"test_calculate_bed_pearson_correlation.bed2": "tests/data/encode_cpg_10e5_gt_10x_coverage.bed.gz" | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/integration/test_calculate_bed_pearson_correlation.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: test_calculate_bed_pearson_correlation | ||
tags: | ||
- integration | ||
command: >- | ||
tests/caper_run.sh | ||
tests/integration/wdl/test_calculate_bed_pearson_correlation.wdl | ||
tests/integration/json/test_calculate_bed_pearson_correlation.json | ||
files: | ||
- path: test-output/bed_pearson_correlation_qc.json | ||
md5sum: cddfd85f87898abeff6701f1c58c71f7 |
11 changes: 11 additions & 0 deletions
11
tests/integration/wdl/test_calculate_bed_pearson_correlation.wdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "../../../wgbs-pipeline.wdl" as wgbs | ||
|
||
workflow test_calculate_bed_pearson_correlation { | ||
File bed1 | ||
File bed2 | ||
|
||
call wgbs.calculate_bed_pearson_correlation { input: | ||
bed1 = bed1, | ||
bed2 = bed2, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"default_runtime_attributes": { | ||
"docker_user": "$EUID" | ||
}, | ||
"final_workflow_outputs_dir": "test-output", | ||
"maxRetries": 1, | ||
"use_relative_output_paths": false | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from contextlib import suppress as does_not_raise | ||
from io import BytesIO | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from wgbs_pipeline.calculate_bed_pearson_correlation import ( | ||
DF_COLUMN_NAMES, | ||
calculate_pearson, | ||
get_parser, | ||
load_bedmethyl, | ||
make_pearson_qc, | ||
) | ||
|
||
|
||
def test_load_bedmethyl(): | ||
data = BytesIO( | ||
( | ||
b'track name="ENCSR156JXJ" description="ENCSR156JXJ" visibility=2 itemRgb="' | ||
b'On"\nchr1\t10468\t10469\t"ENCSR156JXJ"\t1\t+\t10468\t10469\t255,0,0\t1\t1' | ||
b"00\tCG\tCG\t2" | ||
) | ||
) | ||
df = load_bedmethyl(data) | ||
assert df.shape[0] == 1 | ||
expected = ("chr1", 10468, 10469, 1, 100) | ||
for key, expected in zip(DF_COLUMN_NAMES, expected): | ||
assert df.at[0, key] == expected | ||
|
||
|
||
def test_calculate_pearson(): | ||
df1 = pd.DataFrame.from_records( | ||
[("chr1", 1, 2, 14, 50), ("chr1", 3, 4, 12, 100), ("chr1", 5, 6, 3, 100)], | ||
columns=DF_COLUMN_NAMES, | ||
) | ||
df2 = pd.DataFrame.from_records( | ||
[ | ||
("chr1", 1, 2, 16, 25), | ||
("chr1", 3, 4, 12, 50), | ||
("chr1", 5, 6, 3, 100), | ||
("chr1", 7, 8, 3, 100), | ||
], | ||
columns=DF_COLUMN_NAMES, | ||
) | ||
pearson = calculate_pearson(df1, df2) | ||
assert pearson == 1.0 | ||
|
||
|
||
def test_make_pearson_qc(): | ||
qc = make_pearson_qc(0.33) | ||
assert dict(qc.to_ordered_dict()) == { | ||
"pearson_correlation": {"pearson_correlation": 0.33} | ||
} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"condition,args", | ||
[ | ||
(does_not_raise(), ["--bedmethyls", "foo", "bar", "--outfile", "baz"]), | ||
(pytest.raises(SystemExit), ["--bedmethyls", "foo", "--outfile", "baz"]), | ||
], | ||
) | ||
def test_get_parser(condition, args): | ||
parser = get_parser() | ||
with condition: | ||
parser.parse_args(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.