label_mutations: Label mutations

View source: R/label_mutations.R

label_mutationsR Documentation

Label mutations

Description

For each data point, label a mutation as "ref", "alt", "ins", or "del".

  • Data points that have more reference (REF) than alternate (ALT) calls will be labeled as "ref".

  • Mutations whose REF and ALT calls are both one base pair and who have more ALT calls than REF calls will be labeled as "alt".

  • Mutations whose REF and ALT calls differ in length and have more ALT calls than REF calls will be labeled as "ins".

  • Mutations whose REF and ALT calls differ in length and have more REF calls than ALT calls will be labeled as "del".

Usage

label_mutations(.data, .before = NULL, .after = NULL)

## S3 method for class 'ref_alt_cov_tbl'
label_mutations(.data, .before = NULL, .after = NULL)

Arguments

.data

The data set containing REF and ALT calls.

.before, .after

[Experimental] <tidy-select> Optionally, control where new columns should appear (the default is to add to the right-hand side). See dplyr::relocate() for more details.

Value

The object .data with an added column that indicates the mutation type of each row. The column is added to the right-hand side by default, but this may be controlled by the .before and .after arguments.

Examples

# Read example data
data <- read_tbl_ref_alt_cov(
  miplicorn_example("reference_AA_table.csv"),
  miplicorn_example("alternate_AA_table.csv"),
  miplicorn_example("coverage_AA_table.csv"),
  gene == "atp6"
)

# Add ref and alt calls to data
sequences <- c("A", "T", "C", "G", "AT", "TC", "TGC")
data <- dplyr::mutate(
  data,
  ref = sample(sequences, size = nrow(data), replace = TRUE),
  alt = sample(sequences, size = nrow(data), replace = TRUE)
)

# Label the mutations
label_mutations(data)
label_mutations(data, .after = alt)

bailey-lab/miplicorn documentation built on March 19, 2023, 7:40 p.m.