Skip to content

Commit c1cda25

Browse files
authored
Merge pull request #78 from umccr/devtools_fixes
Pass devtools checks
2 parents 14c1f5e + 327f170 commit c1cda25

20 files changed

+311
-228
lines changed

DESCRIPTION

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ Suggests:
4343
scales,
4444
sigrap,
4545
testthat (>= 3.0.0),
46-
tibble,
47-
tidyselect,
46+
tibble
4847
Roxygen: list(markdown = TRUE,
4948
roclets = c("namespace", "rd", "roxytest::testthat_roclet"))
5049
biocViews:

R/oncokb.R

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
#' Read OncoKB
2+
#'
3+
#' @param x Path to something.
4+
#'
5+
#' @return Vector of genes.
16
#' @export
27
read_oncokb <- function(x) {
38
readr::read_tsv(x) |>
49
dplyr::filter(
5-
`OncoKB Annotated` == "Yes"
10+
.data$`OncoKB Annotated` == "Yes"
611
) |>
712
dplyr::pull("Hugo Symbol")
813
}
914

15+
#' Get OncoKB Genes From Somewhere
16+
#'
17+
#' @param x Path to something.
18+
#' @param oncokb_genes A tibble of something.
19+
#' @return A vector I think.
20+
#'
1021
#' @export
1122
get_oncokb_genes <- function(x, oncokb_genes) {
1223
delimiters <- " ,&-"
@@ -16,9 +27,11 @@ get_oncokb_genes <- function(x, oncokb_genes) {
1627
# Create regexes for each match, utilising delimiters for boundaries. Handles most cases where a gene symbol contains the '-' delimiter
1728
purrr::map(function(n) paste0("(?<=^|", delimiter_re, ")", n, "(?=", delimiter_re, "|$)")) |>
1829
# Loop with nm iterations through regex and gene symbols
19-
purrr::map(function(n) stringr::str_detect(x, n) |> tibble::as_tibble_row(.name_repair="unique_quiet")) |>
30+
purrr::map(function(n) stringr::str_detect(x, n) |> tibble::as_tibble_row(.name_repair = "unique_quiet")) |>
2031
# Combine as tibble to access dplyr::summarise and compile list of detected OncoKB gene symbols for each effect
2132
dplyr::bind_rows() |>
22-
dplyr::summarise(dplyr::across(dplyr::everything(), function(v) { paste0(sort(oncokb_genes[v]), collapse=", ") })) |>
33+
dplyr::summarise(dplyr::across(dplyr::everything(), function(v) {
34+
paste0(sort(oncokb_genes[v]), collapse = ", ")
35+
})) |>
2336
unlist()
2437
}

R/oncoviral.R

+21-24
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
#' x <- system.file("extdata/virusbreakend/virusbreakend.vcf.summary.tsv", package = "gpgr")
1313
#' (vb <- virusbreakend_summary_read(x))
1414
#' @testexamples
15-
#' expect_equal(colnames(vb)[ncol(vb)], "QCStatus")
15+
#' expect_equal(colnames(vb$tab)[ncol(vb$tab)], "QC")
1616
#'
1717
#' @export
1818
virusbreakend_summary_read <- function(x) {
19-
2019
nm <- c(
2120
"taxid_genus" = "c",
2221
"name_genus" = "c",
@@ -44,7 +43,6 @@ virusbreakend_summary_read <- function(x) {
4443
"integrations" = "i",
4544
"QCStatus" = "c"
4645
)
47-
4846
ctypes <- paste(nm, collapse = "")
4947
virusbreakend_summary <- readr::read_tsv(x, col_types = ctypes)
5048

@@ -54,13 +52,13 @@ virusbreakend_summary_read <- function(x) {
5452

5553
virusbreakend_summary <- virusbreakend_summary |>
5654
dplyr::select(
57-
Virus="name_assigned",
58-
Length="endpos",
59-
Reads="numreads",
60-
Coverage="coverage",
61-
`Mean depth`="meandepth",
62-
Intergrations="integrations",
63-
QC="QCStatus",
55+
Virus = "name_assigned",
56+
Length = "endpos",
57+
Reads = "numreads",
58+
Coverage = "coverage",
59+
`Mean depth` = "meandepth",
60+
Intergrations = "integrations",
61+
QC = "QCStatus",
6462
)
6563
}
6664

@@ -71,7 +69,7 @@ virusbreakend_summary_read <- function(x) {
7169
"Reads", "Number of reads mapped to adjusted viral reference",
7270
"Coverage", "Percentage of viral positions with at least one read mapped",
7371
"Mean depth", "Mean alignment depth",
74-
"Intergrations", "Number of detected integration breakpoints",
72+
"Integrations", "Number of detected integration breakpoints",
7573
"QC", "QC status of viral intergrations",
7674
)
7775

@@ -95,29 +93,28 @@ virusbreakend_summary_read <- function(x) {
9593
#' x <- system.file("extdata/virusbreakend/virusbreakend.vcf", package = "gpgr")
9694
#' (vb <- virusbreakend_vcf_read(x))
9795
#' @testexamples
98-
#' expect_equal(colnames(vb)[ncol(vb)], "QC")
96+
#' expect_equal(colnames(vb$tab)[ncol(vb$tab)], "QC")
9997
#'
10098
#' @export
10199
virusbreakend_vcf_read <- function(x) {
102-
103100
d <- bedr::read.vcf(x, split.info = TRUE, verbose = FALSE)
104101

105102
if (nrow(d$vcf) > 0) {
106103
virusbreakend_integrations <- tibble::as_tibble(d$vcf) |>
107104
dplyr::select(
108-
Contig="CHROM",
109-
Position="POS",
110-
"Fragment support"="BVF",
111-
"Fragment support (unmapped)"="BUM",
112-
"Softclip read support"="BSC",
113-
Reference="REF",
114-
Alt="ALT",
115-
`Breakend ID`="ID",
116-
`Mate ID`="MATEID",
117-
QC="FILTER",
105+
Contig = "CHROM",
106+
Position = "POS",
107+
"Fragment support" = "BVF",
108+
"Fragment support (unmapped)" = "BUM",
109+
"Softclip read support" = "BSC",
110+
Reference = "REF",
111+
Alt = "ALT",
112+
`Breakend ID` = "ID",
113+
`Mate ID` = "MATEID",
114+
QC = "FILTER",
118115
)
119116
} else {
120-
virusbreakend_integrations <- tibble::tibble()
117+
virusbreakend_integrations <- tibble::tibble()
121118
}
122119

123120
descr <- dplyr::tribble(

0 commit comments

Comments
 (0)