Skip to content

Commit

Permalink
feat: add additional parameters and output processing steps to execut…
Browse files Browse the repository at this point in the history
…e.sh

- Added new parameters (max_features, resolution, species, etc.) for R script execution.
- Updated output processing: included additional file types, created a zip archive, and moved final output.
  • Loading branch information
mihirsamdarshi committed Aug 12, 2024
1 parent ed55b87 commit ded3c2d
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions service.cli/execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ mkdir /home/scu/run
cd /home/scu/run

echo "starting service as"
echo User : "$(id "$(whoami)")"
echo Workdir : "$(pwd)"
echo " User : $(id "$(whoami)")"
echo " Workdir : $(pwd)"
echo "..."
echo

Expand All @@ -19,30 +19,48 @@ ls -al "${INPUT_FOLDER}"

# Parse input parameters
# Assuming these are passed as environment variables by osparc
OUTPUT_PREFIX="${OUTPUT_PREFIX:-}"
NAME="${NAME:-sPARcRNA}"
MIN_CELLS="${MIN_CELLS:-3}"
MIN_FEATURES="${MIN_FEATURES:-200}"
MAX_FEATURES="${MAX_FEATURES:-2500}"
RESOLUTION="${RESOLUTION:-0.8}"
SPECIES="${SPECIES:-Homo sapiens}"
MIN_PCT="${MIN_PCT:-0.25}"
LOGFC_THRESHOLD="${LOGFC_THRESHOLD:-0.25}"
GSEA_MIN_SIZE="${GSEA_MIN_SIZE:-15}"
GSEA_MAX_SIZE="${GSEA_MAX_SIZE:-500}"
CATEGORY="${CATEGORY:-H}"

# Run the R script with command line arguments
Rscript /home/${SC_USER_NAME}/dex.R \
--input "$INPUT_FOLDER" \
--output "$OUTPUT_FOLDER" \
--prefix "$OUTPUT_PREFIX" \
--name "$NAME" \
--min_cells "$MIN_CELLS" \
--min_features "$MIN_FEATURES"
--min_features "$MIN_FEATURES" \
--max_features "$MAX_FEATURES" \
--resolution "$RESOLUTION" \
--species "$SPECIES" \
--min_pct "$MIN_PCT" \
--logfc_threshold "$LOGFC_THRESHOLD" \
--gsea_min_size "$GSEA_MIN_SIZE" \
--gsea_max_size "$GSEA_MAX_SIZE" \
--category "$CATEGORY"

# Check if outputs.json was created
if [ ! -f "${OUTPUT_FOLDER}/outputs.json" ]; then
echo "Error: outputs.json was not created. Check R script execution."
exit 1
fi

cp -r astro/ ./
yarn build
cp build/* "${OUTPUT_FOLDER}/"

# Zip all output files
cd "$OUTPUT_FOLDER"
zip -r outputs.zip ./*.h5ad outputs.json
zip -r outputs.zip "${OUTPUT_FOLDER}"/*.csv "${OUTPUT_FOLDER}"/*.png "${OUTPUT_FOLDER}"/*.rds "${OUTPUT_FOLDER}"/outputs.json

# Move the zip file to be the only output
mv outputs.zip final_output.zip
rm ./*.h5ad outputs.json
mv outputs.zip "${OUTPUT_FOLDER}/final_output.zip"

echo "Service completed successfully."

0 comments on commit ded3c2d

Please sign in to comment.