Skip to content

Commit ecd442b

Browse files
authoredSep 26, 2024··
Merge pull request #169 from umccr/pcgrv2
PCGR v2 support: Handle VAF_TUMOR and ACTIONABILITY_TIER
2 parents 3c10ff5 + 353b756 commit ecd442b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed
 

‎R/pcgr.R

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#' Read PCGR Tiers TSV File
1+
#' Read PCGR TSV File
22
#'
3-
#' Reads the `snvs_indels.tiers.tsv` file output by PCGR.
4-
#' @param x Path to PCGR `snvs_indels.tiers.tsv` file.
3+
#' Reads the `snvs_indels.tiers.tsv` (or v2's `snv_indel_ann.tsv.gz`) file output
4+
#' by PCGR.
5+
#' @param x Path to PCGR `snvs_indels.tiers.tsv`/`snv_indel_ann.tsv.gz` file.
56
#' @return A tibble with the contents of the input TSV file, or NULL if x is NULL.
67
#'
78
#' @examples
@@ -24,10 +25,25 @@ pcgr_tiers_tsv_read <- function(x = NULL) {
2425
.default = "c"
2526
)
2627
)
27-
28-
assertthat::assert_that(
29-
all(c("CONSEQUENCE", "TIER", "AF_TUMOR") %in% colnames(d))
30-
)
28+
assertthat::assert_that("CONSEQUENCE" %in% colnames(d))
29+
if (!"TIER" %in% colnames(d)) {
30+
if ("ACTIONABILITY_TIER" %in% colnames(d)) {
31+
# ACTIONABILITY_TIER does not have TIER prefix
32+
d <- d |>
33+
dplyr::rename(TIER = "ACTIONABILITY_TIER") |>
34+
dplyr::mutate(TIER = paste0("TIER ", .data$TIER))
35+
} else {
36+
stop("PCGR output does not contain TIER or ACTIONABILITY_TIER column!")
37+
}
38+
}
39+
if (!"AF_TUMOR" %in% colnames(d)) {
40+
if ("VAF_TUMOR" %in% colnames(d)) {
41+
d <- d |>
42+
dplyr::rename(AF_TUMOR = "VAF_TUMOR")
43+
} else {
44+
stop("PCGR output does not contain AF_TUMOR or VAF_TUMOR column!")
45+
}
46+
}
3147

3248
d |>
3349
dplyr::mutate(

0 commit comments

Comments
 (0)
Please sign in to comment.