From 5a07171ea2845329b89b89d18d02a736955e7776 Mon Sep 17 00:00:00 2001 From: Lingfei Wang Date: Tue, 14 May 2024 17:48:12 -0400 Subject: [PATCH] Update chromatin_macs2.sh to address compatibility issues --- src/dictys/scripts/chromatin_macs2.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dictys/scripts/chromatin_macs2.sh b/src/dictys/scripts/chromatin_macs2.sh index b0b162e..3e95615 100755 --- a/src/dictys/scripts/chromatin_macs2.sh +++ b/src/dictys/scripts/chromatin_macs2.sh @@ -24,14 +24,20 @@ genome_size=$6 cutoff=$7 nodes=$8 +if [ "a$nodes" == "a1" ]; then + nodes2="" +else + nodes2="-@ $nodes" +fi + #Create bam file for custom cells list, filter out chrM/chrUn/chrRandom, sort and index awk '{printf("%s\n","'$cells_dir/'"$1)}' "$cells_list" > "00-cells.txt" -( samtools view -h -@ "$nodes" "$(head -n 1 "00-cells.txt" )" | grep -v '^@HD' | grep -v '^@PG' ; tail -n +2 "00-cells.txt" | while read l; do samtools view -@ "$nodes" "$l"; done ) | awk '$3!="chrM"' | grep -v chrUn_ | grep -v GL00 | grep -v -e "random" | samtools view -1 -@ "$nodes" -o "02-filtered.bam" - +( samtools view -h $nodes2 "$(head -n 1 "00-cells.txt" )" | grep -v '^@HD' | grep -v '^@PG' ; tail -n +2 "00-cells.txt" | while read l; do samtools view $nodes2 "$l"; done ) | awk '$3!="chrM"' | grep -v chrUn_ | grep -v GL00 | grep -v -e "random" | samtools view -1 $nodes2 -o "02-filtered.bam" - #filter, sort and index bam file. -samtools sort -o "$output_bam" -@ "$nodes" -l 1 02-filtered.bam +samtools sort -o "$output_bam" $nodes2 -l 1 02-filtered.bam rm 02-filtered.bam -samtools index -@ "$nodes" "$output_bam" "$output_bai" +samtools index $nodes2 "$output_bam" "$output_bai" #Step3A. Peak calling on aggregate population [Keep only significant peaks] OMP_NUM_THREADS=$nodes MKL_NUM_THREADS=$nodes NUMEXPR_NUM_THREADS=$nodes OPENBLAS_NUM_THREADS=$nodes OMP_MAX_THREADS=$nodes MKL_MAX_THREADS=$nodes NUMEXPR_MAX_THREADS=$nodes OPENBLAS_MAX_THREADS=$nodes VECLIB_MAXIMUM_THREADS=$nodes macs2 callpeak -t "$output_bam" -n 04 -g $genome_size --nomodel --shift -75 --extsize 150 --keep-dup all --verbose 4 --call-summits -q $cutoff