-
Notifications
You must be signed in to change notification settings - Fork 2
/
metagen.sh
executable file
·69 lines (55 loc) · 2.6 KB
/
metagen.sh
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
#!/bin/bash
# Exit on error
set -e
path="$1"
DB="$2"
echo $path
# Functions
printToLog() {
date +"%F__%T ---> $1"
}
usage () {
printf "USAGE:\n"
printf "metagen.sh <path_to_fastq> <DB>\n\n"
}
exitWithError () {
printf "\n***ERROR: $1\n\n"
usage
exit
}
# Check params
if [ "$#" -ne 2 ]; then
exitWithError "Missing parameters"
fi
# Create log directory
rm -rf "$path/logs"; mkdir "$path/logs"
rm -rf "$path/out"; mkdir "$path/out"
rm -rf "$path/out/plots/reads_distributions"
mkdir -p "$path/out/plots/reads_distributions"
# Base Pipeline - generate required outputs
printf "\nRunning DADA2 pipeline...\n\n"
Rscript /home/makis/tools/metagen/dada2_pipeline.R "$path" "$DB" >"$path"/logs/out 2>"$path"/logs/error
# Display filtered reads distribution
printf "\nRunning FastQ Screen pipeline...\n\n"
for i in `ls "$path"/fastq/filtered/`; do
/home/makis/tools/FastQ-Screen-0.14.1/fastq_screen "$path"/fastq/filtered/$i --outdir "$path/out/plots/reads_distributions" --threads 16 --subset 0 >>"$path"/logs/out 2>>"$path"/logs/error
done
# Add additional info in data_trunc.tsc (Data Filtering table)
printf "\nRunning Data Filtering pipeline...\n\n"
Rscript /home/makis/tools/metagen/enrich_dataFiltering.R "$path" >>"$path"/logs/out 2>>"$path"/logs/error
# Run picrust2 pipeline
printf "\nRunning PICRUSt2 pipeline...\n\n"
printToLog "Running functional annotation..." >>"$path"/logs/out 2>>"$path"/logs/error
source ~/tools/miniconda3/etc/profile.d/conda.sh
conda activate picrust2
picrust2_pipeline.py -s "$path"/out/asv.fasta -i "$path"/out/my.biom -o "$path"/out/functionalAnn_out -p 16 >>"$path"/logs/out 2>>"$path"/logs/error
printToLog "Adding KEGG_ID descriptions..." >>"$path"/logs/out 2>>"$path"/logs/error
add_descriptions.py -i "$path"/out/functionalAnn_out/EC_metagenome_out/pred_metagenome_unstrat.tsv.gz -m EC -o "$path"/out/functionalAnn_out/EC_metagenome_out/pred_metagenome_unstrat_descrip.tsv.gz >>"$path"/logs/out 2>>"$path"/logs/error
add_descriptions.py -i "$path"/out/functionalAnn_out/pathways_out/path_abun_unstrat.tsv.gz -m METACYC -o "$path"/out/functionalAnn_out/pathways_out/path_abun_unstrat_descrip.tsv.gz >>"$path"/logs/out 2>>"$path"/logs/error
conda deactivate
# Generate rmd report
printf "\nRunning phyloseq RMD pipeline...\n\n"
printToLog "Generating visualizations and Rmarkdown report ..." >>"$path"/logs/out 2>>"$path"/logs/error
Rscript -e "path = '$path'; DB= '$DB'; rmarkdown::render('/home/makis/tools/metagen/metagen.Rmd', output_file = paste0(path,'metagen_report.html'), output_dir = path)" >>$1/logs/out 2>>$1/logs/error
printf "\nAnalysis Complete! \n\n"
printf "\nResults in $path \n\n"