From 623c227a8009e4644d105d05b715590b9305b1b1 Mon Sep 17 00:00:00 2001
From: Holger Brandl <brandl@mpi-cbg.de>
Date: Mon, 9 Mar 2015 13:21:18 +0100
Subject: [PATCH] cont khan pipeline

---
 chipseq_workflow/chipseq_utils.sh |   6 +-
 chipseq_workflow/cs_snippets.sh   | 103 ++++++++++++++++++++++++++++++
 common/deepseq_commons.sh         |   1 +
 dge_workflow/dge_utils.sh         |   4 ++
 4 files changed, 111 insertions(+), 3 deletions(-)
 create mode 100755 common/deepseq_commons.sh

diff --git a/chipseq_workflow/chipseq_utils.sh b/chipseq_workflow/chipseq_utils.sh
index 9f72999..cbd6bc3 100755
--- a/chipseq_workflow/chipseq_utils.sh
+++ b/chipseq_workflow/chipseq_utils.sh
@@ -1,5 +1,4 @@
-## enable snippet spinning
-source <(curl https://raw.githubusercontent.com/holgerbrandl/datautils/v1.4/R/spinr/spin_utils.sh 2>&1 2>/dev/null)
+#source <(curl https://raw.githubusercontent.com/holgerbrandl/datautils/v1.4/R/spinr/spin_utils.sh 2>&1 2>/dev/null)
 
 
 ## configure paths
@@ -79,4 +78,5 @@ cat("<embed src=\"./bc.pdf\" width=\"900px\" height=\"700px\">")
 
 ' | spinsnip "bowtie2_qc"
 
-}
\ No newline at end of file
+}
+export -f cs_bowtie_qc
\ No newline at end of file
diff --git a/chipseq_workflow/cs_snippets.sh b/chipseq_workflow/cs_snippets.sh
index e69de29..1c9c4da 100755
--- a/chipseq_workflow/cs_snippets.sh
+++ b/chipseq_workflow/cs_snippets.sh
@@ -0,0 +1,103 @@
+
+## extract chromosome from bam file
+samtools view -bo test.bam /home/brandl/mnt/chip-seq_study/ChIPSeq_February_2014/alignments_trimmed_nomulti_pooled/H2Az.bam 1
+
+
+
+########################################################################################################################
+## macs2 playground
+
+macs2 -n --broad --gsize
+#macs2 -n --gsize
+
+
+########################################################################################################################
+### deeptools
+
+## https://github.com/fidelram/deepTools/wiki/All-command-line-options#bamCorrelate
+#bamCorrelate bins --bamfiles $bamFiles --region 10:1:100000 --plotFile="bam_correlation.png" --numberOfProcessors=4 --corMethod spearman
+
+## see how well bam files correlate using untrimmed data
+bamCorrelate bins --bamfiles $bamFiles --plotFile="bam_correlation_untrimmed.png" --numberOfProcessors=4 --corMethod spearman
+
+
+
+
+
+########################################################################################################################
+### Peak calling with SPP
+
+Rscript /home/brandl/bin/phantompeakqualtools/run_spp.R -c="../alignments_untrimmed/H2Az_Rep1_Lane2_Lib4454.0001.bam" -savp -out="test.txt"
+
+
+
+
+########################################################################################################################
+### other qc
+
+## http://www.nature.com/nmeth/journal/v11/n1/full/nmeth.2786.html
+# Teytelman et al. discovered that highly expressed loci were always enriched in ChIP peaks, regardless of which protein was pulled dow
+
+
+#########################################################################################################################
+#### CHANCE
+
+
+mcdir $baseDir/qc_chance
+
+## convert example to sam format
+bamToBed -i $baseDir/alignments_trimmed/H2Az_Rep1_Lane1_Lib4454_ca.bam > H2Az_Rep1_Lane1_Lib4454_ca.bed
+samtools view -h -o H2Az_Rep1_Lane1_Lib4454_ca.sam  $baseDir/alignments_trimmed/H2Az_Rep1_Lane1_Lib4454_ca.bam
+
+/local/home/henry/bin/CHANCE/run_chance_linux.sh /usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/
+
+
+########################################################################################################################
+## Use phantompeakqualtools to calculate quality tag (strand cross-correlation of peak)
+
+# did the antibody-treatment enrich sufficiently so that the ChIP signal can be separated from the background signal?
+## -->  use https://code.google.com/p/phantompeakqualtools/
+
+mcdir $baseDir/qc_phantompeaks
+
+#Rscript /local/home/brandl/bin/phantompeakqualtools/run_spp.R
+#Rscript run_spp.R <bamfile> -savp -out=<outfile>
+
+ctrlBam=$baseDir/alignments_untrimmed/H3-3_Rep1_Lane1_Lib4453.bam
+#DEBUG ctrlBam=$baseDir/alignments_untrimmed/H3K4me3_Rep2_Lane2_Lib4455.bam
+
+for bamFile in $baseDir/alignments_untrimmed/*bam ; do
+    echo "processing $bamFile..."
+#    Rscript /home/brandl/bin/phantompeakqualtools/run_spp.R -c=$bamFile -savp -ou  t=$(basename $bamFile).pt.log
+    ## one output file is enough  because output is tabular including inpuyt file name
+#    Rscript /home/brandl/bin/phantompeakqualtools/run_spp.R -c=$bamFile -i=$ctrlBam -savp -savd -odir=$(pwd) -out=phantom_qc.txt
+
+    ## with control
+#    ( Rscript /home/brandl/bin/phantompeakqualtools/run_spp.R -c=$bamFile -savp -savd -odir=$(pwd) -out=phantom_qc_noctrl.txt &> $(basename $bamFile).pt.log ) &
+
+    ## without control
+#    ( Rscript /home/brandl/bin/phantompeakqualtools/run_spp.R -c=$bamFile -savp -savd -odir=$(pwd) -out=phantom_qc_noctrl.txt &> $(basename $bamFile).pt.log ) &
+done
+
+wait
+
+## todo visualize results
+#phantom output format
+#format:Filename<tab>numReads<tab>estFragLen<tab>corr_estFragLen<tab>PhantomPeak<tab>corr_phantomPeak<tab>argmin_corr<tab>min_corr<tab>Normalized SCC (NSC)<tab>Relative SCC (RSC)<tab>QualityTag)
+
+
+mailme "phantom qc done"
+
+
+########################################################################################################################
+### motifs
+
+## run meme-chip
+
+########################################################################################################################
+### profiles
+
+## try deepTools
+
+## differential binding diffbind
+
diff --git a/common/deepseq_commons.sh b/common/deepseq_commons.sh
new file mode 100755
index 0000000..fd7e39f
--- /dev/null
+++ b/common/deepseq_commons.sh
@@ -0,0 +1 @@
+## tbd
diff --git a/dge_workflow/dge_utils.sh b/dge_workflow/dge_utils.sh
index 6950641..d1b18b7 100755
--- a/dge_workflow/dge_utils.sh
+++ b/dge_workflow/dge_utils.sh
@@ -1,10 +1,14 @@
 ## docs
 ## http://blog.joncairns.com/2013/08/what-you-need-to-know-about-bash-functions/
 
+## load lsf helpers
 source <(curl https://dl.dropboxusercontent.com/u/113630701/datautils/bash/lsf_utils.sh 2>&1 2>/dev/null)
+
+## enable snippet spinning
 source <(curl https://dl.dropboxusercontent.com/u/113630701/datautils/R/utils/spinr.sh 2>&1 2>/dev/null)
 
 
+## define common binaries
 export PATH=/projects/bioinfo/holger/bin/bowtie2-2.2.2:$PATH
 export PATH=/projects/bioinfo/holger/bin/tophat-2.0.13.Linux_x86_64:$PATH
 export PATH=/home/brandl/bin/cufflinks-2.2.1.Linux_x86_64:$PATH
-- 
GitLab