-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05parsing_vep_data.R
72 lines (51 loc) · 1.48 KB
/
05parsing_vep_data.R
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env Rscript
#################
## LIBRARIES ##
#################
suppressPackageStartupMessages(suppressWarnings({
library(dplyr)
library(glue)
library(stringr)
library(readr)
}))
########################
## SAMPLES AND GENE ##
########################
params <- commandArgs(trailingOnly = TRUE)
sample_list <- params[2:length(params)]
print(glue(">>> This is your sample list: {sample_list}"))
gene_filter <- params[1]
print(glue(">>> This is your gene: {gene_filter}"))
####################
## EXECUTION LOOP ##
####################
for(sample in sample_list){
sample_file <- glue("results/variants/vep/{sample}.txt")
#####################
## READING DATA ##
## AND ##
## PROCESSESING ##
#####################
rows_skip <- tibble(
our_vector = scan(
file=sample_file,
what = character(),
quiet = TRUE,
sep = "\n")) %>%
filter(str_detect(our_vector,"^##")) %>%
nrow()
variants_selec <- read_table(sample_file,
skip=as.numeric(rows_skip)) %>%
filter(SYMBOL == glue("{gene_filter}")) %>%
mutate(sample=glue("{sample}"))
colnames(variants_selec) <- tolower(colnames(variants_selec))
########################
## SAVING PARSED DATA ##
########################
write_tsv(x = variants_selec,
file = glue("results/biostatistics/tables/{sample}.tsv"))
variants_selec %>% print(n=6)
}
print("##==========================##")
print("##===> WORK FINISHED!!! <===##")
print("##==========================##")