-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathseq_denovovar.R
45 lines (35 loc) · 1.61 KB
/
seq_denovovar.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
# Function: seq_denovovar.R
# License: GPLv3 or later
# Modification date: 24 Mar 2021
# Written by: Marco Milanesi
# Contact: [email protected]
# Description: variant calling from BAM file
# Usage: R < seq_denovovar.R --vanilla --args [vcffile] [trios] [ncores] [email]
# Libraries ---------------------------------------------------------------------------------------
library(parallel)
# Programs ----------------------------------------------------------------------------------------
bcftools <- "/media/AP_storage/AP_storage/SOFTWARE/bcftools-1.12/bin/bcftools-1.12"
# User arguments ----------------------------------------------------------------------------------
argv <- commandArgs(T)
vcffile <- argv[1]
trios <- argv[2]
ncores <- argv[3]
email <- argv[4]
# Run Pipeline ------------------------------------------------------------------------------------
#Function
denovo <- function(x){
infile <- vcffile[x]
outfile <- basename(infile)
outfile <- gsub(pattern = ".vcf.gz", replacement = "", x = outfile)
command <- paste0("bcftools-1.12 +mendelian -m x ",infile," -T ",trios," -Oz -o ",outfile,"_DENOVO.vcf.gz")
system(command)
command <- paste0("bcftools-1.12 +mendelian ",infile," -T ",trios," -o ",outfile,".log")
system(command)
}
#Import vcf file
vcffile <- read.table(file = vcffile, header = F, stringsAsFactors = F)[,1]
#Run the function
log <- mclapply(X = 1:length(vcffile), FUN = denovo, mc.cores = ncores)
#End of analyses - send email
command <- paste0("echo 'Dear,\nthe variant calling is finished. Check the results!' | mail -s 'DeNovo variant identification' ",email)
system(command)