Skip to content

Commit

Permalink
cttso: support CopyNumberVariants.vcf.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
pdiakumis committed Nov 28, 2023
1 parent 2003e0f commit b875fac
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(PloidyEstimationMetricsFile)
export(ReplayFile)
export(TimeMetricsFile)
export(TsoAlignCollapseFusionCallerMetricsFile)
export(TsoCopyNumberVariantsVcfFile)
export(TsoFragmentLengthHistFile)
export(TsoFusionsCsvFile)
export(TsoMergedSmallVariantsVcfFile)
Expand Down
4 changes: 3 additions & 1 deletion R/regex.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ DR_FILE_REGEX <- tibble::tribble(
"SampleAnalysisResults\\.json\\.gz$", "TsoSampleAnalysisResultsFile",
"MergedSmallVariants\\.vcf\\.gz$", "TsoMergedSmallVariantsVcfFile",
"MergedSmallVariants\\.vcf\\.gz\\.tbi$", "TsoMergedSmallVariantsVcfIndexFile",
"CopyNumberVariants\\.vcf\\.gz$", "TsoCopyNumberVariantsVcfFile",
"CopyNumberVariants\\.vcf\\.gz\\.tbi$", "TsoCopyNumberVariantsVcfIndexFile",
"fastqc_metrics\\.csv$", "NULL",
"insert-stats\\.tab$", "NULL",
"sv_metrics\\.csv$", "NULL",
Expand All @@ -65,7 +67,7 @@ DR_FILE_REGEX <- tibble::tribble(
"-qc_summary\\.tsv\\.gz$", "UmQcSumFile"
)

FILES_DOWNLOAD_BUT_IGNORE <- c("TsoMergedSmallVariantsVcfIndexFile")
FILES_DOWNLOAD_BUT_IGNORE <- c("TsoMergedSmallVariantsVcfIndexFile", "TsoMergedSmallVariantsVcfIndexFile")

#' Evaluate dracarys Function
#'
Expand Down
50 changes: 49 additions & 1 deletion R/tso.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
#' TsoCopyNumberVariantsVcfFile R6 Class
#'
#' @description
#' Contains methods for reading and displaying contents of the
#' `CopyNumberVariants.vcf.gz` file output from TSO.
#'
#' @examples
#' \dontrun{
#' x <- normalizePath("~/icav1/g/production/analysis_data/SBJ00704/tso_ctdna_tumor_only/202311242b9666e0/L2301411/Results/PTC_ctTSO231120_L2301411/dracarys_gds_sync/PTC_ctTSO231120_L2301411_CopyNumberVariants.vcf.gz")
#' d <- TsoCopyNumberVariantsVcfFile$new(x)
#' d_parsed <- d$read() # or read(d)
#' d$write(d_parsed, out_dir = tempdir(), prefix = "sample705", out_format = "tsv")
#' d$write(d_parsed, prefix = "FOO", out_format = "delta", drid = "wfr.123")
#' }
#' @export
TsoCopyNumberVariantsVcfFile <- R6::R6Class(
"TsoCopyNumberVariantsVcfFile",
inherit = File,
public = list(
#' @description
#' Reads the `CopyNumberVariants.vcf.gz` file output from TSO.
#'
#' @return tibble with variants.
read = function() {
x <- self$path
bcftools_parse_vcf(x, only_pass = TRUE)
},
#' @description
#' Writes a tidy version of the `CopyNumberVariants.vcf.gz` file output from TSO.
#'
#' @param d Parsed object from `self$read()`.
#' @param prefix Prefix of output file(s).
#' @param out_dir Output directory.
#' @param out_format Format of output file(s).
#' @param drid dracarys ID to use for the dataset (e.g. `wfrid.123`, `prid.456`).
write = function(d, out_dir = NULL, prefix, out_format = "tsv", drid = NULL) {
if (!is.null(out_dir)) {
prefix <- file.path(out_dir, prefix)
}
# prefix2 <- glue("{prefix}copynumber_variants")
write_dracarys(obj = d, prefix = prefix, out_format = out_format, drid = drid)
}
)
)
#' TsoMergedSmallVariantsVcfFile R6 Class
#'
#' @description
Expand Down Expand Up @@ -367,7 +411,11 @@ TsoFusionsCsvFile <- R6::R6Class(
BP2_Depth = "d", Total_Depth = "d", VAF = "d", Gene1 = "c", Gene2 = "c",
Contig = "c", Filter = "c", Is_Cosmic_GenePair = "l"
)
readr::read_csv(x, col_types = ct, comment = "#")
res <- readr::read_csv(x, col_types = ct, comment = "#")
if (nrow(res) == 0) {
return(empty_tbl(cnames = names(ct)))
}
return(res)
},

#' @description
Expand Down
101 changes: 101 additions & 0 deletions man/TsoCopyNumberVariantsVcfFile.Rd

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

0 comments on commit b875fac

Please sign in to comment.