spike_counts {spiky} | R Documentation

## use the index of a spiked BAM/CRAM file for spike contig coverage

### Description

It dawned on me one day that we don't even have to bother reading the file if we have an index for a spiked BAM/CRAM result, since any fragments that map properly to the spike contigs are generated from synthetic templates. This function takes an index and a spike database (usually a DataFrame) as inputs and provides a rough coverage estimate over "rehabilitated" contig names (i.e., canonicalized contigs mapping to the database) as its output.

### Usage

    spike_counts(
      bam,
      spike,
      sep = "_",
      ref = "spike",
      verbose = FALSE,
      dump_idx = FALSE
    )

### Arguments

`bam` | the BAM or CRAM file (MUST HAVE AN INDEX)
`spike` | a data.frame, DataFrame, or similar with spikes
`sep` | separator character in contig names ("_")
`ref` | reference name for spike genome ("spike")
`verbose` | be verbose? (FALSE)
`dump_idx` | dump the renamed idxstats to aggregate? (FALSE)

### Details

The argument `spike` has no default since we are attempting to refactor the spike-in databases into their own data packages and allow more general use.

### Value

                   a GRanges of spike-in contig read counts

### Examples

    data(spike, package="spiky")
    sb <- system.file("extdata", "example.spike.bam", package="spiky",
                      mustWork=TRUE)
    spike_counts(sb, spike=spike)

[Package spiky version 1.0.0 Index]