File: mut_type.R

package info (click to toggle)
r-bioc-mutationalpatterns 3.16.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,360 kB
  • sloc: sh: 8; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Retrieve base substitution types from a VCF object
#'
#' A function to extract the base substitutions from a vcf and translate to
#' the 6 common base substitution types.
#'
#' @param vcf A CollapsedVCF object
#' @return Character vector with base substitution types
#'
#' @examples
#' ## See the 'read_vcfs_as_granges()' example for how we obtained the
#' ## following data:
#' vcfs <- readRDS(system.file("states/read_vcfs_as_granges_output.rds",
#'   package = "MutationalPatterns"
#' ))
#'
#' mut_type(vcfs[[1]])
#' @seealso
#' \code{\link{read_vcfs_as_granges}}
#'
#' @export

mut_type <- function(vcf) {
  muts <- mutations_from_vcf(vcf)
  types <- unlist(muts)
  types <- gsub("G>T", "C>A", types)
  types <- gsub("G>C", "C>G", types)
  types <- gsub("G>A", "C>T", types)
  types <- gsub("A>T", "T>A", types)
  types <- gsub("A>G", "T>C", types)
  types <- gsub("A>C", "T>G", types)
  return(types)
}