Runs a CNV pipeline on each sample: counts fragments in fixed-size genomic windows, normalises for GC and mappability (HMMcopy), segments, and stores per-window copy-number in the qseaSet. Supports parallel execution. Only GRCh38/hg38 is currently supported.

addHMMcopyCNV(
  qs,
  inputColumn = "input_file",
  windowSize = 1e+06,
  fragmentLength = NULL,
  plotDir = NULL,
  parallel = getMesaParallel(),
  maxInsertSize = 1000,
  minInsertSize = 50,
  minReferenceLength = 30,
  minMapQual = 30,
  properPairsOnly = FALSE,
  hmmCopyGC = NULL,
  hmmCopyMap = NULL
)

Arguments

qs

qseaSet. Input object whose samples will receive CNV tracks.

inputColumn

character(1). Column in the sample table containing BAM paths (e.g. "input_file"). Default: "input_file".

windowSize

integer(1). CNV bin size in bp. Allowed values: 50000, 500000, 1000000. Default: 1000000.

fragmentLength

integer(1) or NULL. Length to extend unpaired R1 reads; if NULL, estimate from proper pairs. Default: NULL.

plotDir

character(1) or NULL. Directory to write per-sample PDF diagnostics; if NULL, no plots are saved. Default: NULL.

parallel

logical(1). Use the registered BiocParallel backend when TRUE; otherwise run serially. Default: getMesaParallel().

maxInsertSize

integer(1). Maximum insert size to accept for proper pairs (bp). Default: 1000.

minInsertSize

integer(1). Minimum insert size to accept for proper pairs (bp). Default: 50.

minReferenceLength

integer(1). Minimum aligned reference span for unpaired R1 (bp). Default: 30.

minMapQual

integer(1). Minimum MAPQ; for pairs, either end meeting the cutoff is accepted. Default: 30.

properPairsOnly

logical(1). If TRUE, ignore unpaired R1; if FALSE, combine proper pairs with high-quality R1. Default: FALSE.

hmmCopyGC

GRanges or NULL. Precomputed GC content track binned at windowSize. Default: NULL.

hmmCopyMap

GRanges or NULL. Precomputed mappability track binned at windowSize. Default: NULL.

Value

The input qseaSet with CNV information attached, including:

  • per-window CNV tracks accessible via downstream CNV accessors,

  • library/sample tables updated with relevant CNV/coverage summaries,

  • (optionally) per-sample diagnostic PDFs if plotDir is provided.

Details

Coverage is obtained (pairs + optional R1) over tiled windows, corrected with HMMcopy (HMMcopy::correctReadcount() followed by HMMcopy::HMMsegment()), and merged back into the qseaSet. You must supply GC/mappability tracks binned at the same windowSize (or use package-provided defaults where applicable). When parallel = TRUE, computation uses the currently registered backend (see BiocParallel::register()).

See also

runHMMcopy(), plotCNVheatmap(), getBamCoveragePairedAndUnpairedR1() (internal low-level worker), HMMcopy::correctReadcount(), HMMcopy::HMMsegment(), BiocParallel::register()

Other CNV: plotCNVheatmap(), removeCNV(), runHMMCopy()

Examples

if (FALSE) { # \dontrun{
data(exampleTumourNormal, package = "mesa")
exampleTumourNormal %>%

    addHMMcopyCNV(
        inputColumn = "input_file",
        windowSize = 1e6,
        hmmCopyGC = gc_hg38_1000kb, # GRanges with 'gc' column
        hmmCopyMap = map_hg38_1000kb, # GRanges with 'map' column
        properPairsOnly = TRUE,
        parallel = FALSE,
        plotDir = tempdir()
    )
} # }