Skip to contents

Calculates base substitution counts for ref and base counts stored in nx4 matrix bases. ref must have only one reference base. A->G is okay, but AG->G is NOT allowed! If bc is not provided, count the substitutions of the largest non-reference base (@seealso max_observed_bc). Make sure that number of alleles in ref(erence) and bases is 2 at maximum.

Usage

sub_counts(ref, bases, bc = NULL)

Arguments

ref

vector of reference bases.

bases

matrix of observed base call counts.

bc

vector strings that represent observed base calls. Default: NULL.

Value

vector of base call substitution counts.

Examples

ref <- c("A", "A", "T")
# Only one non-ref. base
bases <- matrix(c( 1,  0, 9, 0,
                   5,  0, 5, 0,
                   0, 10, 0, 0),
                ncol = 4, byrow = TRUE)
# show base substitution counts for observed base calls
sub_counts(ref, bases)
#> [1]  9  5 10

# > one non-ref. base
bases <- matrix(c( 1,  2, 9, 1,
                   5,  3, 5, 1,
                   2, 10, 2, 1),
                ncol = 4, byrow = TRUE)
# we are only interested in A->G, T->C
bc <- c("G", "G", "C")
# show base substitution counts for A->G, T->C
sub_counts(ref, bases, bc)
#> [1]  9  5 10