Skip to content

Commit

Permalink
Add test, docs, and namespace for asm pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
NMNS93 committed Jan 4, 2024
1 parent 76d8327 commit 404e7ab
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 20 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(CamConfig)
export(CamSample)
export(asm_pipeline)
export(attach_output)
export(cmain_bind_snps)
export(cmain_call_cna)
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/test-asm-pipeline-after-main.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
test_that("ASM pipeline runs", {
# Run main

main_config <- CamConfig(
outdir = "./result_test",
bsseq = "wgbs",
build = "hg38",
lib = "pe",
regions = regions, # Speed up tests
n_cores = 10,
min_cov = 1, # Required to capture sufficient SNPs from test
cna_caller = "ascat" # Battenberg always recommended. ASCAT used here to speed up test
)

# Run main (skips if outputs exist)
pipeline(tumor, germline = normal, infiltrates = NULL, origin = NULL, config)

asm_pipeline(
tumor = tumor,
germline = normal,
infiltrates = normal,
origin = normal,
config = config
)

# Confirm that final output file is created
asm_out <- get_fpath(tumor, asm_config, "asm_dmp")
expect_true(file.exists(asm_out))
})
2 changes: 1 addition & 1 deletion tests/testthat/test-asm-pipeline.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("ASM pipeline runs", {
# Setup config
asm_config <- CamConfig(
outdir = "./result_asm_full", bsseq = "wgbs", lib = "pe",
outdir = "./result_asm", bsseq = "wgbs", lib = "pe",
build = "hg38", n_cores = 3, min_cov = 1, cna_caller = "ascat"
)

Expand Down
76 changes: 57 additions & 19 deletions vignettes/allele-specific.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vignette: >
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval=FALSE
eval = FALSE
)
```

Expand Down Expand Up @@ -43,22 +43,27 @@ Results from this pipeline are found in the results directory under 'PATIENT/All

## CAMDAC-ASM from BAM files

The `asm_pipeline()` function runs CAMDAC-ASM analysis by generates the allele-specific copy number solution and heterozygous SNP loci, followesd by deconvolution and differential ASM analysis:
The `asm_pipeline()` function runs CAMDAC-ASM analysis by generates the allele-specific copy number solution and heterozygous SNP loci, followed by deconvolution and differential ASM analysis:

```{r}
b_tumor <- system.file("testdata", "tumor.bam", package = "CAMDAC")
b_normal <- system.file("testdata", "normal.bam", package = "CAMDAC")
tumor <- CamSample(id="T", sex="XY", bam=b_tumor)
normal <- CamSample(id="N", sex="XY", bam=b_normal)
config <- CamConfig(outdir="./results", bsseq="wgbs", lib="pe", build="hg38", n_cores=10)
regions <- system.file("testdata", "test_wgbs_segments.bed", package = "CAMDAC") # speed up tests
tumor <- CamSample(id = "T", sex = "XY", bam = b_tumor)
normal <- CamSample(id = "N", sex = "XY", bam = b_normal)
config <- CamConfig(
outdir = "./results", ref = "./pipeline_files", bsseq = "wgbs", lib = "pe", cores = 10,
min_cov = 1, # For test data
regions = regions
)
asm_pipeline(
tumor=tumor,
germline=normal,
infiltrates=normal,
origin=normal,
config=config
tumor = tumor,
germline = normal,
infiltrates = normal,
origin = normal,
config = config
)
```

Expand All @@ -82,9 +87,13 @@ CAMDAC-ASM requires a file of heterozygous SNP loci against which CpGs will be p
First, attach your SNP loci file to the tumor object with `attach_output()`, then run `asm_pipeline()`:
```{r}
# Setup CAMDAC samples
tumor <- CamSample(id="tumor", sex="XY", bam=b_tumor)
normal <- CamSample(id="normal", sex="XY", bam=b_normal)
config <- CamConfig(outdir="./results", ref="./pipeline_files", bsseq="wgbs", lib="pe", cores=10)
tumor <- CamSample(id = "tumor", sex = "XY", bam = b_tumor)
normal <- CamSample(id = "normal", sex = "XY", bam = b_normal)
config <- CamConfig(
outdir = "./results", ref = "./pipeline_files", bsseq = "wgbs", lib = "pe", cores = 10,
min_cov = 1, # For test data
regions = regions
) # For arapid testing)
# Add SNPs
asm_snps_file <- system.file("testdata", "test_het_snps.tsv", package = "CAMDAC")
Expand All @@ -101,13 +110,42 @@ attach_output(tumor, config, "cna", cna_file)
Finally, run the allele-specific methylation pipeline:
```{r}
asm_pipeline(
tumor=tumor,
infiltrates=normal,
origin=normal,
config=config
tumor = tumor,
infiltrates = normal,
origin = normal,
config = config
)
```

## Using SNPs called from previous CAMDAC runs

If you have already run the CAMDAC pipeline in tumor-normal mode, then the tumor object's SNP files will be used by default.
If you have already run the CAMDAC pipeline in tumor-normal mode, then the germline object's SNP files will be used by default. The simplest run from BAM to ASM is shown below using matched normals for infiltrates and DMPs:

```{r}
b_tumor <- system.file("testdata", "tumor.bam", package = "CAMDAC")
b_normal <- system.file("testdata", "normal.bam", package = "CAMDAC")
regions <- system.file("testdata", "test_wgbs_segments.bed", package = "CAMDAC") # speed up tests
tumor <- CamSample(id = "T", sex = "XY", bam = b_tumor)
normal <- CamSample(id = "N", sex = "XY", bam = b_normal)
config <- CamConfig(
outdir = "./test_results", bsseq = "wgbs", lib = "pe",
build = "hg38", n_cores = 10,
regions = regions,
min_cov = 1, # For test data
cna_caller = "ascat" # Battenberg always recommended, however ASCAT used here for rapid testing.
)
# Run main CAMDAC generate SNP files for ASM
# Deconvolution skipped here for simplicity.
pipeline(tumor, germline = normal, infiltrates = NULL, origin = NULL, config)
# Run ASM pipeline
asm_pipeline(
tumor = tumor,
germline = normal,
infiltrates = normal,
origin = normal,
config = config
)
```

0 comments on commit 404e7ab

Please sign in to comment.