forked from topfm/poolER
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombine.R
More file actions
28 lines (19 loc) · 743 Bytes
/
combine.R
File metadata and controls
28 lines (19 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(tidyverse)
library(readr)
# Parse command line arguments
args <- commandArgs(trailingOnly = TRUE)
# Check if an input file was provided
if (length(args) == 0) {
stop("Please provide an input file name as a command-line argument.")
}
infile <- args[1]
input <- read_csv(infile, col_types= cols(ref = col_character(), alt= col_character()))
snpeff <- args[2]
df <- read_tsv(snpeff, skip= 5)
keep <- df %>% select('#CHROM', POS, ID, REF, ALT, INFO)
names(keep)[names(keep) == "POS"] <- "pos"
names(keep)[names(keep) == "REF"] <- "ref"
names(keep)[names(keep) == "ALT"] <- "alt"
final <- left_join(keep, input, by= c("ID", "pos", "ref", "alt"))
outfile <- gsub("_withAnnot.csv", "_snpEff.csv", infile)
write_csv(final, outfile)