Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions workflow/rules/sites.smk
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ rule filter_mpileup_all_sites:
output:
sites_pass = temp(OUTDIR / "all_sites" / "{sample}.filtered_sites.tsv"),
sites_fail = temp(OUTDIR / "all_sites" / "{sample}.fail_sites.tsv"),
log:
LOGDIR / "filter_mpileup_all_sites" / "{sample}.txt"
run:
import pandas as pd
df = pd.read_csv(input[0], sep="\t")
Expand Down
2 changes: 1 addition & 1 deletion workflow/scripts/calculate_dnds.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ variants <- read_delim(
col_select = c(
"SAMPLE",
"VARIANT_NAME",
"REGION",
"CHROM",
"ALT_FREQ",
"SYNONYMOUS",
"POS"
Expand Down
13 changes: 6 additions & 7 deletions workflow/scripts/fill_all_sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ variants <- read_tsv(snakemake@input[["variants"]])

# Create a mapping of variant names to their genomic position
variant_coords <- variants %>%
select(VARIANT_NAME, REGION, POS) %>%
select(VARIANT_NAME, CHROM, POS) %>%
distinct()

log_info("Reading filtered sites")
sites <- read_tsv(snakemake@input[["sites"]]) %>%
select(SAMPLE, POS) %>% # TODO: consider region/chrom
distinct() %>%
distinct(SAMPLE, POS) %>% # TODO: consider region/chrom
mutate(FILTER_PASS = TRUE)

log_info("Processing variants")
all_variants <- variants %>%
# Select minimal columns
select(VARIANT_NAME, REGION, SAMPLE, ALT_FREQ) %>%
distinct(VARIANT_NAME, CHROM, SAMPLE, ALT_FREQ) %>%
# Handle duplicates
group_by(SAMPLE, VARIANT_NAME, REGION) %>%
group_by(SAMPLE, VARIANT_NAME, CHROM) %>%
summarise(ALT_FREQ = sum(ALT_FREQ, na.rm = TRUE), .groups = "drop") %>%
# Complete with NA
complete(SAMPLE, VARIANT_NAME, REGION) %>%
complete(SAMPLE, VARIANT_NAME, CHROM) %>%
# Assign genomic positions for all combinations
left_join(variant_coords, by = c("REGION", "VARIANT_NAME")) %>%
left_join(variant_coords, by = c("CHROM", "VARIANT_NAME")) %>%
# Merge filtered sites
# TODO: consider region/chrom
left_join(sites, by = c("SAMPLE", "POS")) %>%
Expand Down
3 changes: 2 additions & 1 deletion workflow/scripts/merge_annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ merged <- left_join(
) %>%
mutate(
SAMPLE = snakemake@params$sample
)
) %>%
rename(CHROM = REGION)

log_info("Saving results")
write_tsv(
Expand Down
4 changes: 2 additions & 2 deletions workflow/scripts/report/af_time_correlation_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ variants <- read_delim(
col_select = c(
"VARIANT_NAME",
"SAMPLE",
"REGION",
"CHROM",
"ALT_FREQ",
"POS"
)
) %>%
# Fill positions without alt frequency with NA
complete(
nesting(REGION, VARIANT_NAME, POS),
nesting(CHROM, VARIANT_NAME, POS),
SAMPLE,
fill = list(ALT_FREQ = NA)
)
Expand Down
4 changes: 2 additions & 2 deletions workflow/scripts/report/nv_panel_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ variants <- read_delim(
snakemake@input$variants,
col_select = c(
"SAMPLE",
"REGION",
"CHROM",
"POS",
"ALT",
"VARIANT_NAME",
Expand Down Expand Up @@ -77,7 +77,7 @@ if (nrow(variants) == 0) {
log_warning("No variants found, using an empty table")
variants <- tibble(
SAMPLE = date_order,
REGION = as.character(NA),
CHROM = as.character(NA),
VARIANT_NAME = as.character(NA),
ALT_FREQ = as.numeric(NA),
EFFECT = as.character(NA),
Expand Down
2 changes: 1 addition & 1 deletion workflow/scripts/report/polymorphic_sites_over_time_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (nrow(sites) == 0) {
log_warn("There are none, using an empty table and no linear regression")
sites <- tibble(
SAMPLE = date_order,
REGION = as.character(NA),
CHROM = as.character(NA),
VARIANT_NAME = as.character(NA),
ALT_FREQ = as.numeric(NA),
EFFECT = as.character(NA),
Expand Down
Loading