File: get_ref_alt.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 (49 lines) | stat: -rw-r--r-- 1,128 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#' get REF column from GRanges
#'
#' Retreives the REF column from a GRanges object.
#' This can be spelled as REF, Ref or ref.
#'
#' @param gr GRanges object
#'
#' @return DNAStringSet
#' @noRd
#'
.get_ref <- function(gr) {
  gr_cols <- colnames(S4Vectors::mcols(gr))
  if ("REF" %in% gr_cols) {
    ref <- gr$REF
  } else if ("ref" %in% gr_cols) {
    ref <- gr$ref
  } else if ("Ref" %in% gr_cols) {
    ref <- gr$Ref
  } else {
    stop("Some of your data is missing a REF column.", call. = FALSE)
    ref <- Biostrings::DNAStringSet()
  }
  return(ref)
}

#' get ALT column from GRanges
#'
#' Retreives the ALT column from a GRanges object.
#' This can be spelled as ALT, Alt or alt
#'
#' @param gr GRanges object
#'
#' @return DNAStringSetList
#' @noRd
#'
.get_alt <- function(gr) {
  gr_cols <- colnames(S4Vectors::mcols(gr))
  if ("ALT" %in% gr_cols) {
    alt <- gr$ALT
  } else if ("alt" %in% gr_cols) {
    alt <- gr$alt
  } else if ("Alt" %in% gr_cols) {
    alt <- gr$Alt
  } else {
    stop("Some of your data is missing a ALT column.", call. = FALSE)
    alt <- Biostrings::DNAStringSetList()
  }
  return(alt)
}