diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1700561..1eb0857 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,7 +13,7 @@ env: IMAGE_NAME: recap CONTEXT: "./" NAMESPACE: nciccbr - VERSION_TAG: 0.3.1 + VERSION_TAG: 0.3.2 jobs: build-docker: diff --git a/RECAP_MACS.sh b/RECAP_MACS.sh index e932c68..d2220e5 100755 --- a/RECAP_MACS.sh +++ b/RECAP_MACS.sh @@ -32,11 +32,7 @@ # =============================================================== # Script version number -VERSION="1.0.2" -# Provide a variable for the location of this and other scripts -SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -REMIX_PATH=RECAP_Re-Mix.sh -PERL_PATH=RECAP.pl +VERSION="1.0.2" # Text display commands bold=$(tput bold) normal=$(tput sgr0) @@ -62,8 +58,6 @@ then exit 1 fi -cd $INPUT_DIR - if [[ ! -e $CHIP_NAME ]] then echo -e "\nERROR: Treatment bed file does not exist" @@ -92,28 +86,31 @@ then fi # 1) Re-mix ChIP and control bed files -bash $REMIX_PATH -i $INPUT_DIR -t $CHIP_NAME -c $CONTROL_NAME -o $OUTPUT_DIR -m unequal -b $BOOTSTRAP -s $SEED +mkdir -p $OUTPUT_DIR +RECAP_Re-Mix.sh -i $INPUT_DIR -t $CHIP_NAME -c $CONTROL_NAME -o $OUTPUT_DIR -m unequal -b $BOOTSTRAP -s $SEED # 2) Call original peaks using MACS # Please specify your own MACS parameters! # NOTE: p-value threshold must be set to 0.1 for MACS -cd $INPUT_DIR +mkdir -p $OUTPUT_DIR/MACS_original macs2 callpeak -t $CHIP_NAME -c $CONTROL_NAME --pvalue 0.10 -n ${CHIP_NAME%.*} --outdir "$OUTPUT_DIR/MACS_original" # 3) Call re-mixed peaks using MACS specifying desired parameters # Please specify your own MACS parameters! # NOTE: p-value threshold must be set to 0.1 for MACS -cd "$OUTPUT_DIR/re-mix" +pushd "$OUTPUT_DIR/re-mix" for (( i=1; i<=$BOOTSTRAP; i++ )) do macs2 callpeak -t "${CHIP_NAME%.bed}.bootstrap_$i.bed" -c "${CONTROL_NAME%.bed}.bootstrap_$i.bed" --pvalue 0.10 -n "${CHIP_NAME%.*}.bootstrap_$i" --outdir "$OUTPUT_DIR/MACS_re-mix" done +popd # All non-MACS summary files in MACS_re-mix must be deleted if $BOOTSTRAP > 1 if [ -d "$OUTPUT_DIR/MACS_re-mix" ] then - cd "$OUTPUT_DIR/MACS_re-mix" + pushd "$OUTPUT_DIR/MACS_re-mix" find . -type f ! -name '*_peaks.xls' -delete + popd else echo "Output directory doesn't exist!" exit 1 @@ -121,11 +118,17 @@ fi # 4) Recalibrate original peak p-values using RECAP # NOTE: Check for correct header and p-value column if you obtain any errors here -cd $OUTPUT_DIR -mkdir MACS_RECAP - -perl $PERL_PATH --dirOrig "$OUTPUT_DIR/MACS_original" --nameOrig "${CHIP_NAME%.*}_peaks.xls" --dirRemix "$OUTPUT_DIR/MACS_re-mix" --nameRemix "${CHIP_NAME%.*}" --dirOutput "$OUTPUT_DIR/MACS_RECAP" --nameOutput "${CHIP_NAME%.*}.RECAP.bootstrap_${BOOTSTRAP}_peaks.xls" --bootstrap $BOOTSTRAP --header $HEADER --pvalCol 7 --delim t --software M - +mkdir -p $OUTPUT_DIR/MACS_RECAP +pushd $OUTPUT_DIR +RECAP.pl \ + --dirOrig "$(realpath $OUTPUT_DIR/MACS_original)" \ + --nameOrig "${CHIP_NAME%.*}_peaks.xls" \ + --dirRemix "$(realpath $OUTPUT_DIR/MACS_re-mix)" \ + --nameRemix "${CHIP_NAME%.*}" \ + --dirOutput "$(realpath $OUTPUT_DIR/MACS_RECAP)" \ + --nameOutput "${CHIP_NAME%.*}.RECAP.bootstrap_${BOOTSTRAP}_peaks.xls" \ + --bootstrap $BOOTSTRAP --header $HEADER --pvalCol 7 --delim t --software M +popd ################################################################# ######################## End Script Here ######################## } @@ -139,10 +142,10 @@ usage() { [Output directory] [Bootstrap] [Header] ${bold}USAGE:${normal} - -i, --input Input file directory (absolute path) + -i, --input Input file directory -t, --treatment Treatment file (full name with extension) -c, --control Control file (full name with extension) - -o, --output Output file directory (absolute path) + -o, --output Output file directory -b, --bootstrap Number of re-mixes -e, --header Header number of peak calling output files diff --git a/RECAP_Re-Mix.sh b/RECAP_Re-Mix.sh index 95743b1..1712fd8 100755 --- a/RECAP_Re-Mix.sh +++ b/RECAP_Re-Mix.sh @@ -59,10 +59,10 @@ echo "##################################################" echo "###### RECAP RE-MIX v$VERSION ######" echo "##################################################" echo "" -echo "Input directory (absolute path): $INPUT_DIR" +echo "Input directory: $INPUT_DIR" echo "Treatment library: $TREATMENT_NAME" echo "Control library: $CONTROL_NAME" -echo "Output directory (absolute path): $OUTPUT_DIR" +echo "Output directory: $OUTPUT_DIR" echo "Re-mix method: $METHOD_NAME" echo "Number of re-mixes: $BOOTSTRAP" echo "Random seed: $SEED" @@ -73,8 +73,6 @@ then exit 1 fi -cd $INPUT_DIR - if [[ ! -e $TREATMENT_NAME || ! $TREATMENT_NAME == *.bed ]] then echo -e "\nERROR: Treatment bed file does not exist" @@ -97,14 +95,13 @@ fi # Base names of treatment and control libraries TREATMENT_NAME_BASE="${TREATMENT_NAME%.*}" CONTROL_NAME_BASE="${CONTROL_NAME%.*}" - + +mkdir -p $OUTPUT_DIR/re-mix for (( BOOTSTRAP_COUNT=1; BOOTSTRAP_COUNT<=$BOOTSTRAP; BOOTSTRAP_COUNT++ )) do - cd $INPUT_DIR echo "" echo "${bold}Starting Re-Mixing Procedure #$BOOTSTRAP_COUNT ${normal}" echo "Creating directory for re-mix files:" - mkdir -p $OUTPUT_DIR/re-mix echo "Check!" echo "Concatenating treatment and control libraries" @@ -117,38 +114,34 @@ do echo "Unequal mixing method selected" FIRST_LINES=$( wc -l < $TREATMENT_NAME ) LAST_LINES=$( wc -l < $CONTROL_NAME ) - cd $OUTPUT_DIR/re-mix # If method is equal elif [ $METHOD = 1 ] then echo "Equal mixing method selected" - cd $OUTPUT_DIR/re-mix COMBINED_LINES=$(wc -l < $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp) FIRST_LINES=$(( COMBINED_LINES / 2 )) LAST_LINES=$(( COMBINED_LINES - FIRST_LINES )) fi echo "Re-mixing..." - shuf --random-source=<(get_seeded_random $SEED) -o $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp < $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp + shuf --random-source=<(get_seeded_random $SEED) -o $OUTPUT_DIR/re-mix/$TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp < $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp echo "Check!" echo "Creating re-mixed treatment library" - head -n $FIRST_LINES $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp > $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.bed + head -n $FIRST_LINES $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp > $OUTPUT_DIR/re-mix/$TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.bed echo "Check!" echo "Creating re-mixed control library" - tail -n $LAST_LINES $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp > $CONTROL_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.bed + tail -n $LAST_LINES $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp > $OUTPUT_DIR/re-mix/$CONTROL_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.bed echo "Check!" echo "Deleting temporary files" - rm $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp + rm $OUTPUT_DIR/re-mix/$TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp echo "Check!" echo "Completed re-mix #$BOOTSTRAP_COUNT" done -cd $INPUT_DIR - end_time=`date +%s` echo RECAP RE-MIX execution time: `expr $end_time - $start_time`s. @@ -165,10 +158,10 @@ usage() { [Output directory] [Re-mix method] [Bootstrap] ${bold}USAGE:${normal} - -i, --input Input file directory (absolute path) + -i, --input Input file directory -t, --treatment Treatment bed file -c, --control Control bed file - -o, --output Output file directory (absolute path) + -o, --output Output file directory -m, --method Method of re-mixing (equal) or (unequal) -b, --bootstrap Number of re-mixes