Add the missing annotation ref summary [CW-7271]
This commit is contained in:
parent
50b971604e
commit
020d555219
@ -220,6 +220,17 @@ def _load_bambu_qc(bambu_dir):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _load_annotation_reference_summary(summary_file):
|
||||||
|
"""Load reference/annotation preparation summary JSON from a file path."""
|
||||||
|
if summary_file is None:
|
||||||
|
return None
|
||||||
|
summary_path = Path(summary_file)
|
||||||
|
if summary_path.exists():
|
||||||
|
with open(summary_path) as f:
|
||||||
|
return json.load(f)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _load_de_qc(de_dir):
|
def _load_de_qc(de_dir):
|
||||||
"""Load DE/DTU QC statistics JSON."""
|
"""Load DE/DTU QC statistics JSON."""
|
||||||
qc_file = Path(de_dir) / "de_qc_stats.json"
|
qc_file = Path(de_dir) / "de_qc_stats.json"
|
||||||
@ -229,15 +240,6 @@ def _load_de_qc(de_dir):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _load_annotation_reference_summary(cohort_dir):
|
|
||||||
"""Load reference/annotation preparation summary JSON."""
|
|
||||||
summary_file = Path(cohort_dir) / "reference" / "annotation_reference_summary.json"
|
|
||||||
if summary_file.exists():
|
|
||||||
with open(summary_file) as f:
|
|
||||||
return json.load(f)
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _load_cpm_tables(cohort_dir):
|
def _load_cpm_tables(cohort_dir):
|
||||||
"""Load cohort-level gene and transcript CPM tables."""
|
"""Load cohort-level gene and transcript CPM tables."""
|
||||||
cohort_dir = Path(cohort_dir)
|
cohort_dir = Path(cohort_dir)
|
||||||
@ -478,8 +480,7 @@ def main(args):
|
|||||||
.rename(columns={"index": "Field"}),
|
.rename(columns={"index": "Field"}),
|
||||||
use_index=False,
|
use_index=False,
|
||||||
)
|
)
|
||||||
|
annotation_reference_summary = _load_annotation_reference_summary(args.ref_summary)
|
||||||
annotation_reference_summary = _load_annotation_reference_summary(args.cohort_dir)
|
|
||||||
|
|
||||||
if annotation_reference_summary:
|
if annotation_reference_summary:
|
||||||
with report.add_section("Reference and Annotation Checks", "Reference"):
|
with report.add_section("Reference and Annotation Checks", "Reference"):
|
||||||
@ -1210,6 +1211,11 @@ def argparser():
|
|||||||
default=None,
|
default=None,
|
||||||
help="Differential analysis directory.",
|
help="Differential analysis directory.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ref_summary",
|
||||||
|
default=None,
|
||||||
|
help="Annotation reference summary TSV.",
|
||||||
|
)
|
||||||
parser.add_argument("--versions", required=True, help="Versions directory.")
|
parser.add_argument("--versions", required=True, help="Versions directory.")
|
||||||
parser.add_argument("--params", required=True, help="Workflow params JSON.")
|
parser.add_argument("--params", required=True, help="Workflow params JSON.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
@ -145,6 +145,8 @@ def _build_report_args(tmp_path, de_qc=None):
|
|||||||
str(alignment_stats),
|
str(alignment_stats),
|
||||||
"--cohort_dir",
|
"--cohort_dir",
|
||||||
str(cohort),
|
str(cohort),
|
||||||
|
"--ref_summary",
|
||||||
|
str(reference / "annotation_reference_summary.json"),
|
||||||
"--samples_dir",
|
"--samples_dir",
|
||||||
str(samples),
|
str(samples),
|
||||||
"--sqanti_dir",
|
"--sqanti_dir",
|
||||||
@ -229,6 +231,8 @@ def test_report_main_accepts_optional_file_sentinels(monkeypatch, tmp_path):
|
|||||||
str(alignment_stats),
|
str(alignment_stats),
|
||||||
"--cohort_dir",
|
"--cohort_dir",
|
||||||
str(cohort),
|
str(cohort),
|
||||||
|
"--ref_summary",
|
||||||
|
str(cohort / "reference" / "annotation_reference_summary.json"),
|
||||||
"--samples_dir",
|
"--samples_dir",
|
||||||
str(samples),
|
str(samples),
|
||||||
"--sqanti_dir",
|
"--sqanti_dir",
|
||||||
@ -351,6 +355,8 @@ def test_report_main_handles_degenerate_bambu_qc_and_read_summary(
|
|||||||
str(alignment_stats),
|
str(alignment_stats),
|
||||||
"--cohort_dir",
|
"--cohort_dir",
|
||||||
str(cohort),
|
str(cohort),
|
||||||
|
"--ref_summary",
|
||||||
|
str(cohort / "reference" / "annotation_reference_summary.json"),
|
||||||
"--samples_dir",
|
"--samples_dir",
|
||||||
str(samples),
|
str(samples),
|
||||||
"--sqanti_dir",
|
"--sqanti_dir",
|
||||||
@ -411,6 +417,24 @@ def test_report_main_uses_cohort_bambu_qc_for_multi_sample_inputs(
|
|||||||
|
|
||||||
cohort = tmp_path / "cohort"
|
cohort = tmp_path / "cohort"
|
||||||
cohort.mkdir()
|
cohort.mkdir()
|
||||||
|
reference = cohort / "reference"
|
||||||
|
reference.mkdir()
|
||||||
|
_write(
|
||||||
|
reference / "annotation_reference_summary.json",
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"seqname_overlap": ["chr1"],
|
||||||
|
"only_in_annotation": [],
|
||||||
|
"only_in_reference": [],
|
||||||
|
"annotation": {
|
||||||
|
"kept_records": 10,
|
||||||
|
"excluded_unstranded_records": 0,
|
||||||
|
"sanitised_attribute_records": 0,
|
||||||
|
},
|
||||||
|
"warnings": [],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
_write(
|
_write(
|
||||||
cohort / "bambu_qc_stats.json",
|
cohort / "bambu_qc_stats.json",
|
||||||
json.dumps(
|
json.dumps(
|
||||||
@ -478,6 +502,8 @@ def test_report_main_uses_cohort_bambu_qc_for_multi_sample_inputs(
|
|||||||
str(alignment_stats),
|
str(alignment_stats),
|
||||||
"--cohort_dir",
|
"--cohort_dir",
|
||||||
str(cohort),
|
str(cohort),
|
||||||
|
"--ref_summary",
|
||||||
|
str(cohort / "reference" / "annotation_reference_summary.json"),
|
||||||
"--samples_dir",
|
"--samples_dir",
|
||||||
str(samples),
|
str(samples),
|
||||||
"--sqanti_dir",
|
"--sqanti_dir",
|
||||||
|
|||||||
@ -93,7 +93,9 @@ def test_load_annotation_reference_summary_exists(tmp_path):
|
|||||||
with open(summary_dir / "annotation_reference_summary.json", "w") as f:
|
with open(summary_dir / "annotation_reference_summary.json", "w") as f:
|
||||||
json.dump(summary_data, f)
|
json.dump(summary_data, f)
|
||||||
|
|
||||||
result = _load_annotation_reference_summary(tmp_path / "cohort")
|
result = _load_annotation_reference_summary(
|
||||||
|
summary_dir / "annotation_reference_summary.json"
|
||||||
|
)
|
||||||
assert result is not None
|
assert result is not None
|
||||||
assert result["seqname_overlap"] == ["chr1"]
|
assert result["seqname_overlap"] == ["chr1"]
|
||||||
assert result["only_in_annotation"] == ["chrMissing"]
|
assert result["only_in_annotation"] == ["chrMissing"]
|
||||||
@ -106,7 +108,9 @@ def test_load_annotation_reference_summary_missing(tmp_path):
|
|||||||
cohort_dir = tmp_path / "cohort"
|
cohort_dir = tmp_path / "cohort"
|
||||||
cohort_dir.mkdir()
|
cohort_dir.mkdir()
|
||||||
|
|
||||||
result = _load_annotation_reference_summary(cohort_dir)
|
result = _load_annotation_reference_summary(
|
||||||
|
cohort_dir / "reference" / "annotation_reference_summary.json"
|
||||||
|
)
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
main.nf
3
main.nf
@ -43,6 +43,7 @@ process makeReport {
|
|||||||
path sample_dirs, stageAs: "samples/*"
|
path sample_dirs, stageAs: "samples/*"
|
||||||
path sqanti_dirs, stageAs: "sqanti/*"
|
path sqanti_dirs, stageAs: "sqanti/*"
|
||||||
path de_files
|
path de_files
|
||||||
|
path "annotation_reference_summary.tsv"
|
||||||
val wf_version
|
val wf_version
|
||||||
output:
|
output:
|
||||||
path "wf-transcriptomes-report.html", emit: report
|
path "wf-transcriptomes-report.html", emit: report
|
||||||
@ -63,6 +64,7 @@ process makeReport {
|
|||||||
${de_args} \
|
${de_args} \
|
||||||
--versions versions \
|
--versions versions \
|
||||||
--params params.json \
|
--params params.json \
|
||||||
|
--ref_summary annotation_reference_summary.tsv \
|
||||||
--wf_version ${wf_version}
|
--wf_version ${wf_version}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
@ -202,6 +204,7 @@ workflow pipeline {
|
|||||||
sample_dirs_for_report,
|
sample_dirs_for_report,
|
||||||
sqanti_dirs_for_report,
|
sqanti_dirs_for_report,
|
||||||
de_dir,
|
de_dir,
|
||||||
|
transcriptome.annotation_reference_summary,
|
||||||
workflow.manifest.version
|
workflow.manifest.version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user