Skip to content

Commit

Permalink
Fix empty VCF check
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmig committed Apr 16, 2024
1 parent f5bbc56 commit 470b61b
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions workflow/scripts/report/NV_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ library(logger)
log_threshold(INFO)


empty_vcf <- function() {
tibble(
variant = character(),
REGION = character(),
ALT_FREQ = numeric(),
GFF_FEATURE = character(),
synonimous = character(),
POS = numeric(),
ALT = character(),
NV_class = character(),
NV_colors = character(),
group = character()
)
}


# Import file with plots style
source(snakemake@params[["design"]])

Expand Down Expand Up @@ -150,15 +166,7 @@ log_info("Plotting summary figure for whole genome")

if (nrow(vcf) == 0) {
log_warn("Whole-genome VCF has no rows")
vcf <- tibble(
variant = character(),
REGION = character(),
ALT_FREQ = numeric(),
GFF_FEATURE = character(),
synonimous = character(),
POS = numeric(),
ALT = character()
)
vcf <- empty_vcf()
}

variants <- vcf %>%
Expand Down Expand Up @@ -312,15 +320,7 @@ window_plot_spike <- window %>%

if (nrow(vcf_spike) == 0) {
log_warn("Spike VCF has no rows")
vcf_spike <- tibble(
variant = character(),
REGION = character(),
ALT_FREQ = numeric(),
GFF_FEATURE = character(),
synonimous = character(),
POS = numeric(),
ALT = character()
)
vcf_spike <- empty_vcf()
}

variants_spike <- vcf_spike %>%
Expand Down Expand Up @@ -387,6 +387,11 @@ figur_SNP_table <- vcf_snp %>%
) %>%
ungroup()

if (nrow(figur_SNP_table) == 0) {
log_warn("Filtered SNP table has no rows")
figur_SNP_table <- empty_vcf()
}

figur_SNP_time <- figur_SNP_table %>%
ggplot() +
aes(
Expand Down

0 comments on commit 470b61b

Please sign in to comment.