diff --git a/templates/bigwig/RGCRG-ANTISENSE b/templates/bigwig/RGCRG-ANTISENSE index abb577f..d19b3fe 100644 --- a/templates/bigwig/RGCRG-ANTISENSE +++ b/templates/bigwig/RGCRG-ANTISENSE @@ -3,8 +3,12 @@ samtools view -h -@ ${cpus} ${bam} | \ awk 'BEGIN {OFS="\\t"} {if (\$1!~/^@/) {\$2=xor(\$2,0x10)}; print}' | \ samtools view -@ ${cpus} -Sb - > tmp.bam -genomeCoverageBed -strand + -split -bg -ibam tmp.bam > ${prefix}.plusRaw.bedgraph -genomeCoverageBed -strand - -split -bg -ibam tmp.bam > ${prefix}.minusRaw.bedgraph +genomeCoverageBed -strand + -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.plusRaw.bedgraph +genomeCoverageBed -strand - -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.minusRaw.bedgraph rm tmp.bam bedGraphToBigWig ${prefix}.plusRaw.bedgraph ${genomeFai} ${prefix}.plusRaw.bw -bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw \ No newline at end of file +bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw diff --git a/templates/bigwig/RGCRG-MATE1_SENSE b/templates/bigwig/RGCRG-MATE1_SENSE index 41013e4..5e64b80 100644 --- a/templates/bigwig/RGCRG-MATE1_SENSE +++ b/templates/bigwig/RGCRG-MATE1_SENSE @@ -3,8 +3,12 @@ samtools view -h -@ ${cpus} ${bam} | \ awk 'BEGIN {OFS="\\t"} {if (\$1!~/^@/ && and(\$2,128)>0) {\$2=xor(\$2,0x10)}; print}' | \ samtools view -@ ${cpus} -Sb - > tmp.bam -genomeCoverageBed -strand + -split -bg -ibam tmp.bam > ${prefix}.plusRaw.bedgraph -genomeCoverageBed -strand - -split -bg -ibam tmp.bam > ${prefix}.minusRaw.bedgraph +genomeCoverageBed -strand + -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.plusRaw.bedgraph +genomeCoverageBed -strand - -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.minusRaw.bedgraph rm tmp.bam bedGraphToBigWig ${prefix}.plusRaw.bedgraph ${genomeFai} ${prefix}.plusRaw.bw -bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw \ No newline at end of file +bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw diff --git a/templates/bigwig/RGCRG-MATE2_SENSE b/templates/bigwig/RGCRG-MATE2_SENSE index 08dc74d..cd06aac 100644 --- a/templates/bigwig/RGCRG-MATE2_SENSE +++ b/templates/bigwig/RGCRG-MATE2_SENSE @@ -3,8 +3,12 @@ samtools view -h -@ ${cpus} ${bam} | \ awk 'BEGIN {OFS="\\t"} {if (\$1!~/^@/ && and(\$2,64)>0) {\$2=xor(\$2,0x10)}; print}' | \ samtools view -@ ${cpus} -Sb - > tmp.bam -genomeCoverageBed -strand + -split -bg -ibam tmp.bam > ${prefix}.plusRaw.bedgraph -genomeCoverageBed -strand - -split -bg -ibam tmp.bam > ${prefix}.minusRaw.bedgraph +genomeCoverageBed -strand + -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.plusRaw.bedgraph +genomeCoverageBed -strand - -split -bg -ibam tmp.bam \ + | sort -k1,1 -k2,2n \ +> ${prefix}.minusRaw.bedgraph rm tmp.bam bedGraphToBigWig ${prefix}.plusRaw.bedgraph ${genomeFai} ${prefix}.plusRaw.bw -bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw \ No newline at end of file +bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw diff --git a/templates/bigwig/RGCRG-NONE b/templates/bigwig/RGCRG-NONE index e0567b9..3e6cb5d 100644 --- a/templates/bigwig/RGCRG-NONE +++ b/templates/bigwig/RGCRG-NONE @@ -1,3 +1,5 @@ #!/bin/bash -eu -genomeCoverageBed -split -bg -ibam ${bam} > ${prefix}.raw.bedgraph -bedGraphToBigWig ${prefix}.raw.bedgraph ${genomeFai} ${prefix}.raw.bw \ No newline at end of file +genomeCoverageBed -split -bg -ibam ${bam} \ + | sort -k1,1 -k2,2n \ +> ${prefix}.raw.bedgraph +bedGraphToBigWig ${prefix}.raw.bedgraph ${genomeFai} ${prefix}.raw.bw diff --git a/templates/bigwig/RGCRG-SENSE b/templates/bigwig/RGCRG-SENSE index cdfea57..27098ad 100644 --- a/templates/bigwig/RGCRG-SENSE +++ b/templates/bigwig/RGCRG-SENSE @@ -1,5 +1,9 @@ #!/bin/bash -eu -genomeCoverageBed -strand + -split -bg -ibam ${bam} > ${prefix}.plusRaw.bedgraph -genomeCoverageBed -strand - -split -bg -ibam ${bam} > ${prefix}.minusRaw.bedgraph +genomeCoverageBed -strand + -split -bg -ibam ${bam} \ + | sort -k1,1 -k2,2n \ +> ${prefix}.plusRaw.bedgraph +genomeCoverageBed -strand - -split -bg -ibam ${bam} \ + | sort -k1,1 -k2,2n \ +> ${prefix}.minusRaw.bedgraph bedGraphToBigWig ${prefix}.plusRaw.bedgraph ${genomeFai} ${prefix}.plusRaw.bw -bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw \ No newline at end of file +bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw diff --git a/templates/bigwig/STAR-ANTISENSE b/templates/bigwig/STAR-ANTISENSE index aaf690a..c1dd42a 100644 --- a/templates/bigwig/STAR-ANTISENSE +++ b/templates/bigwig/STAR-ANTISENSE @@ -13,6 +13,18 @@ if [[ ${wigRefPrefix} != - ]]; then sed -ni '/^${wigRefPrefix}/p' chrSizes.txt fi +#make sure the bedGraph files are sorted before converting to bigWig +for bedGraph in Signal/Signal.UniqueMultiple.str1.out.bg \ + Signal/Signal.UniqueMultiple.str2.out.bg \ + Signal/Signal.Unique.str1.out.bg \ + Signal/Signal.Unique.str2.out.bg; do + if [[ ! \$( sort -C -k1,1 -k2,2n \$bedGraph ) ]]; then + sort -k1,1 -k2,2n \$bedGraph > \$bedGraph.sorted && \ + mv \$bedGraph.sorted \$bedGraph + fi +done + + bedGraphToBigWig Signal/Signal.UniqueMultiple.str1.out.bg \ chrSizes.txt \ ${prefix}.UniqueMultiple.minusRaw.bw @@ -25,4 +37,4 @@ bedGraphToBigWig Signal/Signal.Unique.str1.out.bg \ ${prefix}.Unique.minusRaw.bw bedGraphToBigWig Signal/Signal.Unique.str2.out.bg \ chrSizes.txt \ - ${prefix}.Unique.plusRaw.bw \ No newline at end of file + ${prefix}.Unique.plusRaw.bw diff --git a/templates/bigwig/STAR-MATE1_SENSE b/templates/bigwig/STAR-MATE1_SENSE index b7cbe37..92e45ef 100644 --- a/templates/bigwig/STAR-MATE1_SENSE +++ b/templates/bigwig/STAR-MATE1_SENSE @@ -13,6 +13,18 @@ if [[ ${wigRefPrefix} != - ]]; then sed -ni '/^${wigRefPrefix}/p' chrSizes.txt fi +#make sure the bedGraph files are sorted before converting to bigWig +for bedGraph in Signal/Signal.UniqueMultiple.str1.out.bg \ + Signal/Signal.UniqueMultiple.str2.out.bg \ + Signal/Signal.Unique.str1.out.bg \ + Signal/Signal.Unique.str2.out.bg; do + if [[ ! \$( sort -C -k1,1 -k2,2n \$bedGraph ) ]]; then + sort -k1,1 -k2,2n \$bedGraph > \$bedGraph.sorted && \ + mv \$bedGraph.sorted \$bedGraph + fi +done + + bedGraphToBigWig Signal/Signal.UniqueMultiple.str1.out.bg \ chrSizes.txt \ ${prefix}.UniqueMultiple.plusRaw.bw @@ -25,4 +37,4 @@ bedGraphToBigWig Signal/Signal.Unique.str1.out.bg \ ${prefix}.Unique.plusRaw.bw bedGraphToBigWig Signal/Signal.Unique.str2.out.bg \ chrSizes.txt \ - ${prefix}.Unique.minusRaw.bw \ No newline at end of file + ${prefix}.Unique.minusRaw.bw diff --git a/templates/bigwig/STAR-MATE2_SENSE b/templates/bigwig/STAR-MATE2_SENSE index aaf690a..c1dd42a 100644 --- a/templates/bigwig/STAR-MATE2_SENSE +++ b/templates/bigwig/STAR-MATE2_SENSE @@ -13,6 +13,18 @@ if [[ ${wigRefPrefix} != - ]]; then sed -ni '/^${wigRefPrefix}/p' chrSizes.txt fi +#make sure the bedGraph files are sorted before converting to bigWig +for bedGraph in Signal/Signal.UniqueMultiple.str1.out.bg \ + Signal/Signal.UniqueMultiple.str2.out.bg \ + Signal/Signal.Unique.str1.out.bg \ + Signal/Signal.Unique.str2.out.bg; do + if [[ ! \$( sort -C -k1,1 -k2,2n \$bedGraph ) ]]; then + sort -k1,1 -k2,2n \$bedGraph > \$bedGraph.sorted && \ + mv \$bedGraph.sorted \$bedGraph + fi +done + + bedGraphToBigWig Signal/Signal.UniqueMultiple.str1.out.bg \ chrSizes.txt \ ${prefix}.UniqueMultiple.minusRaw.bw @@ -25,4 +37,4 @@ bedGraphToBigWig Signal/Signal.Unique.str1.out.bg \ ${prefix}.Unique.minusRaw.bw bedGraphToBigWig Signal/Signal.Unique.str2.out.bg \ chrSizes.txt \ - ${prefix}.Unique.plusRaw.bw \ No newline at end of file + ${prefix}.Unique.plusRaw.bw diff --git a/templates/bigwig/STAR-NONE b/templates/bigwig/STAR-NONE index c24d64c..5e757a0 100644 --- a/templates/bigwig/STAR-NONE +++ b/templates/bigwig/STAR-NONE @@ -13,10 +13,19 @@ if [[ ${wigRefPrefix} != - ]]; then sed -ni '/^${wigRefPrefix}/p' chrSizes.txt fi +#make sure the bedGraph files are sorted before converting to bigWig +for bedGraph in Signal/Signal.UniqueMultiple.str1.out.bg \ + Signal/Signal.Unique.str1.out.bg; do + if [[ ! \$( sort -C -k1,1 -k2,2n \$bedGraph ) ]]; then + sort -k1,1 -k2,2n \$bedGraph > \$bedGraph.sorted && \ + mv \$bedGraph.sorted \$bedGraph + fi +done + bedGraphToBigWig Signal/Signal.UniqueMultiple.str1.out.bg \ chrSizes.txt \ ${prefix}.UniqueMultiple.raw.bw bedGraphToBigWig Signal/Signal.Unique.str1.out.bg \ chrSizes.txt \ - ${prefix}.Unique.raw.bw \ No newline at end of file + ${prefix}.Unique.raw.bw diff --git a/templates/bigwig/STAR-SENSE b/templates/bigwig/STAR-SENSE index b7cbe37..b4c3612 100644 --- a/templates/bigwig/STAR-SENSE +++ b/templates/bigwig/STAR-SENSE @@ -13,6 +13,17 @@ if [[ ${wigRefPrefix} != - ]]; then sed -ni '/^${wigRefPrefix}/p' chrSizes.txt fi +#make sure the bedGraph files are sorted before converting to bigWig +for bedGraph in Signal/Signal.UniqueMultiple.str1.out.bg \ + Signal/Signal.UniqueMultiple.str2.out.bg \ + Signal/Signal.Unique.str1.out.bg \ + Signal/Signal.Unique.str2.out.bg; do + if [[ ! \$( sort -C -k1,1 -k2,2n \$bedGraph ) ]]; then + sort -k1,1 -k2,2n \$bedGraph > \$bedGraph.sorted && \ + mv \$bedGraph.sorted \$bedGraph + fi +done + bedGraphToBigWig Signal/Signal.UniqueMultiple.str1.out.bg \ chrSizes.txt \ ${prefix}.UniqueMultiple.plusRaw.bw @@ -25,4 +36,4 @@ bedGraphToBigWig Signal/Signal.Unique.str1.out.bg \ ${prefix}.Unique.plusRaw.bw bedGraphToBigWig Signal/Signal.Unique.str2.out.bg \ chrSizes.txt \ - ${prefix}.Unique.minusRaw.bw \ No newline at end of file + ${prefix}.Unique.minusRaw.bw