-
Notifications
You must be signed in to change notification settings - Fork 14
/
make_panel_report.sh
executable file
·99 lines (79 loc) · 3.31 KB
/
make_panel_report.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
readonly DIR_SCRIPT=$(
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
pwd -P
)
## load settings
# shellcheck source=common.cfg.sh
. "${DIR_SCRIPT}"/common.cfg.sh
function usage() {
echo "usage: miracum_pipe.sh -d dir [-h]"
echo " -d dir specify relative folder of patient"
echo " -h show this help screen"
exit 1
}
while getopts d:h option; do
case "${option}" in
d) readonly PARAM_DIR_PATIENT=$OPTARG ;;
h) usage ;;
\?)
echo "Unknown option: -$OPTARG" >&2
exit 1
;;
:)
echo "Missing option argument for -$OPTARG" >&2
exit 1
;;
*)
echo "Unimplemented option: -$OPTARG" >&2
exit 1
;;
esac
done
# if no patient is defined
if [[ -z "${PARAM_DIR_PATIENT}" ]]; then
echo "no patient defined."
echo "--"
usage
fi
# load patient yaml
readonly CFG_SEX=$(get_config_value sex "${PARAM_DIR_PATIENT}")
if [[ "$(get_config_value common.protocol "${PARAM_DIR_PATIENT}")" = "panel" ]]; then
readonly CFG_CASE=panelTumor
fi
# check inputs
readonly VALID_SEXES=("XX XY")
if [[ ! " ${VALID_SEXES[@]} " =~ " ${CFG_SEX} " ]]; then
echo "unknown sex: ${CFG_SEX}"
echo "use one of the following values: $(join_by ' ' ${VALID_SEXES})"
exit 1
fi
##################################################################################################################
## load programs
# shellcheck source=programs.cfg.sh
. "${DIR_SCRIPT}/programs.cfg.sh"
##################################################################################################################
cd "${DIR_ANALYSES}" || exit 1
# execute Main.R, i.e. complete analyses in R
${BIN_RSCRIPT} "${DIR_RSCRIPT}/Main.R" "${CFG_CASE}" "${PARAM_DIR_PATIENT}" "${CFG_FILE_GERMLINE_R1}" "${CFG_FILE_TUMOR_R1}" \
"${DIR_TARGET}" "${DIR_RSCRIPT}" "${DIR_DATABASE}" "${CFG_REFERENCE_CAPTUREGENES}" "${CFG_REFERENCE_COVEREDREGION}" \
"${CFG_AUTHOR}" "${CFG_CENTER}" "${CFG_REFERENCE_CAPTUREREGIONS}" "${CFG_REFERENCE_CAPTUREREGIONNAME}" "${FILE_GENOME}" \
"${CFG_REFERENCE_CAPTURECORFACTORS}" "${CFG_GENERAL_MINVAF}" "${CFG_PANEL_VARSCAN_FPFILTER_MINVARCOUNT}" "${CFG_GENERAL_MAFCUTOFF}" \
"${CFG_REFERENCE_ACTIONABLEGENES}" "${CFG_REFERENCE_COVERED_EXONS}" "${CFG_ENTITY}" "${CFG_SEX}" "${CFG_FUSION_GENES}" \
"${CFG_AMPLIFICATION_GENES}" "${CFG_UCSC_SERVER}" "${CFG_CNV_ANNOTATION}"
# translate to tex
${BIN_RSCRIPT} -e "load('${DIR_ANALYSES}/Report.RData'); library(knitr); knit('${DIR_RSCRIPT}/Report_Panel.Rnw');"
# fix possible knitr syntax issues
sed -i 's/\\textbf{.\\textbf{.}/\\textbf{.}/' ${DIR_ANALYSES}/Report_Panel.tex
# PDF report
mv "${DIR_ANALYSES}/Report_Panel.tex" "${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.tex"
pdflatex -interaction=nonstopmode "${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.tex" \
--output-directory="${DIR_ANALYSES}"
pdflatex -interaction=nonstopmode "${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.tex" \
--output-directory="${DIR_ANALYSES}"
# clean up
# remove aux files which are created while pdflatex
rm -f "${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.aux" \
"${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.toc" \
"${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.log" \
"${DIR_ANALYSES}/${CFG_CASE}_${PARAM_DIR_PATIENT}_Report_Panel.out"