@@ -17,26 +17,25 @@ variants <- read_tsv(snakemake@input[["variants"]])
1717
1818# Create a mapping of variant names to their genomic position
1919variant_coords <- variants %> %
20- select(VARIANT_NAME , REGION , POS ) %> %
20+ select(VARIANT_NAME , CHROM , POS ) %> %
2121 distinct()
2222
2323log_info(" Reading filtered sites" )
2424sites <- 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
2928log_info(" Processing variants" )
3029all_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" )) %> %
0 commit comments