Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigWig (update for bedGraphToBigWig ~v357 and later) #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions templates/bigwig/RGCRG-ANTISENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw
10 changes: 7 additions & 3 deletions templates/bigwig/RGCRG-MATE1_SENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw
10 changes: 7 additions & 3 deletions templates/bigwig/RGCRG-MATE2_SENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw
6 changes: 4 additions & 2 deletions templates/bigwig/RGCRG-NONE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash -eu
genomeCoverageBed -split -bg -ibam ${bam} > ${prefix}.raw.bedgraph
bedGraphToBigWig ${prefix}.raw.bedgraph ${genomeFai} ${prefix}.raw.bw
genomeCoverageBed -split -bg -ibam ${bam} \
| sort -k1,1 -k2,2n \
> ${prefix}.raw.bedgraph
bedGraphToBigWig ${prefix}.raw.bedgraph ${genomeFai} ${prefix}.raw.bw
10 changes: 7 additions & 3 deletions templates/bigwig/RGCRG-SENSE
Original file line number Diff line number Diff line change
@@ -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
bedGraphToBigWig ${prefix}.minusRaw.bedgraph ${genomeFai} ${prefix}.minusRaw.bw
14 changes: 13 additions & 1 deletion templates/bigwig/STAR-ANTISENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
${prefix}.Unique.plusRaw.bw
14 changes: 13 additions & 1 deletion templates/bigwig/STAR-MATE1_SENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
${prefix}.Unique.minusRaw.bw
14 changes: 13 additions & 1 deletion templates/bigwig/STAR-MATE2_SENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
${prefix}.Unique.plusRaw.bw
11 changes: 10 additions & 1 deletion templates/bigwig/STAR-NONE
Original file line number Diff line number Diff line change
Expand Up @@ -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
${prefix}.Unique.raw.bw
13 changes: 12 additions & 1 deletion templates/bigwig/STAR-SENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
${prefix}.Unique.minusRaw.bw