Skip to content

Commit

Permalink
Merge pull request #339 from MSKCC-Epi-Bio/extract-patient-id
Browse files Browse the repository at this point in the history
Add extract patient function
  • Loading branch information
michaelcurry1123 authored Dec 20, 2023
2 parents 1659751 + a7198a3 commit 5759088
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gnomeR
Title: Wrangle and analyze IMPACT and TCGA mutation data
Version: 1.3.0
Version: 1.2.0.9004
Authors@R:
c(person(given = "Karissa",
family = "Whiting",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(add_pathways)
export(annotate_any_panel)
export(annotate_specific_panel)
export(create_gene_binary)
export(extract_patient_id)
export(ggcomut)
export(gggenecor)
export(ggsamplevar)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# gnomeR (development version)

- Added `extract_patient_id()` function to get IMPACT patient ID from sample ID
- Deprecated `freq_cutoff`, `freq_cutoff_by_gene`, and `gene_subset` arguments in `tbl_genomic()`. It is now recommended that users use `subset_by_frequency()` instead before passing data to `tbl_genomic()`.
- Added `other_vars` argument to `subset_by_frequency()`, `subset_by_panel()`, `summarize_by_gene()` and `add_pathways()` to allow retention of other clinical vars when using functions within pipeline.
- Deprecated `count_pathways_by` argument of `add_pathways()` function. Now, user must specify which specific alteration to count towards the pathway via the `.mut`, `.Amp`, `.Del`, `.fus` suffix (e.g. `custom_pathways = c('TP53.mut', 'APC.Del)`).
Expand Down
22 changes: 22 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,29 @@ recode_cna <- function(alteration_vector){
}


#' Extract IMPACT Patient ID From Sample ID
#'
#' @param sample_id A character vector of IMPACT Tumor sample IDs
#'
#' @return Returns a vector of patient IDs
#' @export
#'
#' @examples
#' sample_id = c("P-0000071-T01-IM3", "P-0000072-T02-IM4", "P-0000073-T03-IM5")
#' extract_patient_id(sample_id)
#'
extract_patient_id <- function(sample_id) {

# Checks ----------------------------------------------------------------
wrong_format <- sample_id[!stringr::str_detect(sample_id, "^P-\\d{1,}-T.*")]

if (length(wrong_format) > 0) {
cli::cli_abort("Some {.code sample_id} values do not match the expected IMPACT sample format (e.g `P-0000XX-T01-IM3`)")
}

patient_id = stringr::str_replace(sample_id, "-T.*", "")
return(patient_id)
}

#' Create binary data.frames depending on type of mutation data
#'
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ reference:
- recode_cna
- rename_columns
- resolve_alias
- extract_patient_id
- subtitle: Color Palette
- contents:
- gnomer_colors
Expand Down
6 changes: 3 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"codeRepository": "https://github.com/MSKCC-Epi-Bio/gnomeR",
"issueTracker": "https://github.com/MSKCC-Epi-Bio/gnomeR/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "1.3.0",
"version": "1.2.0.9004",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.2.2 (2022-10-31 ucrt)",
"runtimePlatform": "R version 4.2.3 (2023-03-15)",
"author": [
{
"@type": "Person",
Expand Down Expand Up @@ -371,7 +371,7 @@
},
"SystemRequirements": null
},
"fileSize": "2582.696KB",
"fileSize": "2349.143KB",
"releaseNotes": "https://github.com/MSKCC-Epi-Bio/gnomeR/blob/master/NEWS.md",
"readme": "https://github.com/MSKCC-Epi-Bio/gnomeR/blob/main/README.md",
"contIntegration": ["https://github.com/MSKCC-Epi-Bio/gnomeR/actions", "https://app.codecov.io/gh/MSKCC-Epi-Bio/gnomeR?branch=main"],
Expand Down
22 changes: 22 additions & 0 deletions man/extract_patient_id.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

test_that("test extracting patient_id from sample_id works", {

expect_no_error(extract_patient_id(gnomeR::mutations[1:10,]$sampleId))

})

test_that("test error thrown when non IMPACT ID", {

sample_id = c("P-0000071-T01-IM3", "XX", "P-0000073-T03-IM5")
expect_error(extract_patient_id(sample_id))

})

0 comments on commit 5759088

Please sign in to comment.