{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## RNA seq analysis: PAX8 knocked-out\n",
    "In this notebook, we performed the analysis of RNA seq data on two different cell lines of ovarian cancer SKOV-3: wild-type and PAX8 knocked-out.\n",
    "The dataset were retrieved from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE79572"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We first created a work directory."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/mnt/storage/r0479539/jupyternotebooks\r\n"
     ]
    }
   ],
   "source": [
    "pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cd ~/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/luna.kuleuven.be/r0479539/data/work\r\n"
     ]
    }
   ],
   "source": [
    "pwd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the next step, we download and convert the files into .fastq. Since we have paired-end data, the command --split-files created two files, one for each read.\n",
    "We download WT sample 1 (SRR3289897) and sample 2 (SRR3289899), and KO sample 1 (SRR3289898) and sample 2 (SRR3289900)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 21467787 spots for SRR3289897\r\n",
      "Written 21467787 spots for SRR3289897\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR3289897"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 21652426 spots for SRR3289898\r\n",
      "Written 21652426 spots for SRR3289898\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR3289898"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 17190531 spots for SRR3289899\r\n",
      "Written 17190531 spots for SRR3289899\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR3289899"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 16905879 spots for SRR3289900\r\n",
      "Written 16905879 spots for SRR3289900\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR3289900"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we rename the files."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "mv SRR3289897_1.fastq WT_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289897_2.fastq WT_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289898_1.fastq KO_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289898_2.fastq KO_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289899_1.fastq WT2_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289899_2.fastq WT2_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289900_1.fastq KO2_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mv SRR3289900_2.fastq KO2_2.fastq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Quality control\n",
    "Now we perform quality control on each sample using FASTQ tool. The program is located in /usr/local/bin/FastQC/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of WT_1.fastq\r\n",
      "Approx 5% complete for WT_1.fastq\r\n",
      "Approx 10% complete for WT_1.fastq\r\n",
      "Approx 15% complete for WT_1.fastq\r\n",
      "Approx 20% complete for WT_1.fastq\r\n",
      "Approx 25% complete for WT_1.fastq\r\n",
      "Approx 30% complete for WT_1.fastq\r\n",
      "Approx 35% complete for WT_1.fastq\r\n",
      "Approx 40% complete for WT_1.fastq\r\n",
      "Approx 45% complete for WT_1.fastq\r\n",
      "Approx 50% complete for WT_1.fastq\r\n",
      "Approx 55% complete for WT_1.fastq\r\n",
      "Approx 60% complete for WT_1.fastq\r\n",
      "Approx 65% complete for WT_1.fastq\r\n",
      "Approx 70% complete for WT_1.fastq\r\n",
      "Approx 75% complete for WT_1.fastq\r\n",
      "Approx 80% complete for WT_1.fastq\r\n",
      "Approx 85% complete for WT_1.fastq\r\n",
      "Approx 90% complete for WT_1.fastq\r\n",
      "Approx 95% complete for WT_1.fastq\r\n",
      "Analysis complete for WT_1.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . WT_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of WT_2.fastq\r\n",
      "Approx 5% complete for WT_2.fastq\r\n",
      "Approx 10% complete for WT_2.fastq\r\n",
      "Approx 15% complete for WT_2.fastq\r\n",
      "Approx 20% complete for WT_2.fastq\r\n",
      "Approx 25% complete for WT_2.fastq\r\n",
      "Approx 30% complete for WT_2.fastq\r\n",
      "Approx 35% complete for WT_2.fastq\r\n",
      "Approx 40% complete for WT_2.fastq\r\n",
      "Approx 45% complete for WT_2.fastq\r\n",
      "Approx 50% complete for WT_2.fastq\r\n",
      "Approx 55% complete for WT_2.fastq\r\n",
      "Approx 60% complete for WT_2.fastq\r\n",
      "Approx 65% complete for WT_2.fastq\r\n",
      "Approx 70% complete for WT_2.fastq\r\n",
      "Approx 75% complete for WT_2.fastq\r\n",
      "Approx 80% complete for WT_2.fastq\r\n",
      "Approx 85% complete for WT_2.fastq\r\n",
      "Approx 90% complete for WT_2.fastq\r\n",
      "Approx 95% complete for WT_2.fastq\r\n",
      "Analysis complete for WT_2.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . WT_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of KO_1.fastq\r\n",
      "Approx 5% complete for KO_1.fastq\r\n",
      "Approx 10% complete for KO_1.fastq\r\n",
      "Approx 15% complete for KO_1.fastq\r\n",
      "Approx 20% complete for KO_1.fastq\r\n",
      "Approx 25% complete for KO_1.fastq\r\n",
      "Approx 30% complete for KO_1.fastq\r\n",
      "Approx 35% complete for KO_1.fastq\r\n",
      "Approx 40% complete for KO_1.fastq\r\n",
      "Approx 45% complete for KO_1.fastq\r\n",
      "Approx 50% complete for KO_1.fastq\r\n",
      "Approx 55% complete for KO_1.fastq\r\n",
      "Approx 60% complete for KO_1.fastq\r\n",
      "Approx 65% complete for KO_1.fastq\r\n",
      "Approx 70% complete for KO_1.fastq\r\n",
      "Approx 75% complete for KO_1.fastq\r\n",
      "Approx 80% complete for KO_1.fastq\r\n",
      "Approx 85% complete for KO_1.fastq\r\n",
      "Approx 90% complete for KO_1.fastq\r\n",
      "Approx 95% complete for KO_1.fastq\r\n",
      "Analysis complete for KO_1.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . KO_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of KO_2.fastq\r\n",
      "Approx 5% complete for KO_2.fastq\r\n",
      "Approx 10% complete for KO_2.fastq\r\n",
      "Approx 15% complete for KO_2.fastq\r\n",
      "Approx 20% complete for KO_2.fastq\r\n",
      "Approx 25% complete for KO_2.fastq\r\n",
      "Approx 30% complete for KO_2.fastq\r\n",
      "Approx 35% complete for KO_2.fastq\r\n",
      "Approx 40% complete for KO_2.fastq\r\n",
      "Approx 45% complete for KO_2.fastq\r\n",
      "Approx 50% complete for KO_2.fastq\r\n",
      "Approx 55% complete for KO_2.fastq\r\n",
      "Approx 60% complete for KO_2.fastq\r\n",
      "Approx 65% complete for KO_2.fastq\r\n",
      "Approx 70% complete for KO_2.fastq\r\n",
      "Approx 75% complete for KO_2.fastq\r\n",
      "Approx 80% complete for KO_2.fastq\r\n",
      "Approx 85% complete for KO_2.fastq\r\n",
      "Approx 90% complete for KO_2.fastq\r\n",
      "Approx 95% complete for KO_2.fastq\r\n",
      "Analysis complete for KO_2.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . KO_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of WT2_1.fastq\r\n",
      "Approx 5% complete for WT2_1.fastq\r\n",
      "Approx 10% complete for WT2_1.fastq\r\n",
      "Approx 15% complete for WT2_1.fastq\r\n",
      "Approx 20% complete for WT2_1.fastq\r\n",
      "Approx 25% complete for WT2_1.fastq\r\n",
      "Approx 30% complete for WT2_1.fastq\r\n",
      "Approx 35% complete for WT2_1.fastq\r\n",
      "Approx 40% complete for WT2_1.fastq\r\n",
      "Approx 45% complete for WT2_1.fastq\r\n",
      "Approx 50% complete for WT2_1.fastq\r\n",
      "Approx 55% complete for WT2_1.fastq\r\n",
      "Approx 60% complete for WT2_1.fastq\r\n",
      "Approx 65% complete for WT2_1.fastq\r\n",
      "Approx 70% complete for WT2_1.fastq\r\n",
      "Approx 75% complete for WT2_1.fastq\r\n",
      "Approx 80% complete for WT2_1.fastq\r\n",
      "Approx 85% complete for WT2_1.fastq\r\n",
      "Approx 90% complete for WT2_1.fastq\r\n",
      "Approx 95% complete for WT2_1.fastq\r\n",
      "Analysis complete for WT2_1.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . WT2_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of WT2_2.fastq\r\n",
      "Approx 5% complete for WT2_2.fastq\r\n",
      "Approx 10% complete for WT2_2.fastq\r\n",
      "Approx 15% complete for WT2_2.fastq\r\n",
      "Approx 20% complete for WT2_2.fastq\r\n",
      "Approx 25% complete for WT2_2.fastq\r\n",
      "Approx 30% complete for WT2_2.fastq\r\n",
      "Approx 35% complete for WT2_2.fastq\r\n",
      "Approx 40% complete for WT2_2.fastq\r\n",
      "Approx 45% complete for WT2_2.fastq\r\n",
      "Approx 50% complete for WT2_2.fastq\r\n",
      "Approx 55% complete for WT2_2.fastq\r\n",
      "Approx 60% complete for WT2_2.fastq\r\n",
      "Approx 65% complete for WT2_2.fastq\r\n",
      "Approx 70% complete for WT2_2.fastq\r\n",
      "Approx 75% complete for WT2_2.fastq\r\n",
      "Approx 80% complete for WT2_2.fastq\r\n",
      "Approx 85% complete for WT2_2.fastq\r\n",
      "Approx 90% complete for WT2_2.fastq\r\n",
      "Approx 95% complete for WT2_2.fastq\r\n",
      "Analysis complete for WT2_2.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . WT2_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of KO2_1.fastq\r\n",
      "Approx 5% complete for KO2_1.fastq\r\n",
      "Approx 10% complete for KO2_1.fastq\r\n",
      "Approx 15% complete for KO2_1.fastq\r\n",
      "Approx 20% complete for KO2_1.fastq\r\n",
      "Approx 25% complete for KO2_1.fastq\r\n",
      "Approx 30% complete for KO2_1.fastq\r\n",
      "Approx 35% complete for KO2_1.fastq\r\n",
      "Approx 40% complete for KO2_1.fastq\r\n",
      "Approx 45% complete for KO2_1.fastq\r\n",
      "Approx 50% complete for KO2_1.fastq\r\n",
      "Approx 55% complete for KO2_1.fastq\r\n",
      "Approx 60% complete for KO2_1.fastq\r\n",
      "Approx 65% complete for KO2_1.fastq\r\n",
      "Approx 70% complete for KO2_1.fastq\r\n",
      "Approx 75% complete for KO2_1.fastq\r\n",
      "Approx 80% complete for KO2_1.fastq\r\n",
      "Approx 85% complete for KO2_1.fastq\r\n",
      "Approx 90% complete for KO2_1.fastq\r\n",
      "Approx 95% complete for KO2_1.fastq\r\n",
      "Analysis complete for KO2_1.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . KO2_1.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of KO2_2.fastq\r\n",
      "Approx 5% complete for KO2_2.fastq\r\n",
      "Approx 10% complete for KO2_2.fastq\r\n",
      "Approx 15% complete for KO2_2.fastq\r\n",
      "Approx 20% complete for KO2_2.fastq\r\n",
      "Approx 25% complete for KO2_2.fastq\r\n",
      "Approx 30% complete for KO2_2.fastq\r\n",
      "Approx 35% complete for KO2_2.fastq\r\n",
      "Approx 40% complete for KO2_2.fastq\r\n",
      "Approx 45% complete for KO2_2.fastq\r\n",
      "Approx 50% complete for KO2_2.fastq\r\n",
      "Approx 55% complete for KO2_2.fastq\r\n",
      "Approx 60% complete for KO2_2.fastq\r\n",
      "Approx 65% complete for KO2_2.fastq\r\n",
      "Approx 70% complete for KO2_2.fastq\r\n",
      "Approx 75% complete for KO2_2.fastq\r\n",
      "Approx 80% complete for KO2_2.fastq\r\n",
      "Approx 85% complete for KO2_2.fastq\r\n",
      "Approx 90% complete for KO2_2.fastq\r\n",
      "Approx 95% complete for KO2_2.fastq\r\n",
      "Analysis complete for KO2_2.fastq\r\n"
     ]
    }
   ],
   "source": [
    "/usr/local/bin/FastQC/fastqc -o . KO2_2.fastq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that we have obtained the fastQC reports, we proceeded with the analysis.\n",
    "\n",
    "The \"per base sequence quality\" section reveals an overall good quality for all the samples. The lower quartile of all the boxplots remains above 25, and above 30 for most of the bases). In WT_2, KO_2, WT2_2 and KO2_2, the quality decreases towards the end. However, we decided not to trim the sequences since it is only the lower whisker that notably decreases but the lower quartile remains above 30, and trimming can alter the subsequent gene expression estimation.\n",
    "\n",
    "\n",
    "The graphs represent the per base sequence quality. On the left, we observe the graph corresponding to WT_1. On the right, the one corresponding to WT_2; we can clearly observe how the mean quality remains good, even with the decrease in quality around read 55.\n",
    "\n",
    "In the section “Sequence duplication levels” (graphs not shown), we can observe that for all the samples, between 70% and 80% of the sequences are non-duplicated, which is an acceptable value.\n",
    "The percentage of sequences that are repeated (2 or more times) remains under 20% for all the samples.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"https://jupyter.gbiomed.kuleuven.be/user/r0479539/files/Qualities.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Mapping to the genome\n",
    "Now we are going to map the fastq to the human genome by using STAR. We use a database with the human genome and gene notation. We find this at the given directory: /mnt/nfs/mfiers/STAR/hg19_star_db.\n",
    "In this step, we merge both reads, for each file, in one single .bam file."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For WT_1.fastq and WT_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jan 23 22:53:59 ..... started STAR run\r\n",
      "Jan 23 22:53:59 ..... loading genome\r\n",
      "Jan 23 22:54:00 ..... started mapping\r\n",
      "Jan 23 23:15:02 ..... finished successfully\r\n"
     ]
    }
   ],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn WT_1.fastq WT_2.fastq \\\n",
    "     --outFileNamePrefix WT."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we want to obtain the corresponding SAM file, containing the assignment of all reads."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 18 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -o WT.bam WT.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index WT.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chrM\t16571\t91902\t0\r\n",
      "chr1\t249250621\t4188162\t0\r\n",
      "chr2\t243199373\t3050846\t0\r\n",
      "chr3\t198022430\t2287800\t0\r\n",
      "chr4\t191154276\t1311468\t0\r\n",
      "chr5\t180915260\t1981622\t0\r\n",
      "chr6\t171115067\t3344588\t0\r\n",
      "chr7\t159138663\t1155330\t0\r\n",
      "chr8\t146364022\t1380746\t0\r\n",
      "chr9\t141213431\t1957054\t0\r\n",
      "chr10\t135534747\t1707136\t0\r\n",
      "chr11\t135006516\t2620586\t0\r\n",
      "chr12\t133851895\t2902460\t0\r\n",
      "chr13\t115169878\t678050\t0\r\n",
      "chr14\t107349540\t2548164\t0\r\n",
      "chr15\t102531392\t1287498\t0\r\n",
      "chr16\t90354753\t1601168\t0\r\n",
      "chr17\t81195210\t2833798\t0\r\n",
      "chr18\t78077248\t663360\t0\r\n",
      "chr19\t59128983\t1962308\t0\r\n",
      "chr20\t63025520\t1031006\t0\r\n",
      "chr21\t48129895\t377542\t0\r\n",
      "chr22\t51304566\t751676\t0\r\n",
      "chrX\t155270560\t1311908\t0\r\n",
      "chrY\t59373566\t54622\t0\r\n",
      "*\t0\t0\t0\r\n"
     ]
    }
   ],
   "source": [
    "samtools idxstats WT.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By running samtools flagstat, we can obseve that there are no overrepresented sequences found. This indicates towards the absence of contaminants present in the samples.*\n",
    "\n",
    "*This is the case for all samples analysed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "43080800 + 0 in total (QC-passed reads + QC-failed reads)\r\n",
      "1897112 + 0 secondary\r\n",
      "0 + 0 supplementary\r\n",
      "0 + 0 duplicates\r\n",
      "43080800 + 0 mapped (100.00% : N/A)\r\n",
      "41183688 + 0 paired in sequencing\r\n",
      "20591844 + 0 read1\r\n",
      "20591844 + 0 read2\r\n",
      "41183688 + 0 properly paired (100.00% : N/A)\r\n",
      "41183688 + 0 with itself and mate mapped\r\n",
      "0 + 0 singletons (0.00% : N/A)\r\n",
      "0 + 0 with mate mapped to a different chr\r\n",
      "0 + 0 with mate mapped to a different chr (mapQ>=5)\r\n"
     ]
    }
   ],
   "source": [
    "samtools flagstat WT.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For KO_1.fastq and KO_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jan 23 23:36:34 ..... started STAR run\r\n",
      "Jan 23 23:36:34 ..... loading genome\r\n",
      "Jan 23 23:36:34 ..... started mapping\r\n",
      "Jan 23 23:54:07 ..... finished successfully\r\n"
     ]
    }
   ],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn KO_1.fastq KO_2.fastq  \\\n",
    "     --outFileNamePrefix KO."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 18 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -o KO.bam KO.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index KO.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chrM\t16571\t88204\t0\r\n",
      "chr1\t249250621\t4306144\t0\r\n",
      "chr2\t243199373\t3097732\t0\r\n",
      "chr3\t198022430\t2358608\t0\r\n",
      "chr4\t191154276\t1356408\t0\r\n",
      "chr5\t180915260\t2032494\t0\r\n",
      "chr6\t171115067\t3300178\t0\r\n",
      "chr7\t159138663\t1180846\t0\r\n",
      "chr8\t146364022\t1406674\t0\r\n",
      "chr9\t141213431\t1977604\t0\r\n",
      "chr10\t135534747\t1702624\t0\r\n",
      "chr11\t135006516\t2606550\t0\r\n",
      "chr12\t133851895\t2957904\t0\r\n",
      "chr13\t115169878\t692926\t0\r\n",
      "chr14\t107349540\t2447768\t0\r\n",
      "chr15\t102531392\t1209104\t0\r\n",
      "chr16\t90354753\t1627480\t0\r\n",
      "chr17\t81195210\t2834016\t0\r\n",
      "chr18\t78077248\t680788\t0\r\n",
      "chr19\t59128983\t1992794\t0\r\n",
      "chr20\t63025520\t1057236\t0\r\n",
      "chr21\t48129895\t413934\t0\r\n",
      "chr22\t51304566\t769168\t0\r\n",
      "chrX\t155270560\t1336308\t0\r\n",
      "chrY\t59373566\t58080\t0\r\n",
      "*\t0\t0\t0\r\n"
     ]
    }
   ],
   "source": [
    "samtools idxstats KO.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "43491572 + 0 in total (QC-passed reads + QC-failed reads)\r\n",
      "1874906 + 0 secondary\r\n",
      "0 + 0 supplementary\r\n",
      "0 + 0 duplicates\r\n",
      "43491572 + 0 mapped (100.00% : N/A)\r\n",
      "41616666 + 0 paired in sequencing\r\n",
      "20808333 + 0 read1\r\n",
      "20808333 + 0 read2\r\n",
      "41616666 + 0 properly paired (100.00% : N/A)\r\n",
      "41616666 + 0 with itself and mate mapped\r\n",
      "0 + 0 singletons (0.00% : N/A)\r\n",
      "0 + 0 with mate mapped to a different chr\r\n",
      "0 + 0 with mate mapped to a different chr (mapQ>=5)\r\n"
     ]
    }
   ],
   "source": [
    "samtools flagstat KO.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For WT2_1.fastq and WT2_2.fastq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jan 24 15:17:46 ..... started STAR run\r\n",
      "Jan 24 15:17:46 ..... loading genome\r\n",
      "Jan 24 15:17:46 ..... started mapping\r\n",
      "Jan 24 15:31:19 ..... finished successfully\r\n"
     ]
    }
   ],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn WT2_1.fastq WT2_2.fastq  \\\n",
    "     --outFileNamePrefix WT2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 15 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -o WT2.bam WT2.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index WT2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chrM\t16571\t33156\t0\r\n",
      "chr1\t249250621\t3216138\t0\r\n",
      "chr2\t243199373\t2373952\t0\r\n",
      "chr3\t198022430\t1880330\t0\r\n",
      "chr4\t191154276\t1027984\t0\r\n",
      "chr5\t180915260\t1539602\t0\r\n",
      "chr6\t171115067\t2555846\t0\r\n",
      "chr7\t159138663\t892366\t0\r\n",
      "chr8\t146364022\t1083186\t0\r\n",
      "chr9\t141213431\t1693926\t0\r\n",
      "chr10\t135534747\t1317230\t0\r\n",
      "chr11\t135006516\t2088418\t0\r\n",
      "chr12\t133851895\t2240684\t0\r\n",
      "chr13\t115169878\t536484\t0\r\n",
      "chr14\t107349540\t3793976\t0\r\n",
      "chr15\t102531392\t1002292\t0\r\n",
      "chr16\t90354753\t1225134\t0\r\n",
      "chr17\t81195210\t2154664\t0\r\n",
      "chr18\t78077248\t525426\t0\r\n",
      "chr19\t59128983\t1468690\t0\r\n",
      "chr20\t63025520\t782056\t0\r\n",
      "chr21\t48129895\t298286\t0\r\n",
      "chr22\t51304566\t564404\t0\r\n",
      "chrX\t155270560\t1007088\t0\r\n",
      "chrY\t59373566\t33088\t0\r\n",
      "*\t0\t0\t0\r\n"
     ]
    }
   ],
   "source": [
    "samtools idxstats WT2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "35334406 + 0 in total (QC-passed reads + QC-failed reads)\r\n",
      "2171704 + 0 secondary\r\n",
      "0 + 0 supplementary\r\n",
      "0 + 0 duplicates\r\n",
      "35334406 + 0 mapped (100.00% : N/A)\r\n",
      "33162702 + 0 paired in sequencing\r\n",
      "16581351 + 0 read1\r\n",
      "16581351 + 0 read2\r\n",
      "33162702 + 0 properly paired (100.00% : N/A)\r\n",
      "33162702 + 0 with itself and mate mapped\r\n",
      "0 + 0 singletons (0.00% : N/A)\r\n",
      "0 + 0 with mate mapped to a different chr\r\n",
      "0 + 0 with mate mapped to a different chr (mapQ>=5)\r\n"
     ]
    }
   ],
   "source": [
    "samtools flagstat WT2.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For KO2_1 and KO2_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jan 24 15:50:10 ..... started STAR run\r\n",
      "Jan 24 15:50:10 ..... loading genome\r\n",
      "Jan 24 15:50:10 ..... started mapping\r\n",
      "Jan 24 16:04:20 ..... finished successfully\r\n"
     ]
    }
   ],
   "source": [
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn KO2_1.fastq KO2_2.fastq  \\\n",
    "     --outFileNamePrefix KO2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 15 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -o KO2.bam KO2.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index KO2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chrM\t16571\t44730\t0\r\n",
      "chr1\t249250621\t3235438\t0\r\n",
      "chr2\t243199373\t2296846\t0\r\n",
      "chr3\t198022430\t1872262\t0\r\n",
      "chr4\t191154276\t975228\t0\r\n",
      "chr5\t180915260\t1494340\t0\r\n",
      "chr6\t171115067\t2544808\t0\r\n",
      "chr7\t159138663\t869390\t0\r\n",
      "chr8\t146364022\t1028966\t0\r\n",
      "chr9\t141213431\t1675702\t0\r\n",
      "chr10\t135534747\t1279498\t0\r\n",
      "chr11\t135006516\t1975858\t0\r\n",
      "chr12\t133851895\t2307206\t0\r\n",
      "chr13\t115169878\t496756\t0\r\n",
      "chr14\t107349540\t4053964\t0\r\n",
      "chr15\t102531392\t909664\t0\r\n",
      "chr16\t90354753\t1180594\t0\r\n",
      "chr17\t81195210\t2161610\t0\r\n",
      "chr18\t78077248\t504612\t0\r\n",
      "chr19\t59128983\t1501300\t0\r\n",
      "chr20\t63025520\t781704\t0\r\n",
      "chr21\t48129895\t283056\t0\r\n",
      "chr22\t51304566\t564274\t0\r\n",
      "chrX\t155270560\t977236\t0\r\n",
      "chrY\t59373566\t28220\t0\r\n",
      "*\t0\t0\t0\r\n"
     ]
    }
   ],
   "source": [
    "samtools idxstats KO2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "35043262 + 0 in total (QC-passed reads + QC-failed reads)\r\n",
      "2252018 + 0 secondary\r\n",
      "0 + 0 supplementary\r\n",
      "0 + 0 duplicates\r\n",
      "35043262 + 0 mapped (100.00% : N/A)\r\n",
      "32791244 + 0 paired in sequencing\r\n",
      "16395622 + 0 read1\r\n",
      "16395622 + 0 read2\r\n",
      "32791244 + 0 properly paired (100.00% : N/A)\r\n",
      "32791244 + 0 with itself and mate mapped\r\n",
      "0 + 0 singletons (0.00% : N/A)\r\n",
      "0 + 0 with mate mapped to a different chr\r\n",
      "0 + 0 with mate mapped to a different chr (mapQ>=5)\r\n"
     ]
    }
   ],
   "source": [
    "samtools flagstat KO2.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reads to gene counts\n",
    "\n",
    "The next step is to count the number of reads that mapped to each gene. We first create a symbolic link to the human annotation (/mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.sort.gtf), and then using FeatureCounts we perform the count."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lrwxrwxrwx 1 r0479539 domain users 56 jan 23 18:46 gencode.v19.nopseudo.plus.sort.gtf -> /mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.sort.gtf\r\n"
     ]
    }
   ],
   "source": [
    "ln -sf /mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.sort.gtf  ~/data/work/\n",
    "ls -l *gtf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r\n",
      "       \u001b[44;37m ========== \u001b[0m\u001b[36m    _____ _    _ ____  _____  ______          _____  \r\n",
      "       \u001b[44;37m =====      \u001b[0m\u001b[36m   / ____| |  | |  _ \\|  __ \\|  ____|   /\\   |  __ \\ \r\n",
      "       \u001b[44;37m   =====    \u001b[0m\u001b[36m  | (___ | |  | | |_) | |__) | |__     /  \\  | |  | |\r\n",
      "       \u001b[44;37m     ====   \u001b[0m\u001b[36m   \\___ \\| |  | |  _ <|  _  /|  __|   / /\\ \\ | |  | |\r\n",
      "       \u001b[44;37m       ==== \u001b[0m\u001b[36m   ____) | |__| | |_) | | \\ \\| |____ / ____ \\| |__| |\r\n",
      "       \u001b[44;37m ========== \u001b[0m\u001b[36m  |_____/ \\____/|____/|_|  \\_\\______/_/    \\_\\_____/\u001b[0m\r\n",
      "\tv1.5.0-p1\r\n",
      "\r\n",
      "//==========================\u001b[36m featureCounts setting \u001b[0m===========================\\\\\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "||             Input files : \u001b[36m4 BAM files  \u001b[0m \u001b[0m                                   ||\r\n",
      "||                           \u001b[32mP\u001b[36m WT.bam\u001b[0m \u001b[0m                                        ||\r\n",
      "||                           \u001b[32mP\u001b[36m WT2.bam\u001b[0m \u001b[0m                                       ||\r\n",
      "||                           \u001b[32mP\u001b[36m KO.bam\u001b[0m \u001b[0m                                        ||\r\n",
      "||                           \u001b[32mP\u001b[36m KO2.bam\u001b[0m \u001b[0m                                       ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "||             Output file : \u001b[36mgene.counts\u001b[0m \u001b[0m                                     ||\r\n",
      "||             Annotations : \u001b[36m/mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.p\u001b[0m ...\u001b[0m \u001b[0m||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "||                 Threads : \u001b[36m1\u001b[0m \u001b[0m                                               ||\r\n",
      "||                   Level : \u001b[36mmeta-feature level\u001b[0m \u001b[0m                              ||\r\n",
      "||              Paired-end : \u001b[36mno\u001b[0m \u001b[0m                                              ||\r\n",
      "||         Strand specific : \u001b[36mno\u001b[0m \u001b[0m                                              ||\r\n",
      "||      Multimapping reads : \u001b[36mnot counted\u001b[0m \u001b[0m                                     ||\r\n",
      "|| Multi-overlapping reads : \u001b[36mnot counted\u001b[0m \u001b[0m                                     ||\r\n",
      "||       Read orientations : \u001b[36mfr\u001b[0m \u001b[0m                                              ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "\\\\=====================\u001b[36m http://subread.sourceforge.net/ \u001b[0m======================//\r\n",
      "\r\n",
      "//=================================\u001b[36m Running \u001b[0m==================================\\\\\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Load annotation file /mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.s\u001b[0m ... \u001b[0m||\r\n",
      "||    Features : \u001b[36m1156385\u001b[0m \u001b[0m                                                     ||\r\n",
      "||    Meta-features : \u001b[36m41863\u001b[0m \u001b[0m                                                  ||\r\n",
      "||    Chromosomes/contigs : \u001b[36m25\u001b[0m \u001b[0m                                               ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file WT.bam... \u001b[0m                                                ||\r\n",
      "||    Paired-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m43080800\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m32847440 (76.2%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.93 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file WT2.bam... \u001b[0m                                               ||\r\n",
      "||    Paired-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m35334406\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m25557825 (72.3%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.75 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file KO.bam... \u001b[0m                                                ||\r\n",
      "||    Paired-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m43491572\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m32938103 (75.7%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.90 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file KO2.bam... \u001b[0m                                               ||\r\n",
      "||    Paired-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m35043262\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m26079902 (74.4%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.69 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "||                         \u001b[36mRead assignment finished.\u001b[0m \u001b[0m                         ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "\\\\=====================\u001b[36m http://subread.sourceforge.net/ \u001b[0m======================//\r\n",
      "\r\n"
     ]
    }
   ],
   "source": [
    "featureCounts \\\n",
    "    -Q 10 \\\n",
    "    -g gene_name \\\n",
    "    -a /mnt/nfs/data/RNA-seq/gencode.v19.nopseudo.plus.sort.gtf \\\n",
    "    -o gene.counts \\\n",
    "    WT.bam WT2.bam KO.bam KO2.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Status                     WT.bam    WT2.bam   KO.bam    KO2.bam\r\n",
      "Assigned                   32847440  25557825  32938103  26079902\r\n",
      "Unassigned_Ambiguity       2152974   1608694   2158579   1654976\r\n",
      "Unassigned_MultiMapping    0         0         0         0\r\n",
      "Unassigned_NoFeatures      4779858   4328809   5138828   3319084\r\n",
      "Unassigned_Unmapped        0         0         0         0\r\n",
      "Unassigned_MappingQuality  3300528   3839078   3256062   3989300\r\n",
      "Unassigned_FragmentLength  0         0         0         0\r\n",
      "Unassigned_Chimera         0         0         0         0\r\n",
      "Unassigned_Secondary       0         0         0         0\r\n",
      "Unassigned_Nonjunction     0         0         0         0\r\n",
      "Unassigned_Duplicate       0         0         0         0\r\n"
     ]
    }
   ],
   "source": [
    "head -20 gene.counts.summary | column -t"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we separate the columns on gene structure and the columns with the actual counts."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cut -f-6 gene.counts > all.genedata.tsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cut -f1,7- gene.counts | grep -v '^#' > all.gene.counts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "We obtained a .count file, all.gene.counts, that after changing the extension to .tsv, we open in excel. We decided to change the order of the columns to KO KO2 WT WT2 so we would obtain the downregulated genes in KO. Next, we analyse the data using the DESeq package  --> continue in \"Addendum\" notebook"
   ]
  }
 ],
 "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
}
