Results from analyze_peaks can be visualised with this function, specifying what type of segment one wishes to plot.

* Simple clonal CNAs. Gray panels are placeholders for segments among `1:0`, `2:0`, `1:1`, `2:1`, and `2:2` that are available for the sample. Each vertical dashed line is an expected peak, the bandwidth around being the tolerance we use to match peaks (based on purity_error, adjusted for segment ploidy and tumour purity). Each dot is a peak detected from data, with a bandwidth of tolerance (fixed) around it. Note that: i) a green peak is matched, a red one is mismatched; ii) the overall segment QC is given by the colour of the facet; iii) the overall sample QC is given by the box surrounding the whole figure assembly and iv) options of function `plot_peaks_analysis` allow to separate the plots.

* Complex clonal CNAs. The plot is similar to the one for simple segments, but no segment-level or sample-level scores are produced.

* Subclonal simple CNAs. The layout of this plot is the same of complex clonal CNAs; not that the facet reports the distinct evolutionary models that have been generated to QC subclonal CNAs. The model in CNAqc ranks the proposed evolutionary alternatives (linear versus branching) based on the number of matched peaks. A subclonal segment with many matched peaks is likely to be correct.

plot_peaks_analysis(
  x,
  empty_plot = TRUE,
  assembly_plot = TRUE,
  what = "simple"
)

Arguments

x

A CNAqc object.

empty_plot

For simple clonal CNAs, if data for one karyotype is missing an empty plot is returned. Otherwise the plot is not returned (NULL is forwarded).

assembly_plot

For simple clonal CNAs, if TRUE, a unique figure is returned with all the plots assembled. Otherwise a list of plot is returned.

what

What analysis should be plot:

- Value `common` or `simple` refers to clonal karyotypes used for sample-level QC. - `general` or `complex` for all the others. - `subclonal` is for subclonal segments.

Value

A single ggpubr figure or a list of `ggplot2` figures.

Examples

data('example_dataset_CNAqc', package = 'CNAqc')
x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity)
#> 
#> ── CNAqc - CNA Quality Check ───────────────────────────────────────────────────
#> 
#>  Using reference genome coordinates for: GRCh38.
#>  Found annotated driver mutations: TTN, CTCF, and TP53.
#>  Fortified calls for 12963 somatic mutations: 12963 SNVs (100%) and 0 indels.
#> ! CNAs have no CCF, assuming clonal CNAs (CCF = 1).
#>  Fortified CNAs for 267 segments: 267 clonal and 0 subclonal.
#>  12963 mutations mapped to clonal CNAs.

# Analyse first, then plot
x = analyze_peaks(x)
#> 
#> ── Peak analysis: simple CNAs ──────────────────────────────────────────────────
#> 
#>  Analysing 9041 mutations mapping to karyotype(s) 2:2 and 2:1.
#>  Mixed type peak detection for karyotype 2:1 (1563 mutations)
#>  Mixed type peak detection for karyotype 2:2 (7478 mutations)
#> # A tibble: 4 × 16
#> # Rowwise: 
#>   mutation_multiplicity karyotype  peak delta_vaf     x     y counts_per_bin
#>                   <dbl> <chr>     <dbl>     <dbl> <dbl> <dbl>          <int>
#> 1                     1 2:2       0.235   0.00700 0.24   0.85             65
#> 2                     2 2:2       0.471   0.0140  0.461  8.13            625
#> 3                     1 2:1       0.308   0.0120  0.306  3.60             59
#> 4                     2 2:1       0.616   0.0239  0.602  2.93             60
#> # ℹ 9 more variables: discarded <lgl>, from <chr>, offset_VAF <dbl>,
#> #   offset <dbl>, weight <dbl>, epsilon <dbl>, VAF_tolerance <dbl>,
#> #   matched <lgl>, QC <chr>
#>  Peak detection PASS with r = 0.0077628258037083 - maximum purity error ε = 0.05.
#> Joining with `by = join_by(Major, minor)`
#> Joining with `by = join_by(karyotype)`
#> 
#> ── Peak analysis: complex CNAs ─────────────────────────────────────────────────
#> 
#>  Karyotypes 4:2, 3:2, and 3:0 with >100 mutation(s). Using epsilon = 0.05.
#> # A tibble: 3 × 5
#> # Groups:   karyotype, matched [3]
#>   karyotype n           matched mismatched  prop
#>   <chr>     <table[1d]>   <int>      <dbl> <dbl>
#> 1 3:0        312              3          0     1
#> 2 3:2       1625              3          0     1
#> 3 4:2       1893              4          0     1
#> Adding missing grouping variables: `matched`
#> Joining with `by = join_by(Major, minor, QC_PASS)`
#> Adding missing grouping variables: `matched`
#> Joining with `by = join_by(karyotype, QC_PASS)`
#> 
#> ── Peak analysis: subclonal CNAs ───────────────────────────────────────────────
#> 
#>  No subclonal CNAs in this sample.

plot_peaks_analysis(x)