-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchromosome-map-deprecated.R
122 lines (119 loc) · 3.83 KB
/
chromosome-map-deprecated.R
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#------------------------------------------------
#' Create annotated chromosome map
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' This function has been deprecated as it was a simple wrapper around
#' `plot_chromoMap()` and `plot_karyoploteR()` and added unnecessary complexity
#' to function calls.
#'
#' @details
#' Render a graphics visualization of entire chromosomes or chromosomal regions.
#' Annotate multiple targeted regions to visualize probe targets.
#'
#' @param genome A tibble indicating the starting and ending position of each
#' chromosome. Contains three columns:
#' \itemize{
#' \item Name of the chromosome
#' \item The starting position of the chromosome
#' \item The ending position of the chromosome.
#' }
#' @param probes A tibble indicating the starting and ending position of each
#' probe. Contains four columns:
#' \itemize{
#' \item Name of the chromosome the probe is on
#' \item The starting position of the probe
#' \item The ending position of the probe
#' \item An identifier indicating the probe set the probe belongs to.
#' }
#' @param map_pkg The package used for the underlying implementation of the
#' chromosome map.
#' @param title The title of the plot.
#' @param colours A vector of colours indicating the annotation colour for each
#' probe set.
#' @param ... <[`dynamic-dots`][rlang::dyn-dots]> Additional arguments passed to
#' internal plotting functions.
#'
#' @return A [chromoMap][chromoMap::chromoMap] or
#' [karyoploteR](https://bernatgel.github.io/karyoploter_tutorial/) object.
#'
#' @seealso [chromoMap::chromoMap()] [karyoploteR::plotKaryotype()]
#' @keywords internal
#' @export
#' @examples
#' \donttest{
#' probes <- tibble::tribble(
#' ~chrom, ~start, ~end, ~probe_set,
#' "chr14", 2342135L, 2342284L, "IBC",
#' "chr3", 830503L, 830769L, "DR2",
#' "chr5", 482233L, 482391L, "IBC",
#' "chr9", 375274L, 375417L, "IBC",
#' "chr12", 532032L, 532281L, "DR2",
#' "chr7", 383447L, 383653L, "HAP",
#' "chr14", 1401991L, 1402160L, "IBC",
#' "chr4", 734737L, 734936L, "HAP",
#' "chr10", 93054L, 93223L, "IBC",
#' "chr7", 162127L, 162277L, "IBC"
#' )
#'
#' chromosome_map(genome_Pf3D7, probes, "chromoMap")
#' # ->
#' plot_chromoMap(genome_Pf3D7, probes)
#'
#' chromosome_map(
#' genome_Pf3D7,
#' probes,
#' "karyoploteR",
#' title = "Example Chromosome Map",
#' colours = c("#006A8EFF", "#A8A6A7FF", "#B1283AFF")
#' )
#' # ->
#' plot_karyoploteR(
#' genome_Pf3D7,
#' probes,
#' title = "Example Chromosome Map",
#' colours = c("#006A8EFF", "#A8A6A7FF", "#B1283AFF")
#' )}
chromosome_map <- function(genome,
probes,
map_pkg = c("chromoMap", "karyoploteR"),
title = "",
colours = list(),
...) {
msg <- paste(
"The function has been deprecated in favor of `plot_chromoMap()` and\n",
"`plot_karyoploteR()`."
)
lifecycle::deprecate_warn(
when = "0.2.0",
what = "chromosome_map()",
details = msg
)
# Check formatting of inputs
if (ncol(genome) != 3) {
cli_abort("Genomic information is misformatted.")
}
if (ncol(probes) != 4) {
cli_abort(c(
"Annotation information is misformatted.",
"i" = "Did you forget to indicate the probe sets?"
))
}
# Call underlying implementation
if (length(map_pkg) > 1) {
cli_abort(c(
"`map_pkg` must be of length 1.",
"i" = '`map_pkg` must be either "chromoMap" or "karyoploteR".'
))
} else if (map_pkg == "chromoMap") {
plot_chromoMap(genome, probes, title, colours)
} else if (map_pkg == "karyoploteR") {
plot_karyoploteR(genome, probes, title, colours)
} else {
cli_abort(c(
'`map_pkg` must be either "chromoMap" or "karyoploteR".',
"x" = 'You\'ve input "{ map_pkg }".'
))
}
}