From 435c223e8bca781a42354320eb0aac3214f5cad1 Mon Sep 17 00:00:00 2001 From: naumenko-sa Date: Fri, 14 Jun 2019 00:15:16 -0400 Subject: [PATCH] fixed an issue when platypus.subset table is empty --- cre.sh | 3 ++- cre.vcf2db.R | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cre.sh b/cre.sh index c77f465..206d708 100755 --- a/cre.sh +++ b/cre.sh @@ -207,7 +207,8 @@ function f_make_report vcf.gatk.get_depth.sh $fprefix.subset.vcf.gz $reference fi - #gemini.decompose.sh ${family}-platypus.vcf.gz + # gemini.decompose.sh ${family}-platypus.vcf.gz + # there might a case when platypus subset vcf is empty fprefix=${family}-platypus-annotated-decomposed if [ -f $fprefix.vcf.gz ] then diff --git a/cre.vcf2db.R b/cre.vcf2db.R index d9df802..6f9d964 100644 --- a/cre.vcf2db.R +++ b/cre.vcf2db.R @@ -468,12 +468,13 @@ merge_reports <- function(family, samples){ platypus_file <- paste0(family, "-platypus-annotated-decomposed.table") if(file.exists(platypus_file)){ platypus <- read.delim(platypus_file, stringsAsFactors = F) - platypus$superindex <- with(platypus, paste(paste0(CHROM,":",POS), REF, ALT, sep = '-')) - platypus[c("CHROM", "POS", "REF", "ALT")] <- NULL - ensemble <- merge(ensemble, platypus, by.x = "superindex", by.y = "superindex", + if (nrow(platypus) > 0){ + platypus$superindex <- with(platypus, paste(paste0(CHROM,":",POS), REF, ALT, sep = '-')) + platypus[c("CHROM", "POS", "REF", "ALT")] <- NULL + ensemble <- merge(ensemble, platypus, by.x = "superindex", by.y = "superindex", all.x = T, all.y = F) - for (i in 1:nrow(ensemble)){ + for (i in 1:nrow(ensemble)){ #if(grepl("NA",ensemble[i,"Trio_coverage"])) - wrong, may be 10/10/NA in gatk #if (ensemble[i,"Trio_coverage"]=="NA/NA/NA") if (str_count(ensemble[i,"Trio_coverage"],"NA") == length(samples)){ @@ -503,6 +504,7 @@ merge_reports <- function(family, samples){ n_sample <- n_sample + 1 } } + } } for (sample in samples){