#!/bin/bash
# =============================================================================
# CIBERSORTx GEP (Group Mode) -- SINGULARITY version
# One representative transcriptome profile per cell type across the group.
# =============================================================================
set -euo pipefail

# ---- USER CONFIG -----------------------------------------------------------
EMAIL="jin.yan1@wustl.edu"
TOKEN="$(cat "$HOME/.cibersortx_token")"

BASE="$HOME/TaRGET_II/cibersortx"
SIF="${BASE}/sif/cibersortx_gep.sif"
INDIR="${BASE}/input"
OUTDIR="${BASE}/output_gep"

MIXTURE="brain_bulk_mixture.txt"
SIGMATRIX="CIBERSORTx_sigmatrix.txt"   # from Fractions step; symlink into INDIR
CLASSES="class_labels.txt"
# ----------------------------------------------------------------------------

mkdir -p "$OUTDIR"

singularity exec \
  --containall \
  --bind "${INDIR}:/src/data" \
  --bind "${OUTDIR}:/src/outdir" \
  "$SIF" \
  /src/CIBERSORTxGEP \
  --username "$EMAIL" \
  --token "$TOKEN" \
  --mixture "$MIXTURE" \
  --sigmatrix "$SIGMATRIX" \
  --classes "$CLASSES" \
  --rmbatchSmode TRUE \
  --refsample "macosko_reference.txt" \
  --threads 8 \
  --QN FALSE

echo "[DONE] GEP output -> $OUTDIR"
