From fea9f8c3dc61d4b0f921749620bae4a1f35fe396 Mon Sep 17 00:00:00 2001 From: Zilong-Li Date: Tue, 30 Apr 2024 08:51:59 +0200 Subject: [PATCH] input of vcfcomp can be saved RDS file --- R/vcf-compare.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/vcf-compare.R b/R/vcf-compare.R index e3316dc..a9629f6 100644 --- a/R/vcf-compare.R +++ b/R/vcf-compare.R @@ -5,7 +5,7 @@ #' \code{vcfcomp} implements various statisitcs to compare two VCF/BCF files, #' e.g. report genotype concocrdance, correlation stratified by allele frequency. #' -#' @param test path to the first VCF/BCF file referred as test. +#' @param test path to the first VCF/BCF file referred as test, or saved RDS file. #' #' @param truth path to the second VCF/BCF file referred as truth, or saved RDS file. #' @@ -78,7 +78,9 @@ vcfcomp <- function(test, truth, formats[1] <- "GT" } collapse <- ifelse(stats=="pse", FALSE, TRUE) - d1 <- vcftable(test, format = formats[1], setid = TRUE, collapse = collapse, ...) + d1 <- tryCatch( { suppressWarnings(readRDS(test)) }, error = function(e) { + vcftable(test, format = formats[1], setid = TRUE, collapse = collapse, ...) + } ) d2 <- tryCatch( { suppressWarnings(readRDS(truth)) }, error = function(e) { vcftable(truth, format = formats[2], setid = TRUE, collapse = collapse, ...) } )