Implement calculate_interaction_zscores.R

This commit is contained in:
2024-08-23 04:01:13 -04:00
parent bcc8dba3e4
commit 1502f6bf38
4 changed files with 101 additions and 380 deletions

View File

@@ -427,6 +427,25 @@ execute() {
fi
}
is_directory_empty() {
local dir="$1"
# Check if the directory exists and is a directory
if [ ! -d "$dir" ]; then
echo "Directory does not exist or is not a directory"
return 1
fi
# Iterate over the files and directories inside the specified directory
for _ in "$dir"/*; do
# If we find at least one entry, it's not empty
return 1
done
# If the loop completes without finding any entries, the directory is empty
return 0
}
# @description Backup one or more files to an incremented .bk file
#
# **TODO**
@@ -1481,8 +1500,10 @@ calculate_interaction_zscores() {
EOF
declare script="$APPS_DIR/r/calculate_interaction_zscores.R"
declare combined_out_path="${1:-"$STUDY_RESULTS_DIR/zscores"}"
declare -a out_paths=("${EXP_PATHS[@]}/zscores" "$combined_out_path")
declare -a out_paths=("${1:-"$STUDY_RESULTS_DIR/zscores"}")
for path in "${EXP_PATHS[@]}"; do
out_paths+=("${path}/zscores")
done
# TODO we'll need to change this behaviour after testing
# we can test for existence and then choose to skip or rerun later
@@ -1493,7 +1514,7 @@ calculate_interaction_zscores() {
done
execute "$RSCRIPT" "$script" \
"${1:-"$out_path"}" \
"${1:-"$STUDY_RESULTS_DIR"}" \
"${2:-3}" \
"${3:-"$APPS_DIR/r/SGD_features.tab"}" \
"${4:-"$EASY_RESULTS_DIR/results_std.txt"}" \