2 # Time-stamp: <2022-06-06 12:13:43 Tao Liu>
4 # integrative subcmds testing
7 echo "Run all tests for subcommands of MACS3. Need >=1 parameter for a tag name! A unique string combining date, time and MACS3 version is recommended. ./test.sh <TAG> [UPDATE]\n If UPDATE is set with anything, aka, this command sees a second parameter, the standard output results will be replaced."
12 if [ "$#" = "2" ];then
19 OUTPUTDIR_PREFIX
=${TEMPDIR}/${TAG}
21 # make temp directory if necessary
22 if [ ! -d $TEMPDIR ]; then mkdir
$TEMPDIR; fi
24 CHIP
=CTCF_SE_ChIP_chr22_50k.bed.gz
25 CTRL
=CTCF_SE_CTRL_chr22_50k.bed.gz
27 CHIPPE
=CTCF_PE_ChIP_chr22_50k.bam
28 CTRLPE
=CTCF_PE_CTRL_chr22_50k.bam
30 CHIPBEDPE
=CTCF_PE_ChIP_chr22_50k.bedpe.gz
31 CTRLBEDPE
=CTCF_PE_CTRL_chr22_50k.bedpe.gz
33 CHIPCONTIGS50K
=contigs50k.bed.gz
35 CHIPBIGSPEEDTEST
=CTCF_12878_5M.bed.gz
36 CTRLBIGSPEEDTEST
=input_12878_5M.bed.gz
38 CALLVARPEAK
=callvar_testing.narrowPeak
40 ATACSEQBAM
=yeast_500k_SRR1822137.bam
44 echo "1.1 callpeak narrow"
46 mkdir
${OUTPUTDIR_PREFIX}_run_callpeak_narrow
48 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow0
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--cutoff-analysis &> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow0.log
49 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow1
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--d-min 15 --call-summits &> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow1.log
50 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow2
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--nomodel --extsize 100 &> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow2.log
51 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow3
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--nomodel --extsize 100 --shift -50 &> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow3.log
52 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow4
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--nomodel --nolambda --extsize 100 --shift -50 &> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow4.log
53 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow5
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
--scale-to large
&> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow
/run_callpeak_narrow5.log
55 echo "1.2 callpeak broad"
56 mkdir
${OUTPUTDIR_PREFIX}_run_callpeak_broad
58 macs3 callpeak
-g 52000000 -t $CHIP -c $CTRL -n run_callpeak_broad
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_broad
--broad &> ${OUTPUTDIR_PREFIX}_run_callpeak_broad
/run_callpeak_broad.log
60 echo "1.3 callpeak on PE narrow/broad"
62 mkdir
${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
64 macs3 callpeak
-g 52000000 -f BAMPE
-t $CHIPPE -c $CTRLPE -n run_callpeak_bampe_narrow
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
--call-summits &> ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
/run_callpeak_bampe_narrow.log
65 macs3 callpeak
-g 52000000 -f BEDPE
-t $CHIPBEDPE -c $CTRLBEDPE -n run_callpeak_bedpe_narrow
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
--call-summits &> ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
/run_callpeak_bedpe_narrow.log
66 macs3 callpeak
-g 52000000 -f BEDPE
-t $CHIPBEDPE -n run_callpeak_pe_narrow_onlychip
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
&> ${OUTPUTDIR_PREFIX}_run_callpeak_pe_narrow
/run_callpeak_pe_narrow_onlychip.log
68 mkdir
${OUTPUTDIR_PREFIX}_run_callpeak_pe_broad
70 macs3 callpeak
-g 52000000 -f BAMPE
-t $CHIPPE -c $CTRLPE -n run_callpeak_bampe_broad
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_pe_broad
--broad &> ${OUTPUTDIR_PREFIX}_run_callpeak_pe_broad
/run_callpeak_bampe_broad.log
71 macs3 callpeak
-g 52000000 -f BEDPE
-t $CHIPBEDPE -c $CTRLBEDPE -n run_callpeak_bedpe_broad
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_pe_broad
--broad &> ${OUTPUTDIR_PREFIX}_run_callpeak_pe_broad
/run_callpeak_bedpe_broad.log
76 mkdir
${OUTPUTDIR_PREFIX}_run_pileup
78 macs3 pileup
-f BED
-i $CHIP --extsize 200 --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_ChIP.bed.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_ChIP.bed.log
79 macs3 pileup
-f BED
-i $CTRL --extsize 200 --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_CTRL.bed.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_CTRL.bed.log
81 macs3 pileup
-f BAMPE
-i $CHIPPE --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_ChIPPE.bampe.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_ChIPPE.bampe.log
82 macs3 pileup
-f BAMPE
-i $CTRLPE --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_CTRLPE.bampe.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_CTRLPE.bampe.log
84 macs3 pileup
-f BEDPE
-i $CHIPBEDPE --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_ChIPPE.bedpe.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_ChIPPE.bedpe.log
85 macs3 pileup
-f BEDPE
-i $CTRLBEDPE --outdir ${OUTPUTDIR_PREFIX}_run_pileup
-o run_pileup_CTRLPE.bedpe.bdg
&> ${OUTPUTDIR_PREFIX}_run_pileup
/run_pileup_CTRLPE.bedpe.log
90 mkdir
${OUTPUTDIR_PREFIX}_run_filterdup
92 macs3 filterdup
-g 52000000 -i $CHIP --outdir ${OUTPUTDIR_PREFIX}_run_filterdup
-o run_filterdup_result.bed
--dry-run &> ${OUTPUTDIR_PREFIX}_run_filterdup
/run_filterdup_d.log
93 macs3 filterdup
-g 52000000 -i $CHIP --outdir ${OUTPUTDIR_PREFIX}_run_filterdup
-o run_filterdup_result.bed
&> ${OUTPUTDIR_PREFIX}_run_filterdup
/run_filterdup.log
95 macs3 filterdup
-g 52000000 -i $CHIPPE -f BAMPE
--outdir ${OUTPUTDIR_PREFIX}_run_filterdup
-o run_filterdup_result_pe.bedpe
--dry-run &> ${OUTPUTDIR_PREFIX}_run_filterdup
/run_filterdup_pe_d.log
96 macs3 filterdup
-g 52000000 -i $CHIPPE -f BAMPE
--outdir ${OUTPUTDIR_PREFIX}_run_filterdup
-o run_filterdup_result_pe.bedpe
&> ${OUTPUTDIR_PREFIX}_run_filterdup
/run_filterdup_pe.log
101 mkdir
${OUTPUTDIR_PREFIX}_run_predictd
103 macs3 predictd
-i $CHIPPE -f BAMPE
--outdir ${OUTPUTDIR_PREFIX}_run_predictd
&> ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bampe.log
104 grep "Average insertion length" ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bampe.log | perl
-pe 's/^.*\s(\d+)\sbps/$1/' > ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bampe.txt
106 macs3 predictd
-i $CHIPBEDPE -f BEDPE
--outdir ${OUTPUTDIR_PREFIX}_run_predictd
&> ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bedpe.log
107 grep "Average insertion length" ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bedpe.log | perl
-pe 's/^.*\s(\d+)\sbps/$1/' > ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd_bedpe.txt
109 macs3 predictd
-g 52000000 -i $CHIP --d-min 10 --outdir ${OUTPUTDIR_PREFIX}_run_predictd
--rfile run_predictd.R
&> ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd.log
110 grep "predicted fragment length" ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd.log | perl
-pe 's/^.*\s(\d+)\sbps/$1/' > ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd.txt
111 grep "alternative fragment length" ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd.log | perl
-pe 's/^.*\s(\S+)\sbps/$1/' >> ${OUTPUTDIR_PREFIX}_run_predictd
/run_predictd.txt
116 mkdir
${OUTPUTDIR_PREFIX}_run_randsample
118 macs3 randsample
-i $CHIP -n 10000 --seed 31415926 --outdir ${OUTPUTDIR_PREFIX}_run_randsample
-o run_randsample.bed
&> ${OUTPUTDIR_PREFIX}_run_randsample
/run_randsample.log
120 macs3 randsample
-f BAMPE
-i $CHIPPE -n 10000 --seed 31415926 --outdir ${OUTPUTDIR_PREFIX}_run_randsample
-o run_randsample_bampe.bedpe
&> ${OUTPUTDIR_PREFIX}_run_randsample
/run_randsample_bampe.log
122 macs3 randsample
-f BEDPE
-i $CHIPBEDPE -n 10000 --seed 31415926 --outdir ${OUTPUTDIR_PREFIX}_run_randsample
-o run_randsample_bedpe.bedpe
&> ${OUTPUTDIR_PREFIX}_run_randsample
/run_randsample_bedpe.log
127 mkdir
${OUTPUTDIR_PREFIX}_run_refinepeak
129 macs3 refinepeak
-b ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_peaks.narrowPeak -i $CHIP --outdir ${OUTPUTDIR_PREFIX}_run_refinepeak --o-prefix run_refinepeak_w_prefix &> ${OUTPUTDIR_PREFIX}_run_refinepeak
/run_refinepeak_w_prefix.log
131 macs3 refinepeak
-b ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_peaks.narrowPeak -i $CHIP --outdir ${OUTPUTDIR_PREFIX}_run_refinepeak -o run_refinepeak_w_ofile.bed &> ${OUTPUTDIR_PREFIX}_run_refinepeak
/run_refinepeak_w_ofile.log
136 mkdir
${OUTPUTDIR_PREFIX}_run_bdgcmp
138 macs3 bdgcmp
-t ${OUTPUTDIR_PREFIX}_run_pileup/run_pileup_ChIP.bed.bdg -c ${OUTPUTDIR_PREFIX}_run_pileup/run_pileup_CTRL.bed.bdg -m ppois FE -p 1 --outdir ${OUTPUTDIR_PREFIX}_run_bdgcmp --o-prefix run_bdgcmp &> ${OUTPUTDIR_PREFIX}_run_bdgcmp
/run_bdgcmp.log
141 echo "8. bdgpeakcall"
143 mkdir
${OUTPUTDIR_PREFIX}_run_bdgpeakcall
145 macs3 bdgpeakcall
-i ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_FE.bdg -c 2 --outdir ${OUTPUTDIR_PREFIX}_run_bdgpeakcall --o-prefix run_bdgpeakcall_w_prefix &> ${OUTPUTDIR_PREFIX}_run_bdgpeakcall
/run_bdgpeakcall_w_prefix.log
147 macs3 bdgpeakcall
-i ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_FE.bdg -c 2 --outdir ${OUTPUTDIR_PREFIX}_run_bdgpeakcall -o run_bdgpeakcall_cutoff.txt --cutoff-analysis &> ${OUTPUTDIR_PREFIX}_run_bdgpeakcall
/run_bdgpeakcall_cutoff.log
150 echo "9. bdgbroadcall"
152 mkdir
${OUTPUTDIR_PREFIX}_run_bdgbroadcall
154 macs3 bdgbroadcall
-i ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_FE.bdg -c 2 -C 1.5 --outdir ${OUTPUTDIR_PREFIX}_run_bdgbroadcall --o-prefix run_bdgbroadcall_w_prefix &> ${OUTPUTDIR_PREFIX}_run_bdgbroadcall
/run_bdgbroadcall_w_prefix.log
159 mkdir
${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert
160 mkdir
${OUTPUTDIR_PREFIX}_run_bdgdiff
162 macs3 callpeak
-g 10000000 --nomodel --extsize 250 -c $CHIP -t $CTRL -n run_callpeak_narrow_revert
-B --outdir ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert
&> ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert
/run_callpeak_narrow_revert.log
164 macs3 bdgdiff
--t1 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg --c1 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_control_lambda.bdg --t2 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert/run_callpeak_narrow_revert_treat_pileup.bdg --c2 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert/run_callpeak_narrow_revert_control_lambda.bdg --o-prefix run_bdgdiff_prefix --outdir ${OUTPUTDIR_PREFIX}_run_bdgdiff &> ${OUTPUTDIR_PREFIX}_run_bdgdiff
/run_bdgdiff_w_prefix.log
166 macs3 bdgdiff
--t1 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg --c1 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_control_lambda.bdg --t2 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert/run_callpeak_narrow_revert_treat_pileup.bdg --c2 ${OUTPUTDIR_PREFIX}_run_callpeak_narrow_revert/run_callpeak_narrow_revert_control_lambda.bdg -o cond1.bed cond2.bed common.bed --outdir ${OUTPUTDIR_PREFIX}_run_bdgdiff &> ${OUTPUTDIR_PREFIX}_run_bdgdiff
/run_bdgdiff_w_o_file.log
171 mkdir
${OUTPUTDIR_PREFIX}_run_cmbreps
173 macs3 cmbreps
-i ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_control_lambda.bdg ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_ppois.bdg -m max -o run_cmbreps_max.bdg --outdir ${OUTPUTDIR_PREFIX}_run_cmbreps &> ${OUTPUTDIR_PREFIX}_run_cmbreps
/run_cmbreps_max.log
174 macs3 cmbreps
-i ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_control_lambda.bdg ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_ppois.bdg -m mean -o run_cmbreps_mean.bdg --outdir ${OUTPUTDIR_PREFIX}_run_cmbreps &> ${OUTPUTDIR_PREFIX}_run_cmbreps
/run_cmbreps_mean.log
175 macs3 cmbreps
-i ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_control_lambda.bdg ${OUTPUTDIR_PREFIX}_run_bdgcmp/run_bdgcmp_ppois.bdg -m fisher -o run_cmbreps_fisher.bdg --outdir ${OUTPUTDIR_PREFIX}_run_cmbreps &> ${OUTPUTDIR_PREFIX}_run_cmbreps
/run_cmbreps_fisher.log
180 mkdir
${OUTPUTDIR_PREFIX}_run_bdgopt
182 macs3 bdgopt
-m min
-p 10 -i ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg -o run_bdgopt_min.bdg --outdir ${OUTPUTDIR_PREFIX}_run_bdgopt &> ${OUTPUTDIR_PREFIX}_run_bdgopt
/run_bdgopt_min.log
184 macs3 bdgopt
-m max
-p 2 -i ${OUTPUTDIR_PREFIX}_run_callpeak_narrow/run_callpeak_narrow0_treat_pileup.bdg -o run_bdgopt_max.bdg --outdir ${OUTPUTDIR_PREFIX}_run_bdgopt &> ${OUTPUTDIR_PREFIX}_run_bdgopt
/run_bdgopt_max.log
189 mkdir
${OUTPUTDIR_PREFIX}_run_callvar
191 macs3 callvar
-b ${CALLVARPEAK} -t ${CHIPPE} -c ${CTRLPE} -o ${OUTPUTDIR_PREFIX}_run_callvar/PEsample.vcf &> ${OUTPUTDIR_PREFIX}_run_callvar
/run_callvar_PE.log
193 # test large amount of contigs
194 echo "14. 50k contigs with buffersize"
196 mkdir
${OUTPUTDIR_PREFIX}_run_50kcontigs
199 macs3 callpeak
-g 10000000 -t $CHIPCONTIGS50K -n run_callpeak_50kcontigs
--outdir ${OUTPUTDIR_PREFIX}_run_50kcontigs
--buffer-size 1000 --nomodel --extsize 200 &> ${OUTPUTDIR_PREFIX}_run_50kcontigs
/run_callpeak_50kcontigs.log
201 echo "14.2 filterdup"
202 macs3 filterdup
-g 10000000 -i $CHIPCONTIGS50K --outdir ${OUTPUTDIR_PREFIX}_run_50kcontigs
-o run_filterdup_result.bed
--buffer-size 1000 &> ${OUTPUTDIR_PREFIX}_run_50kcontigs
/run_filterdup_50kcontigs.log
205 macs3 pileup
-f BED
-i $CHIPCONTIGS50K --extsize 200 --outdir ${OUTPUTDIR_PREFIX}_run_50kcontigs
-o run_pileup_ChIP.bed.bdg
--buffer-size 1000 &> ${OUTPUTDIR_PREFIX}_run_50kcontigs
/run_pileup_ChIP.bed.log
207 echo "14.4 randsample"
208 macs3 randsample
-i $CHIPCONTIGS50K -n 100000 --seed 31415926 --outdir ${OUTPUTDIR_PREFIX}_run_50kcontigs
-o run_randsample.bed
--buffer-size 1000 &> ${OUTPUTDIR_PREFIX}_run_50kcontigs
/run_randsample.log
210 echo "15. skip hmmratac"
211 #mkdir ${OUTPUTDIR_PREFIX}_run_hmmratac
213 #macs3 hmmratac -b $ATACSEQBAM -n hmmratac_yeast500k --outdir ${OUTPUTDIR_PREFIX}_run_hmmratac &> ${OUTPUTDIR_PREFIX}_run_hmmratac/run_hmmratac.log
215 echo "16. search for errors or warnings in log files"
217 for i
in `ls ${OUTPUTDIR_PREFIX}_run_*/*.log`;do
218 echo " checking $i..."
219 egrep -i "error|warning" $i;
220 if [[ $?
== 0 ]];then
221 echo " ... error/warning found!"
230 if [[ $flag == 1 ]]; then
231 echo " Error or Warning can be found! Quit the test!"
235 echo "17. compare with standard outputs"
238 # we do not check the consistency of random subsampling results and hmmratac on non-x86 arch
239 subfolders
=(50kcontigs bdgbroadcall bdgcmp bdgdiff bdgpeakcall callpeak_broad callpeak_narrow callpeak_narrow_revert callpeak_pe_broad callpeak_pe_narrow cmbreps filterdup pileup refinepeak bdgopt predictd callvar
) # hmmratac)
243 for i
in ${subfolders[@]};do
246 for j
in `ls standard_results_${i}/*`; do
249 echo "16.${m}.${n} checking $i $k ..."
250 fq
=${OUTPUTDIR_PREFIX}_run_${i}/${k}
251 fs
=standard_results_
${i}/${k}
252 if [ "${REPLACE}" = "Y" ]; then
254 echo " ... replaced!"
256 sort $fq|
grep -v ^
# > tmp_fq.txt
257 sort $fs|
grep -v ^
# > tmp_fs.txt
258 d
=`diff tmp_fq.txt tmp_fs.txt`
262 echo " ... failed! Difference:"
263 diff tmp_fq.txt tmp_fs.txt |
head -10
269 rm -f tmp_fq.txt tmp_fs.txt
271 # exit with 1 if test fails
272 if [ $flag -eq 1 ];then
276 echo "17. brief speed test"
278 mkdir
${OUTPUTDIR_PREFIX}_speedtest
279 macs3 callpeak
-t CTCF_12878_5M.bed.gz
-c Input_12878_5M.bed.gz
-n speedtest
-B --outdir ${OUTPUTDIR_PREFIX}_speedtest
&> ${OUTPUTDIR_PREFIX}_speedtest
/speedtest.log
&
280 # monitor the macs3 callpeak run and output CPU and mem usage