Skip to content

Instantly share code, notes, and snippets.

@rejuvyesh
Created November 11, 2016 04:53
Show Gist options
  • Save rejuvyesh/7eb50ef2855070edef416f5e3ffc9899 to your computer and use it in GitHub Desktop.
Save rejuvyesh/7eb50ef2855070edef416f5e3ffc9899 to your computer and use it in GitHub Desktop.

for fl in wgEncode*.broadPeak; do /afs/ir/class/cs273a/bin/overlapSelect -selectCoordCols=0,1,2 -inCoordCols=0,1,2 hg19.knownGene.codingExons.bed ${fl} “${fl}_observed_overlaps_coding.bed”; done for fl in wgEncode*.broadPeak; do /afs/ir/class/cs273a/bin/overlapSelect -selectCoordCols=0,1,2 -inCoordCols=0,1,2 wgEncodeAwgDnaseDukeOsteoblUniPk.narrowPeak ${fl} “${fl}_observed_overlaps_narrow.bed”; done

for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do for i in $(seq 100); do /afs/ir/class/cs273a/bin/overlapSelect -selectCoordCols=0,1,2 -inCoordCols=0,1,2 hg19.knownGene.codingExons.bed “wgEncodeBroadHistoneOsteo${hist}.broadPeak_shuffle_${i}.bed” “${hist}_shuffle_${i}_coding_overlap.bed”; /afs/ir/class/cs273a/bin/overlapSelect -selectCoordCols=0,1,2 -inCoordCols=0,1,2 wgEncodeAwgDnaseDukeOsteoblUniPk.narrowPeak “wgEncodeBroadHistoneOsteo${hist}.broadPeak_shuffle_${i}.bed” “${hist}_shuffle_${i}_narrow_overlap.bed”; done; done

for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do for i in $(seq 100); do wc -l “${hist}_shuffle_${i}_coding_overlap.bed” >> “${hist}_coding_counts.txt” wc -l “${hist}_shuffle_${i}_narrow_overlap.bed” >> “${hist}_narrow_counts.txt” done; done

for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do cat “${hist}_coding_counts.txt” | echo $(( $( cut -d’ ’ -f1 | paste -s -d+ - ) )) >> “${hist}_coding_count.sum”; cat “${hist}_narrow_counts.txt” | echo $(( $( cut -d’ ’ -f1 | paste -s -d+ - ) )) >> “${hist}_narrow_count.sum”; done

for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do awk ‘{sum+=$0; sumsq+=$0*$0} END {print sqrt(sumsq/NR - (sum/NR)**2)}’ “${hist}_coding_counts.txt” > “${hist}_coding_count.std”; awk ‘{sum+=$0; sumsq+=$0*$0} END {print sqrt(sumsq/NR - (sum/NR)**2)}’ “${hist}_narrow_counts.txt” > “${hist}_narrow_count.std”; done

for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_coding.bed” > “${hist}_observed_overlap_coding.count” wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_narrow.bed” > “${hist}_observed_overlap_narrow.count” done for hist in H3k27me3Pk blH3k36me3StdPk blH3k27acStdPk; do paste <(wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_coding.bed”) <(cat “${hist}_coding_count.sum”) | awk ‘{print $1/($3/100)}’ &gt; “${hist}_coding.fold” paste <(wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_narrow.bed”) <(cat “${hist}_narrow_count.sum”) | awk ‘{print $1/($3/100)}’ &gt; “${hist}_narrow.fold” paste <(wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_coding.bed”) <(cat “${hist}_coding_count.sum”) <(cat “${hist}_coding_count.std”) | awk ‘{print ($1-($3/100))/$4}’ > “${hist}_coding.zscore” paste <(wc -l “wgEncodeBroadHistoneOsteo${hist}.broadPeak_observed_overlaps_narrow.bed”) <(cat “${hist}_narrow_count.sum”) <(cat “${hist}_narrow_count.std”) | awk ‘{print ($1-($3/100))/$4}’ > “${hist}_narrow.zscore”

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment