Skip to content

Commit

Permalink
Update source
Browse files Browse the repository at this point in the history
  • Loading branch information
anngvu committed Feb 14, 2025
1 parent a46eab7 commit a14a1a3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/cbioportal.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ cbp_add_maf <- function(maf_data, verbose = TRUE) {

if(verbose) checked_message("Making maf meta file")
make_meta_maf(cancer_study_identifier, verbose = verbose)

if(verbose) checked_message("Making required _sequenced case list for mutation data")
make_case_list_maf(cancer_study_identifier)

if(verbose) checked_message("Done with adding MAF data")

Expand Down
26 changes: 26 additions & 0 deletions R/cboilerplate.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,31 @@ make_meta_study_generic <- function(cancer_study_identifier,
return(meta)
}

#--- Generating case list files ------------------------------------------------ #

#' Case lists for mutation samples
#'
#' https://docs.cbioportal.org/file-formats/#case-lists
#' @keywords internal
make_case_list_maf <- function(cancer_study_identifier, verbose = TRUE) {

mut <- fread("data_mutations.txt")
mut_samples <- unique(mut$Tumor_Sample_Barcode)
n <- length(mut_samples)
case_list_ids <- paste(mut_samples,collapse = "\t")
meta <- glue::glue("cancer_study_identifier: {cancer_study_identifier}") %>%
append_kv("stable_id", paste0(cancer_study_identifier, "_sequenced")) %>%
append_kv("case_list_name", "Samples with mutation data from sequencing") %>%
append_kv("case_list_description", paste0("Samples with mutation data from sequencing ", "(", n, ")")) %>%
append_kv("case_list_ids", case_list_ids)

if(!dir.exists("case_lists")) {
if(verbose) checked_message(glue::glue("Creating case_lists study directory"))
dir.create(glue::glue("./case_lists"))
}

writeLines(meta, "case_lists/case-list.txt")
}

# --- Other utils -------------------------------------------------------------- #

Expand Down Expand Up @@ -443,3 +468,4 @@ use_ref_map <- function(ref_map, as_dt = TRUE) {
return(ref_map_ls)
}
}

0 comments on commit a14a1a3

Please sign in to comment.