interactions.R refactor

This commit is contained in:
2024-08-19 03:15:29 -04:00
parent 46f1e4d4d4
commit a300484ceb
4 changed files with 287 additions and 3791 deletions

View File

@@ -209,7 +209,12 @@ parse_input() {
# @section Modules
# @description
#
# A module contains a cohesive set of actions/experiments to run on a project
# A module contains a cohesive set of tasks, including:
#
# * Filesystem operations
# * Variable setting
# * Executing other modules
# * Executing wrappers
#
# Use a module to:
#
@@ -217,8 +222,7 @@ parse_input() {
# * Generate project directories
# * Group multiple wrappers (and modules) into a larger task
# * Dictate the ordering of multiple wrappers
# * Competently handle pushd and popd for their wrappers if they do not reside in the SCANS/PROJECT_DIR
# * Call their wrappers with the appropriate arguments
# * Call wrappers with the appropriate arguments
#
# @description
module() {
@@ -580,7 +584,6 @@ interactive_header() {
unset response arr i
done
fi
echo ""
# Project selection
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
@@ -685,7 +688,7 @@ install_dependencies() {
depends_r=(
BiocManager ontologyIndex ggrepel tidyverse sos openxlsx ggplot2
plyr extrafont gridExtra gplots stringr plotly ggthemes pandoc
rmarkdown plotly htmlwidgets gplots gdata)
rmarkdown plotly htmlwidgets gplots gdata Hmisc)
depends_bioc=(UCSC.utils org.Sc.sgd.db)
[[ $1 == "--get-depends" ]] && return 0 # if we just want to read the depends vars
@@ -693,6 +696,7 @@ install_dependencies() {
# Install system-wide dependencies
echo "Installing system dependencies"
echo "You may be prompted for your sudo password to install packages using your system package manager"
echo "If you do not have sudo access, you may want to use toolbox"
case "$(uname -s)" in
Linux*|CYGWIN*|MINGW*)
if hash dnf &>/dev/null; then
@@ -1360,9 +1364,9 @@ qhtcp() {
# Run R interactions script on all studies
for study in "${STUDIES[@]}"; do
read -r num sd _ <<< "$study"
r_interactions "$num" "$sd" & # run in parallel, catch with wait below
done \
&& wait -n \
r_interactions "$num" "$sd" &
done
wait -n \
&& remc \
&& gtf \
&& gta
@@ -1790,7 +1794,7 @@ r_join_interactions() {
"${1:-$QHTCP_RESULTS_DIR}/parameters.csv"
)
((DEBUG)) && declare -p
# ((DEBUG)) && declare -p # for when the going gets tough
backup "${out_files[@]}"
@@ -2368,6 +2372,10 @@ main() {
fi
done
# If module equals install_dependencies run install_dependencies
declare -gx R_LIBS_USER=${R_LIBS_USER:-"$HOME/R/$SCRIPT_NAME"}
[[ ${MODULES[*]} == "install_dependencies" ]] && install_dependencies
# Loop over projects
for PROJECT_NAME in "${PROJECTS[@]}"; do
declare -gx PROJECT_NAME
@@ -2383,7 +2391,6 @@ main() {
declare -gx EASY_RESULTS_DIR="$EASY_OUT_DIR/$PROJECT_PREFIX"
declare -gx GTA_OUT_DIR="$QHTCP_RESULTS_DIR/gta"
declare -gx GTF_OUT_DIR="$QHTCP_RESULTS_DIR/gtf"
declare -gx R_LIBS_USER=${R_LIBS_USER:-"$HOME/R/$SCRIPT_NAME"}
# ((DEBUG)) && declare -p # for when the going gets rough
debug "Project: $PROJECT_NAME"