Skip to content

Commit 7dd4216

Browse files
authored
refactor: rename REGION field to CHROM (#34)
* refactor: rename REGION field to CHROM * refactor: update renaming logic * refactor: rename REGION field to CHROM
1 parent 94e9b50 commit 7dd4216

7 files changed

Lines changed: 14 additions & 16 deletions

File tree

workflow/rules/sites.smk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ rule filter_mpileup_all_sites:
3131
output:
3232
sites_pass = temp(OUTDIR / "all_sites" / "{sample}.filtered_sites.tsv"),
3333
sites_fail = temp(OUTDIR / "all_sites" / "{sample}.fail_sites.tsv"),
34-
log:
35-
LOGDIR / "filter_mpileup_all_sites" / "{sample}.txt"
3634
run:
3735
import pandas as pd
3836
df = pd.read_csv(input[0], sep="\t")

workflow/scripts/calculate_dnds.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variants <- read_delim(
1919
col_select = c(
2020
"SAMPLE",
2121
"VARIANT_NAME",
22-
"REGION",
22+
"CHROM",
2323
"ALT_FREQ",
2424
"SYNONYMOUS",
2525
"POS"

workflow/scripts/fill_all_sites.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,25 @@ variants <- read_tsv(snakemake@input[["variants"]])
1717

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

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

2928
log_info("Processing variants")
3029
all_variants <- variants %>%
3130
# Select minimal columns
32-
select(VARIANT_NAME, REGION, SAMPLE, ALT_FREQ) %>%
31+
distinct(VARIANT_NAME, CHROM, SAMPLE, ALT_FREQ) %>%
3332
# Handle duplicates
34-
group_by(SAMPLE, VARIANT_NAME, REGION) %>%
33+
group_by(SAMPLE, VARIANT_NAME, CHROM) %>%
3534
summarise(ALT_FREQ = sum(ALT_FREQ, na.rm = TRUE), .groups = "drop") %>%
3635
# Complete with NA
37-
complete(SAMPLE, VARIANT_NAME, REGION) %>%
36+
complete(SAMPLE, VARIANT_NAME, CHROM) %>%
3837
# Assign genomic positions for all combinations
39-
left_join(variant_coords, by = c("REGION", "VARIANT_NAME")) %>%
38+
left_join(variant_coords, by = c("CHROM", "VARIANT_NAME")) %>%
4039
# Merge filtered sites
4140
# TODO: consider region/chrom
4241
left_join(sites, by = c("SAMPLE", "POS")) %>%

workflow/scripts/merge_annotation.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ merged <- left_join(
7575
) %>%
7676
mutate(
7777
SAMPLE = snakemake@params$sample
78-
)
78+
) %>%
79+
rename(CHROM = REGION)
7980

8081
log_info("Saving results")
8182
write_tsv(

workflow/scripts/report/af_time_correlation_data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ variants <- read_delim(
1919
col_select = c(
2020
"VARIANT_NAME",
2121
"SAMPLE",
22-
"REGION",
22+
"CHROM",
2323
"ALT_FREQ",
2424
"POS"
2525
)
2626
) %>%
2727
# Fill positions without alt frequency with NA
2828
complete(
29-
nesting(REGION, VARIANT_NAME, POS),
29+
nesting(CHROM, VARIANT_NAME, POS),
3030
SAMPLE,
3131
fill = list(ALT_FREQ = NA)
3232
)

workflow/scripts/report/nv_panel_data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variants <- read_delim(
1919
snakemake@input$variants,
2020
col_select = c(
2121
"SAMPLE",
22-
"REGION",
22+
"CHROM",
2323
"POS",
2424
"ALT",
2525
"VARIANT_NAME",
@@ -77,7 +77,7 @@ if (nrow(variants) == 0) {
7777
log_warning("No variants found, using an empty table")
7878
variants <- tibble(
7979
SAMPLE = date_order,
80-
REGION = as.character(NA),
80+
CHROM = as.character(NA),
8181
VARIANT_NAME = as.character(NA),
8282
ALT_FREQ = as.numeric(NA),
8383
EFFECT = as.character(NA),

workflow/scripts/report/polymorphic_sites_over_time_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (nrow(sites) == 0) {
4242
log_warn("There are none, using an empty table and no linear regression")
4343
sites <- tibble(
4444
SAMPLE = date_order,
45-
REGION = as.character(NA),
45+
CHROM = as.character(NA),
4646
VARIANT_NAME = as.character(NA),
4747
ALT_FREQ = as.numeric(NA),
4848
EFFECT = as.character(NA),

0 commit comments

Comments
 (0)