{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Task informatics: RNA-Seq + ChIP-Seq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Despite use-intensive treatment strategies, such as chemotherapy and hematopoietic stem cell transplantation, Acute Myeloid Leukemia (AML) is still associated with a poor prognosis. The transcription factor cAMP Response Element Binding Protein (CREB) was found to be overexpressed in up to ~60% of AML patients and is associated with a more aggressive form of AML. Previous work has shown that this CREB overexpression augments AML cell growth, while CREB knockdown disrupted AML cell functions in vivo.\n",
    "\n",
    "CREB is thus an important regulator of AML-cell survival and cell growth, which makes it an interesting target for future drug discovery and development. For this reason, a small-molecule inhibitor of CREB, XX-650-23 was developed. This molecule interferes with the interaction between CREB and its co-activator CBP.\n",
    "\n",
    "XX-650-23 has been shown to disrupt the interaction in AML cells and shows an array of on-target transcriptional alterations. The goal of the paper was to determine the efficacy of targeting the CBP-CREB interaction in AML-therapy. Here, we tried to confirm the RNA-Seq and ChIP-Seq results, together with some deeper analysis of the data.\n",
    "\n",
    "Reference: Small molecule inhibition of cAMP response element binding protein in human acute myeloid leukemia cells - (Mitton et al.)\n",
    "\n",
    "Raw data files can be found here:\n",
    "https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE74928\n",
    "\n",
    "all.gene.counts and deseqresults can be found in /home/luna.kuleuven.be/r0363211/data/work\n",
    "ChIP-Seq data can be found in /home/luna.kuleuven.be/r0382186/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mkdir ~/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cd ~/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/mnt/storage/r0363211/jupyternotebooks\r\n"
     ]
    }
   ],
   "source": [
    "pwd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# RNA-Seq data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To confirm the downregulation of CREB bound genes after XX-650-23 treatment, RNA seq analysis was performed. For RNA-seq experiments, KG-1 cells were treated with either XX-650-23 (5μM) or 0.1% DMSO for 12 hours. Two repetitions of this experiment were compared. DMSO-treated cells were used as a negative control.\n",
    "\n",
    "For RNA-seq analysis, the four different \".sra files\" (GSM1937937/SRR2919449 : DMSO_rep1, GSM1937938/SRR2919450 : DMSO_rep2, GSM1937939/SRR2919451 : XX-650-23_rep1, GSM1937940/SRR2919452 : XX-650-23_rep2) were dowloaded from the GEO Accession Viewer. The \"sra files\" were then converted into a \"fastq\" format with the fastq-command. Then, a quality control was performed on the fastq files. After this, the STAR command was run to map the fastq files to the genome, using hg19 as a reference genome. SAM files were then converted into BAM files. An all.gene.counts file was made to annotate the right gene names to the reads.\n",
    "\n",
    "Fully run RNA-seq commands can be found in the attached jupyter notebook called \"RNAseq_fullcommands\" ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "mkdir /home/luna.kuleuven.be/r0363211/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/luna.kuleuven.be/r0363211/data/work\r\n"
     ]
    }
   ],
   "source": [
    "cd /home/luna.kuleuven.be/r0363211/data/work\n",
    "pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "fastq-dump --split-files SRR2919449\n",
    "fastq-dump --split-files SRR2919450\n",
    "fastq-dump --split-files SRR2919451\n",
    "fastq-dump --split-files SRR2919452"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One of the FASTQC reports is shown (figure 1)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . SRR2919449_1.fastq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 1\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/fastq%20control.jpg\">"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn SRR2919449_1.fastq \\\n",
    "     --outFileNamePrefix DMSO_rep1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn SRR2919450_1.fastq \\\n",
    "     --outFileNamePrefix DMSO_rep2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn SRR2919451_1.fastq \\\n",
    "     --outFileNamePrefix XX650_23_rep1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn SRR2919452_1.fastq \\\n",
    "     --outFileNamePrefix XX650_23_rep2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools sort -o DMSO_rep1.bam DMSO_rep1.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools index DMSO_rep1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools sort -o DMSO_rep2.bam DMSO_rep2.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools index DMSO_rep2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools sort -o XX650_23_rep1.bam XX650_23_rep1.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools index XX650_23_rep1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools sort -o XX650_23_rep2.bam XX650_23_rep2.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "samtools index XX650_23_rep2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ln -sf /mnt/nfs/data/RNA-seq/GSE47042/*.gtf /home/luna.kuleuven.be/r0363211/data/work\n",
    "ls -l *gtf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "featureCounts \\\n",
    "    -Q 10 \\\n",
    "    -g gene_name \\\n",
    "    -a /mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.sort.gtf \\\n",
    "    -o all.counts \\\n",
    "  DMSO_rep1.bam DMSO_rep2.bam XX650_23_rep1.bam XX650_23_rep1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "head all.counts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "cut -f-6 all.counts > all.genedata.tsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "head all.genedata.tsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "cut -f1,7- all.counts | grep -v '^#' > all.gene.counts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "head all.gene.counts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# RNA-seq analysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, we performed a geneMAD analysis using the online tool of Multi experiment Viewer (MeV). There is clearly a difference in gene expression between DMSO-treated and XX-650-23-treated cells. This is a first indication that XX-650-23 indeed interferes with the CREB-related transcription of genes. Here the top 20 of affected genes is shown (figure 2)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 2\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/heatmap.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to know in which processes these genes play a role, we performed a Gene Ontology analysis using GORilla. \n",
    "\n",
    "The top processes we found were responses to endoplasmic reticulum stress, single-organism developmental processes and regulation of apoptotic processes. This last one is in line with the article since there, the main focus was on genes encoding proteins involved in proliferation and DNA/RNA replication.\n",
    "\n",
    "Proliferation was also found in the list of gene ontologies as shown below but was not at the top of the list (figure 3). "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 3\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/GORilla.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For some deeper analysis, we tried to confirm the differential expression of genes found in the article. Here, we checked the gene counts of the genes discussed in the article. We can see some drastic changes in gene counts in DMSO-treated versus XX-650-23-treated cells. (colums are DMSO_rep1; DMSO_rep2; XX-650-23_rep1; XX-650-23_rep2)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "grep POLD2 all.gene.counts\n",
    "grep ANAPC2 all.gene.counts\n",
    "grep GNL3 all.gene.counts\n",
    "grep ODF2 all.gene.counts\n",
    "grep DTYMK all.gene.counts\n",
    "grep FOSL1 all.gene.counts\n",
    "grep RECQL4 all.gene.counts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using DESEQ-analysis, we could confirm the significant differential expression of the genes discussed in the article (jupyternotebook \"DESEQ_for_task_bioinformatics\"). These genes indeed encode proteins involved in proliferation and DNA/RNA replication, such as for example ANAPC2, FOSL1 and GNL3 (figure 4)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 4\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/creb%20affected%20genes%201.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, we also looked at other genes known to be regulated by CREB and found that PER1, PER2 and VGF, have a significant lower expression after XX-650-23 treatment (figure 5)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 5\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/creb%20affected%20genes%202.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We chose two of the discussed proteins for visualization in IGV. FOSL1 and DTYMK clearly have less coverage in the XX-650-23 treated condition compared to DMSO treatment. Since these genes are involved in cell proliferation and RNA replication respectively, this is in line with the lower proliferation found in the XX-650-23 treated cells (figure 6 and figure 7)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 6\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/FOSL1%20IGV.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 7 \n",
    "<img width=\"100%\" src=\"/user/r0363211/files/DTYMK%20IGV.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ChIP-seq analysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "CREB ChIP-Seq was performed to define the CREB transcriptome. For ChIP-seq analysis, the four different “.sra files” (GSM1937941/SRR2919453 : DMSO CREB_ChIPSeq, GSM1937942/SRR2919454 : DMSO input DNA, GSM1937943/SRR2919455 : XX-650-23 CREB_ChIPSeq and GSM1937944/SRR2919456 : XX-650-23 input DNA) were downloaded from the GEO Accession Viewer. The \".sra files\" were then converted into a “fastq” format with the fastq-dump command. Afterwards, bowtie2 alignment was performed on these fastq files using the bowtie2 hg19 index. The obtained SAM file was converted into a BAM file. After sorting and indexing these BAM files, the narrowpeak files were created by using the macs2 command. Peak calling was performed against the full human genome hs. This was done for all the four different samples. Input DNA was used as a control in the macs2 command."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 41625469 spots for SRR2919453\r\n",
      "Written 41625469 spots for SRR2919453\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR2919453"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "41625469 reads; of these:\r\n",
      "  41625469 (100.00%) were unpaired; of these:\r\n",
      "    2147826 (5.16%) aligned 0 times\r\n",
      "    30375319 (72.97%) aligned exactly 1 time\r\n",
      "    9102324 (21.87%) aligned >1 times\r\n",
      "94.84% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x /mnt/nfs/data/resources/bowtie2/hg19 SRR2919453_1.fastq -S SRR2919453_1.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b SRR2919453_1.sam > SRR2919453_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 17 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o SRR2919453_1sorted.bam SRR2919453_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index SRR2919453_1sorted.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 8015114 spots for SRR2919454\r\n",
      "Written 8015114 spots for SRR2919454\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR2919454"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8015114 reads; of these:\r\n",
      "  8015114 (100.00%) were unpaired; of these:\r\n",
      "    340892 (4.25%) aligned 0 times\r\n",
      "    5906203 (73.69%) aligned exactly 1 time\r\n",
      "    1768019 (22.06%) aligned >1 times\r\n",
      "95.75% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x /mnt/nfs/data/resources/bowtie2/hg19 SRR2919454_1.fastq -S SRR2919454_1.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b SRR2919454_1.sam > SRR2919454_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 4 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o SRR2919454_1sorted.bam SRR2919454_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index SRR2919454_1sorted.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Mon, 23 Jan 2017 17:22:33: \r\n",
      "# Command line: callpeak -t SRR2919453_1sorted.bam -c SRR2919454_1sorted.bam -f BAM -g hs -n DMSO_CREB_ChIPSeq_PC\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = DMSO_CREB_ChIPSeq_PC\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['SRR2919453_1sorted.bam']\r\n",
      "# control file = ['SRR2919454_1sorted.bam']\r\n",
      "# effective genome size = 2.70e+09\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-02\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:33: #1 read tag files... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:33: #1 read treatment tags... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:38:  1000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:43:  2000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:47:  3000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:52:  4000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:22:57:  5000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:01:  6000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:06:  7000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:10:  8000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:15:  9000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:20:  10000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:25:  11000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:29:  12000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:34:  13000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:39:  14000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:43:  15000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:48:  16000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:53:  17000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:23:57:  18000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:03:  19000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:08:  20000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:16:  21000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:21:  22000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:25:  23000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:29:  24000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:33:  25000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:37:  26000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:41:  27000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:45:  28000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:49:  29000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:53:  30000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:24:57:  31000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:01:  32000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:04:  33000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:08:  34000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:12:  35000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:16:  36000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:20:  37000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:24:  38000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:28:  39000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:31:  40000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:33:  41000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:35: #1.2 read input tags... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:38:  1000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:42:  2000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:46:  3000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:49:  4000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:53:  5000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:25:57:  6000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:01:  7000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:04:  8000000 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 tag size is determined as 51 bps \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 tag size = 51 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  total tags in treatment: 39477643 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 user defined the maximum tags... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  tags after filtering in treatment: 36585819 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  Redundant rate of treatment: 0.07 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  total tags in control: 7674222 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 user defined the maximum tags... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  tags after filtering in control: 6327055 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1  Redundant rate of control: 0.18 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #1 finished! \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #2 Build Peak Model... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:05: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:09: #2 number of paired peaks: 8092 \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:09: start model_add_line... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: start X-correlation... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: end of X-cor \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #2 finished! \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #2 predicted fragment length is 108 bps \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #2 alternative fragment length(s) may be 108 bps \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #2.2 Generate R script for model : DMSO_CREB_ChIPSeq_PC_model.r \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #3 Call peaks... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:26:10: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:27:08: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:27:34: #4 Write output xls file... DMSO_CREB_ChIPSeq_PC_peaks.xls \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:27:34: #4 Write peak in narrowPeak format file... DMSO_CREB_ChIPSeq_PC_peaks.narrowPeak \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:27:34: #4 Write summits bed file... DMSO_CREB_ChIPSeq_PC_summits.bed \r\n",
      "INFO  @ Mon, 23 Jan 2017 17:27:34: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t SRR2919453_1sorted.bam -c SRR2919454_1sorted.bam -f BAM -g hs -n DMSO_CREB_ChIPSeq_PC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "~\r\n",
      "DMSO_CREB_ChIPSeq_PC_model.r\r\n",
      "DMSO_CREB_ChIPSeq_PC_peaks.bed\r\n",
      "DMSO_CREB_ChIPSeq_PC_peaks.narrowPeak\r\n",
      "DMSO_CREB_ChIPSeq_PC_peaks.xls\r\n",
      "DMSO_CREB_ChIPSeq_PC_summits.bed\r\n",
      "DMSO_XXinput_ChIPSeq_PC_model.r\r\n",
      "DMSO_XXinput_ChIPSeq_PC_peaks.narrowPeak\r\n",
      "DMSO_XXinput_ChIPSeq_PC_peaks.xls\r\n",
      "DMSO_XXinput_ChIPSeq_PC_summits.bed\r\n",
      "SRR2919453_1sorted.bam\r\n",
      "SRR2919453_1sorted.bam.bai\r\n",
      "SRR2919454_1sorted.bam\r\n",
      "SRR2919454_1sorted.bam.bai\r\n",
      "SRR2919455_1sorted.bam\r\n",
      "SRR2919455_1sorted.bam.bai\r\n",
      "SRR2919456_1sorted.bam\r\n",
      "SRR2919456_1sorted.bam.bai\r\n",
      "XX-650-23_CREB_ChIPSeq_PC_model.r\r\n",
      "XX-650-23_CREB_ChIPSeq_PC_peaks.bed\r\n",
      "XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak\r\n",
      "XX-650-23_CREB_ChIPSeq_PC_peaks.xls\r\n",
      "XX-650-23_CREB_ChIPSeq_PC_summits.bed\r\n"
     ]
    }
   ],
   "source": [
    "ls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3790 DMSO_XXinput_ChIPSeq_PC_peaks.narrowPeak\r\n"
     ]
    }
   ],
   "source": [
    "wc -l DMSO_XXinput_ChIPSeq_PC_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 33486236 spots for SRR2919455\r\n",
      "Written 33486236 spots for SRR2919455\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR2919455"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "33486236 reads; of these:\r\n",
      "  33486236 (100.00%) were unpaired; of these:\r\n",
      "    1590281 (4.75%) aligned 0 times\r\n",
      "    24940197 (74.48%) aligned exactly 1 time\r\n",
      "    6955758 (20.77%) aligned >1 times\r\n",
      "95.25% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x /mnt/nfs/data/resources/bowtie2/hg19 SRR2919455_1.fastq -S SRR2919455_1.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b SRR2919455_1.sam > SRR2919455_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 14 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o SRR2919455_1sorted.bam SRR2919455_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index SRR2919455_1sorted.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 34444255 spots for SRR2919456\r\n",
      "Written 34444255 spots for SRR2919456\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR2919456"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "bowtie2-align -x /mnt/nfs/data/resources/bowtie2/hg19 SRR2919456_1.fastq -S SRR2919456_1.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b SRR2919456_1.sam > SRR2919456_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 15 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o SRR2919456_1sorted.bam SRR2919456_1.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index SRR2919456_1sorted.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Wed, 25 Jan 2017 15:26:44: \r\n",
      "# Command line: callpeak -t SRR2919455_1sorted.bam -c SRR2919456_1sorted.bam -f BAM -g hs -n XX-650-23_CREB_ChIPSeq_PC\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = XX-650-23_CREB_ChIPSeq_PC\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['SRR2919455_1sorted.bam']\r\n",
      "# control file = ['SRR2919456_1sorted.bam']\r\n",
      "# effective genome size = 2.70e+09\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-02\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:44: #1 read tag files... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:44: #1 read treatment tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:48:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:51:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:55:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:26:59:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:03:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:06:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:10:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:14:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:18:  9000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:21:  10000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:25:  11000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:29:  12000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:32:  13000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:36:  14000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:40:  15000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:44:  16000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:47:  17000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:51:  18000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:55:  19000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:27:59:  20000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:02:  21000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:06:  22000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:10:  23000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:14:  24000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:17:  25000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:21:  26000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:25:  27000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:29:  28000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:32:  29000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:36:  30000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:40:  31000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:43:  32000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:45:  33000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:47: #1.2 read input tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:52:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:28:56:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:02:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:06:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:11:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:16:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:21:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:25:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:30:  9000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:35:  10000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:41:  11000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:48:  12000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:54:  13000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:29:59:  14000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:04:  15000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:09:  16000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:14:  17000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:19:  18000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:25:  19000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:29:  20000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:34:  21000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:39:  22000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:44:  23000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:49:  24000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:54:  25000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:30:59:  26000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:04:  27000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:09:  28000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:14:  29000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:20:  30000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:25:  31000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:30:  32000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:34:  33000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:37:  34000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:38: #1 tag size is determined as 51 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:38: #1 tag size = 51 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:38: #1  total tags in treatment: 31895955 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:38: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:38: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:41: #1  tags after filtering in treatment: 29300477 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:41: #1  Redundant rate of treatment: 0.08 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:41: #1  total tags in control: 32747440 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:41: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:41: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:42: #1  tags after filtering in control: 30181059 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:42: #1  Redundant rate of control: 0.08 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:42: #1 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:42: #2 Build Peak Model... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:42: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #2 number of paired peaks: 9638 \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: start model_add_line... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: start X-correlation... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: end of X-cor \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #2 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #2 predicted fragment length is 127 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #2 alternative fragment length(s) may be 127 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #2.2 Generate R script for model : XX-650-23_CREB_ChIPSeq_PC_model.r \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #3 Call peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:31:45: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:33:47: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:34:54: #4 Write output xls file... XX-650-23_CREB_ChIPSeq_PC_peaks.xls \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:34:54: #4 Write peak in narrowPeak format file... XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:34:54: #4 Write summits bed file... XX-650-23_CREB_ChIPSeq_PC_summits.bed \r\n",
      "INFO  @ Wed, 25 Jan 2017 15:34:54: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t SRR2919455_1sorted.bam -c SRR2919456_1sorted.bam -f BAM -g hs -n XX-650-23_CREB_ChIPSeq_PC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chr1\t32710\t32889\tXX-650-23_CREB_ChIPSeq_PC_peak_1\t26\t.\t3.77106\t5.96592\t2.69349\t157\r\n",
      "chr1\t712305\t712628\tXX-650-23_CREB_ChIPSeq_PC_peak_2\t44\t.\t4.91328\t7.94848\t4.48610\t223\r\n",
      "chr1\t713430\t714545\tXX-650-23_CREB_ChIPSeq_PC_peak_3\t1063\t.\t32.88519\t113.17110\t106.32307\t681\r\n",
      "chr1\t762684\t762842\tXX-650-23_CREB_ChIPSeq_PC_peak_4\t41\t.\t4.87901\t7.58608\t4.15477\t77\r\n",
      "chr1\t935890\t936645\tXX-650-23_CREB_ChIPSeq_PC_peak_5\t378\t.\t14.95761\t42.56922\t37.84654\t449\r\n",
      "chr1\t1051493\t1051829\tXX-650-23_CREB_ChIPSeq_PC_peak_6\t145\t.\t9.25066\t18.55763\t14.56296\t107\r\n",
      "chr1\t1167332\t1167475\tXX-650-23_CREB_ChIPSeq_PC_peak_7\t42\t.\t4.75924\t7.68965\t4.24550\t86\r\n",
      "chr1\t1243601\t1243771\tXX-650-23_CREB_ChIPSeq_PC_peak_8\t59\t.\t5.88679\t9.54697\t5.96353\t78\r\n",
      "chr1\t1310554\t1311323\tXX-650-23_CREB_ChIPSeq_PC_peak_9\t571\t.\t13.15314\t62.41165\t57.12908\t341\r\n",
      "chr1\t1311427\t1311651\tXX-650-23_CREB_ChIPSeq_PC_peak_10\t41\t.\t5.04582\t7.55886\t4.12797\t160\r\n"
     ]
    }
   ],
   "source": [
    "head XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The amount of peaks can be found by executing following command:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5898 XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak\r\n"
     ]
    }
   ],
   "source": [
    "wc -l  XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "415 DMSO_CREB_ChIPSeq_PC_peaks.narrowPeak\r\n"
     ]
    }
   ],
   "source": [
    "wc -l DMSO_CREB_ChIPSeq_PC_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The sorted and indexed BAM files were loaded into IGV together with the \"narrowpeak files\". For the BAM files  their names were changed: \n",
    "SRR2919453 => DMSO CREB_ChipSeq\n",
    "SRR2919454 => DMSO inputDNA\n",
    "SRR2919455 => XX-650-23 CREB_ChIPSeq\n",
    "SRR2919456 => XX-650-23 inputDNA\n",
    "\n",
    "We then compared our results with the results given in the paper. According to the paper, treatment with XX-650-23 inhibits CREB binding to CBP and therefore also should inhibit binding of CREB to the DNA. \n",
    "\n",
    "But when visualizing the data, we noticed something strange as for the DMSO sample almost no peaks were called, although there was an open DNA region. We checked both the XX-650-23 input DNA and DMSO input DNA, a lower background was noticed in the DMSO input sample. Thus, we should expect at least some peak calling. (This is visualized for the CCNA2 gene in figure 8).  \n",
    "\n",
    "The big difference in the input DNA files seemed strange to us, since the input samples should represent unspecific binding to the DNA, we expected to see a similar pattern in these samples. Since this was not the case we decided to check whether the problem was due to the XX-650-23 input DNA sample or to the DMSO input DNA.  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 8\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/Normal_inputs.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Therefore, we performed peak calling with XX-650-23 input DNA (SRR2919456) for both samples as well as peak calling with DMSO input DNA (SRR2919454) for both samples. The output \".narrowpeak\" files were visualized in IGV, as shown in figure 9. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Wed, 25 Jan 2017 17:57:52: \r\n",
      "# Command line: callpeak -t SRR2919453_1sorted.bam -c SRR2919456_1sorted.bam -f BAM -g hs -n DMSO_XXinput_ChIPSeq_PC\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = DMSO_XXinput_ChIPSeq_PC\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['SRR2919453_1sorted.bam']\r\n",
      "# control file = ['SRR2919456_1sorted.bam']\r\n",
      "# effective genome size = 2.70e+09\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-02\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:57:52: #1 read tag files... \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:57:52: #1 read treatment tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:57:57:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:02:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:07:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:12:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:17:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:22:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:27:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:31:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:36:  9000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:41:  10000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:45:  11000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:50:  12000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:58:55:  13000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:00:  14000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:05:  15000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:10:  16000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:15:  17000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:20:  18000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:25:  19000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:29:  20000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:34:  21000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:38:  22000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:43:  23000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:48:  24000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:52:  25000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 17:59:57:  26000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:02:  27000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:08:  28000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:13:  29000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:18:  30000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:24:  31000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:28:  32000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:33:  33000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:38:  34000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:43:  35000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:47:  36000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:52:  37000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:00:57:  38000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:02:  39000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:06:  40000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:08:  41000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:11: #1.2 read input tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:16:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:21:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:26:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:31:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:35:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:40:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:45:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:50:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:54:  9000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:01:59:  10000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:04:  11000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:08:  12000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:13:  13000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:18:  14000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:23:  15000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:28:  16000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:32:  17000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:37:  18000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:42:  19000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:46:  20000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:51:  21000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:02:56:  22000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:01:  23000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:06:  24000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:12:  25000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:18:  26000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:23:  27000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:29:  28000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:33:  29000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:38:  30000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:43:  31000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:48:  32000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:52:  33000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:55:  34000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:56: #1 tag size is determined as 51 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:56: #1 tag size = 51 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:56: #1  total tags in treatment: 39477643 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:56: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:56: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:57: #1  tags after filtering in treatment: 36585819 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:57: #1  Redundant rate of treatment: 0.07 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:57: #1  total tags in control: 32747440 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:57: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:57: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:58: #1  tags after filtering in control: 30181059 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:58: #1  Redundant rate of control: 0.08 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:58: #1 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:58: #2 Build Peak Model... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:03:58: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:01: #2 number of paired peaks: 8092 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:01: start model_add_line... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: start X-correlation... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: end of X-cor \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #2 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #2 predicted fragment length is 108 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #2 alternative fragment length(s) may be 108 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #2.2 Generate R script for model : DMSO_XXinput_ChIPSeq_PC_model.r \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #3 Call peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:04:02: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:06:28: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:07:42: #4 Write output xls file... DMSO_XXinput_ChIPSeq_PC_peaks.xls \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:07:42: #4 Write peak in narrowPeak format file... DMSO_XXinput_ChIPSeq_PC_peaks.narrowPeak \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:07:42: #4 Write summits bed file... DMSO_XXinput_ChIPSeq_PC_summits.bed \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:07:42: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t SRR2919453_1sorted.bam -c SRR2919456_1sorted.bam -f BAM -g hs -n DMSO_XXinput_ChIPSeq_PC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Wed, 25 Jan 2017 18:36:42: \r\n",
      "# Command line: callpeak -t SRR2919455_1sorted.bam -c SRR2919454_1sorted.bam -f BAM -g hs -n XX-650-23_DMSOinput_PC\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = XX-650-23_DMSOinput_PC\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['SRR2919455_1sorted.bam']\r\n",
      "# control file = ['SRR2919454_1sorted.bam']\r\n",
      "# effective genome size = 2.70e+09\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-02\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:42: #1 read tag files... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:42: #1 read treatment tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:45:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:49:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:53:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:36:57:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:01:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:04:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:09:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:14:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:21:  9000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:28:  10000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:33:  11000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:38:  12000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:42:  13000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:46:  14000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:51:  15000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:37:57:  16000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:04:  17000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:11:  18000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:18:  19000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:24:  20000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:31:  21000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:38:  22000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:44:  23000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:51:  24000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:38:58:  25000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:05:  26000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:13:  27000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:20:  28000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:28:  29000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:35:  30000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:41:  31000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:46:  32000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:50:  33000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:53: #1.2 read input tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:39:58:  1000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:05:  2000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:11:  3000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:17:  4000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:22:  5000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:30:  6000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:35:  7000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38:  8000000 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38: #1 tag size is determined as 51 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38: #1 tag size = 51 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38: #1  total tags in treatment: 31895955 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:38: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1  tags after filtering in treatment: 29300477 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1  Redundant rate of treatment: 0.08 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1  total tags in control: 7674222 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1 user defined the maximum tags... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1  tags after filtering in control: 6327055 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1  Redundant rate of control: 0.18 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #1 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #2 Build Peak Model... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:39: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #2 number of paired peaks: 9638 \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: start model_add_line... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: start X-correlation... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: end of X-cor \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #2 finished! \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #2 predicted fragment length is 127 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #2 alternative fragment length(s) may be 127 bps \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #2.2 Generate R script for model : XX-650-23_DMSOinput_PC_model.r \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #3 Call peaks... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:40:43: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:41:31: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:41:55: #4 Write output xls file... XX-650-23_DMSOinput_PC_peaks.xls \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:41:55: #4 Write peak in narrowPeak format file... XX-650-23_DMSOinput_PC_peaks.narrowPeak \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:41:55: #4 Write summits bed file... XX-650-23_DMSOinput_PC_summits.bed \r\n",
      "INFO  @ Wed, 25 Jan 2017 18:41:55: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t SRR2919455_1sorted.bam -c SRR2919454_1sorted.bam -f BAM -g hs -n XX-650-23_DMSOinput_PC"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A higher peak calling was seen for the DMSO sample when we used the XX-650-23 input DNA (the DMSO_XXinput_ChIPSeq_PC_peaks_narrowPeak.bed), which seems more logic to us since there was a clearly open DNA region seen in the DMSO CREB_ChIPSeq_sorted.bam, suggesting there should be called a peak there (visualized in figure 9). Based on these findings, we decided to use the XX-650-23 input DNA for both samples and for further analysis.\n",
    "\n",
    "In figure 9, we zoomed in on the CCNA2 gene, which was also discussed in the paper. The peaks were located around the Transcription Start Site (TSS) because that indicates the place where the transcription factor (CREB) will bind. The CCNA2 is an important cell cycle regulator, again showing the important role of CREB in regulation of cell proliferation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 9\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/CCNA2_figure7.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Motif discovery via RSAT & GREAT"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The XX-650-23 narrowpeak file was used to create a new “.bed file”. This \".bed file\" containing the peaks was converted into a fasta file by using following tool (http://rsat-tagc.univ-mrs.fr/fetch-sequences_form.php). The obtained fasta sequence was loaded into RSAT Metazoa to perform motif discovery. \n",
    "\n",
    "20 possible motifs were found for the XX-650-23 treated samples (http://rsat.sb-roscoff.fr/tmp/apache/2017/01/24/peak-motifs.2017-01-24.174004_2017-01-24.174004_DBKt0H/peak-motifs_synthesis.html#discovered_motifs_10).  RSAT- motifs 6 and 9 showed great similarity to the motif found in the article which at its turn is similar to the CREB consensus sequence. (Motif 6 is visualized in figure 10). \n",
    "\n",
    "We can conclude that the CREB peaks identified on ChIP-Seq analysis were enriched for the canonical CRE element binding sequence."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 10 \n",
    "<img width=\"100%\" src=\"/user/r0363211/files/Motif6.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to use GREAT, new “.bed files” were created from the original \".narrowPeak\" files. The following command was used to change the q-score into integers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cat XX-650-23_CREB_ChIPSeq_PC_peaks.narrowPeak | cut -f 1-4 > XX-650-23_CREB_ChIPSeq_PC_peaks.bed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cat DMSO_XXinput_ChIPSeq_PC_peaks.narrowPeak  | cut -f 1-4 > DMSO_XXinput_ChIPSeq_PC_peaks.bed"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The GREAT analysis was used to show the most important biological processes that are associated with the CREB ChIP-seq peaks. This was done for both the DMSO-treated as for the XX-650-23 treated samples. \n",
    "\n",
    "Gene ontology showed that peaks were enriched in genes mainly regulating translation and mRNA processing. In the paper, they also stress the genes regulating cell cycle and apoptosis. \n",
    "\n",
    "However, we did also find this in our GREAT analysis but at a much lower signifance as for the genes involved in translation and mRNA processing.  \n",
    "\n",
    "(Results for the XX-650-23 treated cells and DMSO treated cells are shown in figure 11 and 12, respectively)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 11 (XX-650-23 treated samples)\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/XX-650-23_GREAT.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Figure 12 (DMSO-treated samples)\n",
    "<img width=\"100%\" src=\"/user/r0363211/files/DMSO_XXinputDNA_GREAT.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Discussion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "RNA-seq data confirmed the results discussed in the paper. Gene ontology analysis indeed shows the role of CREB in cell proliferative processes. \n",
    "\n",
    "For the ChIP-seq we could confirm the motif the findings discussed in the paper but we encountered a few problems with the data. We think that the DMSO input file is incorrect. We suggest that the experiment should be redone to prove validity of the experiment. \n",
    "\n",
    "Interestingly, the RNA-seq was discussed in detail in the paper, whereas this was not the case for the ChIP-Seq data. So maybe the authors already had knowledge of the pitfalls of their data. \n",
    "\n",
    "As for CREB being an interesting target for AML treatment, we are still a bit cautious. We could indeed find the clear correlation between CREB and cell proliferation, but found many other cellular processes under regulation of CREB. Therefore, we fear that targeting CREB could induce several side effects."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Bash",
   "language": "bash",
   "name": "bash"
  },
  "language_info": {
   "codemirror_mode": "shell",
   "file_extension": ".sh",
   "mimetype": "text/x-sh",
   "name": "bash"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
