{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Report Bioinformatics  2016-2017 - Katrien Neyrinck & Eleonora Persoons"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We start our report with making a new directory in our jupyternotebook (account of Eleonora Persoons: r0384602) called 'groepswerk' where we will store all our data.\n",
    "This notebook (Bash) will serve as our main report, while the R-notebook will serve as an addendum."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mkdir -p /mnt/storage/$USER/jupyternotebooks/groepswerk\n",
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Transactive response DNA-binding protein (TDP-43) is a nuclear protein that can bind RNA and DNA in most tissues. TDP-43 is involved in RNA metabolism as it regulates transcription and splicing within the cell. In addition, it plays a role in miRNA maturation, RNA transport and it is a subunit of the stress granule to protect mRNA during stress conditions. In the neurodegenerative diseases amyotrophic lateral sclerosis (ALS) and frontotemporal dementia (FTD), often TDP-43 aggregates are found within the cytosol of affected neurons. As a consequence, loss of the nuclear function of TDP-43 is observed as well as gain of new toxic functions within the cytoplasm which contributes to the degeneration of the neuron. \n",
    "\n",
    "Within this report, we searched for articles that performed knockdown of TDP-43. The observed effects upon TDP-43 silencing, could give us more insights in the pathologic mechanism of neurodegeneration in ALS and FTD."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Microarray data analysis "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- PubMed: https://www.ncbi.nlm.nih.gov/pubmed/?term=Knockdown+of+transactive+response+DNA-binding+protein+TDP-43+downregulates+histone+deacetylase+6\n",
    "- GeoData: https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE18632"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the article mentioned above, they performed knockdown of TDP-43 in HEK293E cells via RNA silencing using siRNA against TDP-43 compared to scrambled siRNA (negative control). Afterwards, microarray analysis was performed to asses the genes that are differentially expressed upon TDP-43 knockdown. The article states to have found histone deacetylase 6 (HDAC6) to be significantly downregulated when TDP-43 is silenced. HDAC6 is an cytoplasmic enzyme that connects ubiquitinated/misfolded proteins to the microtubules inducing their retrograde transport and subsequent degradation via autophagy. So in situations of HDAC6 deficiency, this mechanism is impaired inducing an increased proteotoxicity to the cell. This can be one possible mechanism contributing to the neurodegeneration seen in ALS and FTD characterized by TDP-43 loss of function.\n",
    "\n",
    "We now try to reproduce this microarray data analysis performed in this article."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, we download the package 'Affy'. See our R-jupyternotebook, COMMANDO 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to upload the celfiles into our directory, groepswerk, we use the following commando and we check whether the files are indeed there. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data_norm.eset\t  GSM463017.CEL.gz  GSM463020.CEL.gz\r\n",
      "GSM463015.CEL.gz  GSM463018.CEL.gz  GSM463021.CEL.gz\r\n",
      "GSM463016.CEL.gz  GSM463019.CEL.gz  GSM463022.CEL.gz\r\n"
     ]
    }
   ],
   "source": [
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk/ARRAY_GSE18632_RAW/\n",
    "ls"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We group these 8 gz-files under the name 'celfiles'. See COMMANDO 2.\n",
    "Because the 'celfiles' only contain a list of names, we now load the raw data as well. See COMMANDO 3."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Annotation of the samples was performed, using COMMANDO 4."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The next step is to merge the sampleNames with the actual tranfection used on the HEK293E cells. See COMMANDO 5."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We convert this dataframe into an annotated dataframe. See COMMANDO 6."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since we have 8 different samples, we normalise our data. See COMMANDO 7."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The current sample names are not very informative to us. Therefore we change them manually. See COMMANDO 8."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we quickly check the normalized expression levels for a few probes. See COMMANDO 9."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before we can go further with the workflow, two libraries need to be loaded. See COMMANDO 10."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now gene names are assigned to the probes. See COMMANDO 11."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To make our data table more informative, we add an extra (last) column with the gene symbols. See COMMANDO 12."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Some of the probes do not have a gene symbol assigned to them. Therefore we will remove them out of the dataset. See COMMANDO 13"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As one gene can have multiple probes, we will just take the median expression in further analysis. See COMMANDO 14."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A gene count table was made, using COMMANDO 15."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Because the column gene.symbols is 'just a column', we now want to link each gene symbol to a row. See COMMANDO 16."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An important step in this work flow, is to check the quality of the data. Therefore we make a MDS plot. See COMMANDO 17.\n",
    "The control samples (scrambled) are grouped together on the left side of the graph. The  TDP-43 samples on the other hand, are located on the right handside. -> So there is a lot of difference between the control and treated samples.\n",
    "-> Within the contol and treated samples, there is some difference. For example, scrambled_replicate 2 and 3 are quite different from the other two. -> This indicates some variance within the groups."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now check the expression levels of HDAC6 and we indeed see that the values are lower upon TDP-43 knockdown. See COMMANDO 18. In order to know if this difference in expression is significant, we will perform a differential expression analysis using Limma (cf. infra)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, we need to define the different experimental conditions. See COMMANDO 19."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We build a model matrix, because Limma uses a linear model in the background. See COMMANDO 20."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the differential expression analysis, a new library Limma is needed.\n",
    "Next, we make a MA plot to get a general overview of our differential expression analysis. The dots in the upper half (above the orange line) symbolise upregulated genes, those in the lower half downregulated genes. See COMMANDO 21."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As 8 different samples are used, we will correct for multiple testing. See COMMANDO 22."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We use the Benjamini Hochberg method with a cut off value of 0.05. -> the expression of 3515 genes is significantly different after TDP-43 knockdown."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we make a tsv-file from this differential expression analysis. See COMMANDO 23."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we assess the tsv-file in Excel, we see that HDAC6 has a log-fold-change of -0.25 and a adjusted p-value of 0.013. So according to the cut-offs we chose, HDAC6 is indeed significantly downregulated when TDP-43 is silenced. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Extra: When we run commando 23, the first few genes of the TopTable are shown. Here, we find TARDBP, which is the gene for TDP-43. This is a good control for the transfection that was performed: TDP-43 is indeed silenced (LogFC=-1.832799 ; p adj.=2.675694e-08)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## RNASeq Analysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- PubMed: https://www.ncbi.nlm.nih.gov/pubmed/?term=Distinct+and+shared+functions+of+ALS-associated+TDP-43%2C+FUS%2C+and+TAF15+revealed+by+comprehensive+multi-system+integrative+analyses\n",
    "- GeoData: https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE77702"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the article mentioned above, TDP-43 knockdown is performed in an identical way (RNA silencing). However, a more clinical relevant celltype is used, namely motor neurons generated from induced pluripotent stem cells from healthy humans. To check the effect on gene expression levels after TDP-43 silencing, RNASeq is perfomed.\n",
    "\n",
    "We redo the RNASeq analysis and see if HDAC6 is also significantly downregulated upon TDP-43 knockdown in this setting."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before we can start this analysis, we need to get RNAseq fastq data from the NCBI GEO/SRA db. (Commando given by prof.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mkdir -p ~/data/ncbi\n",
    "vdb-config -s /repository/user/main/public/root=~/data/ncbi\n",
    "mkdir -p ~/data/work && cd ~/data/work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 29905668 spots for SRR3153260\r\n",
      "Written 29905668 spots for SRR3153260\r\n",
      "Read 44386427 spots for SRR3153259\r\n",
      "Written 44386427 spots for SRR3153259\r\n",
      "Read 33675077 spots for SRR3153256\r\n",
      "Written 33675077 spots for SRR3153256\r\n",
      "Read 22513222 spots for SRR3153255\r\n",
      "Written 22513222 spots for SRR3153255\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump --split-files SRR3153260\n",
    "fastq-dump --split-files SRR3153259\n",
    "fastq-dump --split-files SRR3153256\n",
    "fastq-dump --split-files SRR3153255"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cd /mnt/storage/$USER/jupyternotebooks\n",
    "mv SRR3153260_1.fastq TDP-43_2.fastq\n",
    "mv SRR3153259_1.fastq TDP-43_1.fastq\n",
    "mv SRR3153256_1.fastq scr_2.fastq\n",
    "mv SRR3153255_1.fastq scr_1.fastq\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now move the fastq files to the appropriate directory."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mv: cannot stat ‘TDP-43_2.fastq’: No such file or directory\r\n",
      "mv: cannot stat ‘TDP-43_1.fastq’: No such file or directory\r\n",
      "mv: cannot stat ‘scr_2.fastq’: No such file or directory\r\n",
      "mv: cannot stat ‘scr_1.fastq’: No such file or directory\r\n",
      "total 44127588\r\n",
      "-rw-r--r-- 1 r0384602 domain users  7789707940 nov 16 12:12 scr_1.fastq\r\n",
      "-rw-r--r-- 1 r0384602 domain users 11662802940 nov 16 11:59 scr_2.fastq\r\n",
      "-rw-r--r-- 1 r0384602 domain users 15379403148 nov 16 11:56 TDP-43_1.fastq\r\n",
      "-rw-r--r-- 1 r0384602 domain users 10354709946 nov 16 11:53 TDP-43_2.fastq\r\n"
     ]
    }
   ],
   "source": [
    "mkdir -p /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "cd /mnt/storage/$USER/jupyternotebooks\n",
    "\n",
    "mv TDP-43_2.fastq /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "mv TDP-43_1.fastq /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "mv scr_2.fastq /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "mv scr_1.fastq /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "\n",
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "ls -l"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It's important to check the quality of the data. We do this via FastQC and then look at per base sequence quality and overrepresented sequences."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started analysis of TDP-43_2.fastq\r\n",
      "Approx 5% complete for TDP-43_2.fastq\r\n",
      "Approx 10% complete for TDP-43_2.fastq\r\n",
      "Approx 15% complete for TDP-43_2.fastq\r\n",
      "Approx 20% complete for TDP-43_2.fastq\r\n",
      "Approx 25% complete for TDP-43_2.fastq\r\n",
      "Approx 30% complete for TDP-43_2.fastq\r\n",
      "Approx 35% complete for TDP-43_2.fastq\r\n",
      "Approx 40% complete for TDP-43_2.fastq\r\n",
      "Approx 45% complete for TDP-43_2.fastq\r\n",
      "Approx 50% complete for TDP-43_2.fastq\r\n",
      "Approx 55% complete for TDP-43_2.fastq\r\n",
      "Approx 60% complete for TDP-43_2.fastq\r\n",
      "Approx 65% complete for TDP-43_2.fastq\r\n",
      "Approx 70% complete for TDP-43_2.fastq\r\n",
      "Approx 75% complete for TDP-43_2.fastq\r\n",
      "Approx 80% complete for TDP-43_2.fastq\r\n",
      "Approx 85% complete for TDP-43_2.fastq\r\n",
      "Approx 90% complete for TDP-43_2.fastq\r\n",
      "Approx 95% complete for TDP-43_2.fastq\r\n",
      "Analysis complete for TDP-43_2.fastq\r\n",
      "Started analysis of TDP-43_1.fastq\r\n",
      "Approx 5% complete for TDP-43_1.fastq\r\n",
      "Approx 10% complete for TDP-43_1.fastq\r\n",
      "Approx 15% complete for TDP-43_1.fastq\r\n",
      "Approx 20% complete for TDP-43_1.fastq\r\n",
      "Approx 25% complete for TDP-43_1.fastq\r\n",
      "Approx 30% complete for TDP-43_1.fastq\r\n",
      "Approx 35% complete for TDP-43_1.fastq\r\n",
      "Approx 40% complete for TDP-43_1.fastq\r\n",
      "Approx 45% complete for TDP-43_1.fastq\r\n",
      "Approx 50% complete for TDP-43_1.fastq\r\n",
      "Approx 55% complete for TDP-43_1.fastq\r\n",
      "Approx 60% complete for TDP-43_1.fastq\r\n",
      "Approx 65% complete for TDP-43_1.fastq\r\n",
      "Approx 70% complete for TDP-43_1.fastq\r\n",
      "Approx 75% complete for TDP-43_1.fastq\r\n",
      "Approx 80% complete for TDP-43_1.fastq\r\n",
      "Approx 85% complete for TDP-43_1.fastq\r\n",
      "Approx 90% complete for TDP-43_1.fastq\r\n",
      "Approx 95% complete for TDP-43_1.fastq\r\n",
      "Analysis complete for TDP-43_1.fastq\r\n",
      "Started analysis of scr_2.fastq\r\n",
      "Approx 5% complete for scr_2.fastq\r\n",
      "Approx 10% complete for scr_2.fastq\r\n",
      "Approx 15% complete for scr_2.fastq\r\n",
      "Approx 20% complete for scr_2.fastq\r\n",
      "Approx 25% complete for scr_2.fastq\r\n",
      "Approx 30% complete for scr_2.fastq\r\n",
      "Approx 35% complete for scr_2.fastq\r\n",
      "Approx 40% complete for scr_2.fastq\r\n",
      "Approx 45% complete for scr_2.fastq\r\n",
      "Approx 50% complete for scr_2.fastq\r\n",
      "Approx 55% complete for scr_2.fastq\r\n",
      "Approx 60% complete for scr_2.fastq\r\n",
      "Approx 65% complete for scr_2.fastq\r\n",
      "Approx 70% complete for scr_2.fastq\r\n",
      "Approx 75% complete for scr_2.fastq\r\n",
      "Approx 80% complete for scr_2.fastq\r\n",
      "Approx 85% complete for scr_2.fastq\r\n",
      "Approx 90% complete for scr_2.fastq\r\n",
      "Approx 95% complete for scr_2.fastq\r\n",
      "Analysis complete for scr_2.fastq\r\n",
      "Started analysis of scr_1.fastq\r\n",
      "Approx 5% complete for scr_1.fastq\r\n",
      "Approx 10% complete for scr_1.fastq\r\n",
      "Approx 15% complete for scr_1.fastq\r\n",
      "Approx 20% complete for scr_1.fastq\r\n",
      "Approx 25% complete for scr_1.fastq\r\n",
      "Approx 30% complete for scr_1.fastq\r\n",
      "Approx 35% complete for scr_1.fastq\r\n",
      "Approx 40% complete for scr_1.fastq\r\n",
      "Approx 45% complete for scr_1.fastq\r\n",
      "Approx 50% complete for scr_1.fastq\r\n",
      "Approx 55% complete for scr_1.fastq\r\n",
      "Approx 60% complete for scr_1.fastq\r\n",
      "Approx 65% complete for scr_1.fastq\r\n",
      "Approx 70% complete for scr_1.fastq\r\n",
      "Approx 75% complete for scr_1.fastq\r\n",
      "Approx 80% complete for scr_1.fastq\r\n",
      "Approx 85% complete for scr_1.fastq\r\n",
      "Approx 90% complete for scr_1.fastq\r\n",
      "Approx 95% complete for scr_1.fastq\r\n",
      "Analysis complete for scr_1.fastq\r\n"
     ]
    }
   ],
   "source": [
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "/usr/local/bin/FastQC/fastqc -o . TDP-43_2.fastq\n",
    "/usr/local/bin/FastQC/fastqc -o . TDP-43_1.fastq\n",
    "/usr/local/bin/FastQC/fastqc -o . scr_2.fastq\n",
    "/usr/local/bin/FastQC/fastqc -o . scr_1.fastq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This commando creates a html-file for every fastq file. When you open this, you get an elaborate rapport of the quality of the sample."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"50%\" src=\"/user/r0384602/files/groepswerk/RNAseq/Quality_control_fastq-files.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- per base sequence quality is good (see image)\n",
    "- There are 16 overrepresentative sequences in the scrambled samples and in the TDP-43 samples. \n",
    "So, there is some contamination of adaptors. However, we will continue the analysis without correcting for this."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now make SAM-files out of the fastq-files with the following commando. We sort and compress the data in these files, and thereby converting them into BAM-files."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nov 16 15:39:10 ..... started STAR run\r\n",
      "Nov 16 15:39:12 ..... loading genome\r\n",
      "Nov 16 15:39:12 ..... started mapping\r\n",
      "\r\n"
     ]
    }
   ],
   "source": [
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "STAR --genomeLoad LoadAndExit --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \n",
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn TDP-43_2.fastq \\\n",
    "     --outFileNamePrefix TDP-43_2.\n",
    "     \n",
    "STAR --genomeLoad LoadAndExit --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \n",
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn TDP-43_1.fastq \\\n",
    "     --outFileNamePrefix TDP-43_1.\n",
    "     \n",
    "STAR --genomeLoad LoadAndExit --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \n",
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn scr_2.fastq \\\n",
    "     --outFileNamePrefix scr_2.\n",
    "     \n",
    "STAR --genomeLoad LoadAndExit --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \n",
    "STAR --genomeDir /mnt/nfs/mfiers/STAR/hg19_star_db \\\n",
    "     --genomeLoad LoadAndKeep \\\n",
    "     --runThreadN 2 \\\n",
    "     --readFilesIn scr_1.fastq \\\n",
    "     --outFileNamePrefix scr_1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 3 files...\r\n",
      "[bam_sort_core] merging from 3 files...\r\n",
      "[bam_sort_core] merging from 11 files...\r\n",
      "[bam_sort_core] merging from 16 files...\r\n"
     ]
    }
   ],
   "source": [
    "cd /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "samtools sort -o TDP-43_1.bam TDP-43_1.Aligned.out.sam\n",
    "samtools sort -o TDP-43_2.bam TDP-43_2.Aligned.out.sam\n",
    "samtools sort -o scr_1.bam scr_1.Aligned.out.sam\n",
    "samtools sort -o scr_2.bam scr_2.Aligned.out.sam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "BAM-files are indexed, using samtools."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index TDP-43_1.bam\n",
    "samtools index TDP-43_2.bam\n",
    "samtools index scr_1.bam\n",
    "samtools index scr_2.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We check the bam- and bai-files in IGV. When we look at TARDBP, we can confirm that the knockdown of TARDBP was done succesfully, as the amount of reads mapped in the scrambled condition is much more than upon TDP-knockdown."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/Scr_IGV.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/TDP-43_IGV.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now want to know how many reads were mapped to the individual chromosomes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chrM\t16571\t14816\t0\r\n",
      "chr1\t249250621\t576343\t0\r\n",
      "chr2\t243199373\t418804\t0\r\n",
      "chr3\t198022430\t338965\t0\r\n",
      "chr4\t191154276\t221175\t0\r\n",
      "chr5\t180915260\t301436\t0\r\n",
      "chr6\t171115067\t326260\t0\r\n",
      "chr7\t159138663\t236543\t0\r\n",
      "chr8\t146364022\t200271\t0\r\n",
      "chr9\t141213431\t329797\t0\r\n",
      "chr10\t135534747\t198443\t0\r\n",
      "chr11\t135006516\t271560\t0\r\n",
      "chr12\t133851895\t295461\t0\r\n",
      "chr13\t115169878\t99903\t0\r\n",
      "chr14\t107349540\t645305\t0\r\n",
      "chr15\t102531392\t173606\t0\r\n",
      "chr16\t90354753\t155582\t0\r\n",
      "chr17\t81195210\t353707\t0\r\n",
      "chr18\t78077248\t85061\t0\r\n",
      "chr19\t59128983\t175095\t0\r\n",
      "chr20\t63025520\t105059\t0\r\n",
      "chr21\t48129895\t52614\t0\r\n",
      "chr22\t51304566\t94787\t0\r\n",
      "chrX\t155270560\t157245\t0\r\n",
      "chrY\t59373566\t21301\t0\r\n",
      "*\t0\t0\t0\r\n",
      "chrM\t16571\t18445\t0\r\n",
      "chr1\t249250621\t671438\t0\r\n",
      "chr2\t243199373\t478474\t0\r\n",
      "chr3\t198022430\t387927\t0\r\n",
      "chr4\t191154276\t248162\t0\r\n",
      "chr5\t180915260\t345362\t0\r\n",
      "chr6\t171115067\t382758\t0\r\n",
      "chr7\t159138663\t272313\t0\r\n",
      "chr8\t146364022\t228102\t0\r\n",
      "chr9\t141213431\t379236\t0\r\n",
      "chr10\t135534747\t219743\t0\r\n",
      "chr11\t135006516\t315091\t0\r\n",
      "chr12\t133851895\t342648\t0\r\n",
      "chr13\t115169878\t114592\t0\r\n",
      "chr14\t107349540\t756224\t0\r\n",
      "chr15\t102531392\t198196\t0\r\n",
      "chr16\t90354753\t173200\t0\r\n",
      "chr17\t81195210\t402814\t0\r\n",
      "chr18\t78077248\t94440\t0\r\n",
      "chr19\t59128983\t197413\t0\r\n",
      "chr20\t63025520\t118243\t0\r\n",
      "chr21\t48129895\t58743\t0\r\n",
      "chr22\t51304566\t107555\t0\r\n",
      "chrX\t155270560\t179957\t0\r\n",
      "chrY\t59373566\t21672\t0\r\n",
      "*\t0\t0\t0\r\n",
      "chrM\t16571\t53713\t0\r\n",
      "chr1\t249250621\t2537773\t0\r\n",
      "chr2\t243199373\t1811120\t0\r\n",
      "chr3\t198022430\t1581077\t0\r\n",
      "chr4\t191154276\t932087\t0\r\n",
      "chr5\t180915260\t1311461\t0\r\n",
      "chr6\t171115067\t1504294\t0\r\n",
      "chr7\t159138663\t994839\t0\r\n",
      "chr8\t146364022\t876665\t0\r\n",
      "chr9\t141213431\t1562970\t0\r\n",
      "chr10\t135534747\t825921\t0\r\n",
      "chr11\t135006516\t1190390\t0\r\n",
      "chr12\t133851895\t1322312\t0\r\n",
      "chr13\t115169878\t427545\t0\r\n",
      "chr14\t107349540\t3591786\t0\r\n",
      "chr15\t102531392\t723144\t0\r\n",
      "chr16\t90354753\t604307\t0\r\n",
      "chr17\t81195210\t1606659\t0\r\n",
      "chr18\t78077248\t357581\t0\r\n",
      "chr19\t59128983\t694321\t0\r\n",
      "chr20\t63025520\t428160\t0\r\n",
      "chr21\t48129895\t223475\t0\r\n",
      "chr22\t51304566\t393490\t0\r\n",
      "chrX\t155270560\t665557\t0\r\n",
      "chrY\t59373566\t64934\t0\r\n",
      "*\t0\t0\t0\r\n",
      "chrM\t16571\t87870\t0\r\n",
      "chr1\t249250621\t3913935\t0\r\n",
      "chr2\t243199373\t2655724\t0\r\n",
      "chr3\t198022430\t2341986\t0\r\n",
      "chr4\t191154276\t1376593\t0\r\n",
      "chr5\t180915260\t1928126\t0\r\n",
      "chr6\t171115067\t2166948\t0\r\n",
      "chr7\t159138663\t1477604\t0\r\n",
      "chr8\t146364022\t1290118\t0\r\n",
      "chr9\t141213431\t2278092\t0\r\n",
      "chr10\t135534747\t1229805\t0\r\n",
      "chr11\t135006516\t1763127\t0\r\n",
      "chr12\t133851895\t1953873\t0\r\n",
      "chr13\t115169878\t642010\t0\r\n",
      "chr14\t107349540\t5292658\t0\r\n",
      "chr15\t102531392\t1068140\t0\r\n",
      "chr16\t90354753\t914281\t0\r\n",
      "chr17\t81195210\t2549963\t0\r\n",
      "chr18\t78077248\t535990\t0\r\n",
      "chr19\t59128983\t1034169\t0\r\n",
      "chr20\t63025520\t644745\t0\r\n",
      "chr21\t48129895\t331705\t0\r\n",
      "chr22\t51304566\t580199\t0\r\n",
      "chrX\t155270560\t978206\t0\r\n",
      "chrY\t59373566\t103204\t0\r\n",
      "*\t0\t0\t0\r\n"
     ]
    }
   ],
   "source": [
    "samtools idxstats TDP-43_1.bam\n",
    "samtools idxstats TDP-43_2.bam\n",
    "samtools idxstats scr_1.bam\n",
    "samtools idxstats scr_2.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the 3rd column we see the number of reads mapped to each chromosome (high number). The 4th column, represents the amount that did not map (0). In our case, this means that all the reads are mapped."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, we make a symbolic link to the human annotation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lrwxrwxrwx 1 r0384602 domain users 56 nov 16 16:21 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 /mnt/storage/$USER/jupyternotebooks/groepswerk/RNAseq\n",
    "ls -l *gtf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using featureCounts, we create gene counts for each sample."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "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[32mS\u001b[36m scr_1.bam\u001b[0m \u001b[0m                                     ||\r\n",
      "||                           \u001b[32mS\u001b[36m scr_2.bam\u001b[0m \u001b[0m                                     ||\r\n",
      "||                           \u001b[32mS\u001b[36m TDP-43_1.bam\u001b[0m \u001b[0m                                  ||\r\n",
      "||                           \u001b[32mS\u001b[36m TDP-43_2.bam\u001b[0m \u001b[0m                                  ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "||             Output file : \u001b[36mall.counts\u001b[0m \u001b[0m                                      ||\r\n",
      "||             Annotations : \u001b[36mgencode.v19.nopseudo.plus.sort.gtf (GTF)\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 gencode.v19.nopseudo.plus.sort.gtf \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 scr_1.bam... \u001b[0m                                             ||\r\n",
      "||    Single-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m26285581\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m13367385 (50.9%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.55 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file scr_2.bam... \u001b[0m                                             ||\r\n",
      "||    Single-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m39139071\u001b[0m \u001b[0m                                                 ||\r\n",
      "||    Successfully assigned reads : \u001b[36m18839854 (48.1%)\u001b[0m \u001b[0m                         ||\r\n",
      "||    Running time : \u001b[36m0.78 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file TDP-43_1.bam... \u001b[0m                                          ||\r\n",
      "||    Single-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m5849139\u001b[0m \u001b[0m                                                  ||\r\n",
      "||    Successfully assigned reads : \u001b[36m2868258 (49.0%)\u001b[0m \u001b[0m                          ||\r\n",
      "||    Running time : \u001b[36m0.14 minutes\u001b[0m \u001b[0m                                            ||\r\n",
      "||  \u001b[0m                                                                          ||\r\n",
      "|| Process BAM file TDP-43_2.bam... \u001b[0m                                          ||\r\n",
      "||    Single-end reads are included. \u001b[0m                                         ||\r\n",
      "||    Assign reads to features... \u001b[0m                                            ||\r\n",
      "||    Total reads : \u001b[36m6712748\u001b[0m \u001b[0m                                                  ||\r\n",
      "||    Successfully assigned reads : \u001b[36m3327819 (49.6%)\u001b[0m \u001b[0m                          ||\r\n",
      "||    Running time : \u001b[36m0.14 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 -Q 10 -g gene_name -a gencode.v19.nopseudo.plus.sort.gtf -o all.counts scr_1.bam scr_2.bam TDP-43_1.bam TDP-43_2.bam"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When you open the all.counts file, you see that the file is made of several columns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# Program:featureCounts v1.5.0-p1; Command:\"featureCounts\" \"-Q\" \"10\" \"-g\" \"gene_name\" \"-a\" \"gencode.v19.nopseudo.plus.sort.gtf\" \"-o\" \"all.counts\" \"scr_1.bam\" \"scr_2.bam\" \"TDP-43_1.bam\" \"TDP-43_2.bam\" \r\n",
      "Geneid\tChr\tStart\tEnd\tStrand\tLength\tscr_1.bam\tscr_2.bam\tTDP-43_1.bam\tTDP-43_2.bam\r\n",
      "MIR1302-11\tchr1;chr1;chr1\t29554;30267;30976\t30039;30667;31109\t+;+;+\t1021\t0\t0\t0\t0\r\n",
      "FAM138A\tchr1;chr1;chr1\t34554;35245;35721\t35174;35481;36081\t-;-;-\t1219\t0\t0\t0\t0\r\n",
      "OR4F5\tchr1\t69091\t70008\t+\t918\t0\t0\t0\t0\r\n",
      "RP11-34P13.7\tchr1;chr1;chr1;chr1;chr1;chr1;chr1\t89295;92091;110953;112700;120721;129055;133374\t91629;92240;111357;112804;120932;129223;133566\t-;-;-;-;-;-;-\t3569\t2\t1\t0\t0\r\n",
      "RP11-34P13.8\tchr1;chr1\t89551;90287\t90050;91105\t-;-\t1319\t0\t0\t0\t0\r\n",
      "AL627309.1\tchr1;chr1\t134901;137621\t135802;139379\t-;-\t2661\t6\t6\t0\t2\r\n",
      "RP11-34P13.14\tchr1;chr1\t139790;140075\t139847;140339\t-;-\t323\t1\t0\t0\t0\r\n",
      "RP11-34P13.13\tchr1;chr1;chr1;chr1;chr1;chr1;chr1;chr1;chr1;chr1\t141474;146386;155767;164263;165884;168100;168610;169049;172557;173753\t143011;149707;155831;164791;165942;168165;168767;169264;172688;173862\t-;-;-;-;-;-;-;-;-;-\t6195\t10\t13\t1\t3\r\n"
     ]
    }
   ],
   "source": [
    "head all.counts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Column 1, 2, 3, 4, 5 and 6 only give information about the position in the genome (GeneID, chromosome, start, end, strand and length). Using the following commando, we separate these first 6 columns and paste them into a new file, called all.genedata.tsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cut -f-6 all.counts > all.genedata.tsv"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Column 7, 8, 9 and 10 only give information about the different samples. Using the following commando, we separate these 4 columns together with the first GeneID column into a new file, called all.gene.counts.tsv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "cut -f1,7- all.counts | grep -v '^#' > all.gene.counts.tsv"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the differential expression analysis of the data, we load the packages DESeq2 and scales. See COMMANDO 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we make sure that we are working in the right directory. See COMMANDO 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We define the file we just made containing the raw counts. See COMMANDO 3."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We rename the column to have a better overview of the table. See COMMANDO 4."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we say which different experimental conditions were used. See COMMANDO 5.\n",
    "We first assigned scrambled, then TDP-43 knockdown. This means that if we see a positive Log2FoldChange, the gene is upregulated upon TDP-43 knockdown and vice versa."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next we make a dataframe with the sample names and conditions. See COMMANDO 6. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A DESeq Object was created for using in the further analysis with the DESeq package. See COMMANDO 7."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We want to confirm that the order of the conditions has remained. See COMMANDO 8."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, the actual differential analysis was done using DESeq2. See COMMANDO 9."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As with all analysis, quality control needs to be done. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We check whether the scrambled replicates are similar to each other, and likewise for the TDP-43 replicates. Further, we check if the scambled replicates are more \"distant\" from the TDP-43 replicates. See COMMANDO 10.\n",
    "--> The diagonals are indeed what we expect. Great variability between the two conditions and small variability within the conditions."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is some noise visible in the diagonals for the low expressing genes. Using DESeq2, we can minimise this. See COMMANDO 11."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another way to look at the data and to understand the between-sample variation, is by making a PCA-plot. See COMMANDO 12.\n",
    "Again you can see a larger variability between the conditions than within."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To visualise the results of the differentional expression analysis, we create a MA plot. The significantly differentially expressed genes are coloured red. See COMMANDO 13. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We export these results. See COMMANDO 14."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we set the p-value at 0.05, we see that 1579 genes are differentially expressed. See COMMANDO 15."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we are interested in the expression levels of HDAC6. If we make a bar plot (see COMMANDO 16), we do not see a downregulation of HDAC6 after TDP-43 knockdown.\n",
    "\n",
    "If we look at the actual data (therefore we make a tsv-file, using COMMANDO 17), we see that HDAC6 is downregulated (Log2FoldChange=-0,036849), but not significantly (p-adjusted=0,9018339)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "<img width=\"50%\" src=\"/user/r0384602/files/groepswerk/RNAseq/RNASeq_HDAC6.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So in this clincally more relevant setting, we observe in our analysis that the downregulation of HDAC6 after TDP-43 silencing is not significant.\n",
    "\n",
    "We think the difference in results between the 2 articles can be present because the research is perfomed by two different labs using different techniques, different cells, different tools,...\n",
    "\n",
    "In addition, we did not control for adaptor contamination which may also influence the outcome of the analysis."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ranking based analysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we are interested in the function of the genes that are differentially expressed after TDP-43 knockdown."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For this analysis, we used the Deseq.results.tsv file and opened it in Excel. Here we ranked the data on decreasing Log2FoldChange. Then, we uploaded the ranked_up list in GOrilla with the following result (http://cbl-gorilla.cs.technion.ac.il/GOrilla/10n6crwt/GOResults.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/GOrilla_ranked_up_top.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the top of the table (which is ranked by increasing p-value), you see that the most significant cellular function of the upregulated genes after knockdown of TDP-43 is 'detection of chemical stimulus involved in sensory perception of smell'. \n",
    "Because loss of function of TDP-43 is associated with neurodegeneration, we hypothesized that mainly functions needed for normal neuronal functioning would come out of this anaysis. If we look further into the list we find for example neurological system process."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/GOrilla_ranked_up_filtered.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we ranked the data on increasing Log2FoldChange. Then, we uploaded the ranked_down list in GOrilla with the following result (http://cbl-gorilla.cs.technion.ac.il/GOrilla/bz704sar/GOResults.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/GOrilla_ranked_down_top.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the top of the table (which is ranked by increasing p-value), you see that the most significant cellular function of the downregulated genes after knockdown of TDP-43 is 'extracellular matrix organisation'. \n",
    "Again we hypothesized that mainly functions needed for normal neuronal functioning would come out of this anaysis. If we look further into the list we find for example neuron projection guidance."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"100%\" src=\"/user/r0384602/files/groepswerk/RNAseq/GOrilla_ranked_down_filtered.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CLiP-Seq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "The article (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4935974/) also investigates the ALS-associated protein TAF15. TAF15 is an RNA-binding protein just like TDP-43. They performed CLiP-seq on whole-brain tissue from adult mice to check which genes TAF15 binds. CLiP stands for \"cross-linking immunoprecipitation\" and is a technique to identify protein interactions with RNA. \n",
    "\n",
    "After applying a cluster-finding algorithm, the article identified TAF-binding clusters. We could find these clusters in a bed-file generated by the researches of the article (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM2056777)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "We download and rename this bed file to \"TAF15.bed\", copy it manually to our directory and take a look at it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "#TAF15_combined_data/TAF15_combined_notrim_s0_50-150_g20_corrected_premRNA_withrepeats_clusters\r\n",
      "track name=TAF15_combined_notrim_ingenes_clusters_mm9 description=TAF15_combined_notrim_ingenes_clusters_mm9 visibility=2 itemRgb=\"On\" useScore=1\r\n",
      "chr1\t3280460\t3280518\t1\t25\t-\t3280490\t3280499\t0,255,255\r\n",
      "chr1\t3290124\t3290173\t1\t41\t-\t3290130\t3290139\t0,255,255\r\n",
      "chr1\t3310940\t3311005\t1\t65\t-\t3310965\t3310974\t0,255,255\r\n",
      "chr1\t3344692\t3344741\t1\t28\t-\t3344719\t3344728\t0,255,255\r\n",
      "chr1\t3346065\t3346118\t1\t30\t-\t3346082\t3346091\t0,255,255\r\n",
      "chr1\t3350701\t3350757\t1\t50\t-\t3350731\t3350740\t0,255,255\r\n",
      "chr1\t3362888\t3362936\t1\t21\t-\t3362905\t3362914\t0,255,255\r\n",
      "chr1\t3367009\t3367061\t1\t24\t-\t3367032\t3367041\t0,255,255\r\n"
     ]
    }
   ],
   "source": [
    "mkdir -p /mnt/storage/$USER/jupyternotebooks/groepswerk/CLIPseq\n",
    "cd ~/data/jupyternotebooks/groepswerk/CLIPseq\n",
    "head TAF15.bed"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now upload this file in IGV and see to which genes TAF15 can bind in the brain tissue of mice. Therefore, we first have to make sure that in IGV the genome is changed to \"Mouse mm9\"."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we are curious if TAF15 binds the RNA of TDP-43, FUS and/or itself as these are all proteins involved in RNA metabolism and maybe regulate in that way each others expression. And indeed, if we look for these proteins in IGV we see overlap of the bed file, meaning TAF15 binds here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### TDP-43 (tardbp)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"80%\" src=\"/user/r0384602/files/groepswerk/CLIPseq/Taf15_binds_Tardbp.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Fus"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"80%\" src=\"/user/r0384602/files/groepswerk/CLIPseq/Taf15_binds_Fus.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Taf15"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img width=\"80%\" src=\"/user/r0384602/files/groepswerk/CLIPseq/Taf15_binds_Taf15.jpg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Discussion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "In the neurodegenerative disorders ALS and FTD, the nuclear protein TDP-43 is known to form cytoplasmic aggregates in the affected neurons which possibly contributes to neuronal death. In this report, we tried to get more insight in the role of TDP-43 in neurodegeneration by looking at the effect of TDP-43 silencing. We found two articles that performed TDP-43 knockdown using siRNA against TDP-43.\n",
    "\n",
    "The first article silenced TDP-43 in HEK293E cells and performed a micro-array analysis afterwards. By analysing the data, we could confirm TDP-43 knockdown and the finding that the cytoplasmic enzyme HDAC6 is significantly downregulated after TDP-43 knockdown. HDAC6 has a protective role as it primes misfolded proteins to degradation via autophagy. Hence, a possible mechanism involved in neurodegeneration could be proteotoxicity caused by HDAC6 deficiency.\n",
    "\n",
    "The second article performed TDP-43 silencing in a more clinical relevant setting as they used motor neurons generated from induced pluripotent stem cells from healthy humans instead of HEK293E cells. This group used RNA-sequencing and not micro-array to assess the differentially expressed genes upon TDP-43 knockdown. First, we could confirm the silencing of TDP-43, when we visualized the mapped reads from the test (TDP-43 knockdown) and control situation in IGV. Second, we were particularly interested in the expression levels of HDAC6 RNA after TDP-43 knockdown. However, we did not see a significant downregulation of HDAC6 after silencing TDP-43. There can be numerous of reasons for this difference in result between the two articles as a different cell type is used and the research is perfomed by two different labs using different techniques and different analyzing tools. Another contributing factor that can possibly influence the results, is the fact that we did not control for adaptor contamination.\n",
    "\n",
    "Next, we continued with the results of the second article for functional analysis. As loss of function of TDP-43 is associated with neurodegeneration, we hypothesized that after knockdown of TDP-43 in vitro, mostly the expression of genes important for normal neuronal functioning would be affected. Indeed, via a ranking-based analysis, we found 2352 (of 18359 genes in total) downregulated genes involved in neuron projection guidance and 346 (of 18313 genes in total) upregulated genes involved in neurological system processes after TDP-43 knockdown.\n",
    "\n",
    "Lastly, the second article also used the interesting technique CLiP-Seq to identify protein-RNA interactions. The article focused on the ALS-associated protein TAF15 which is an RNA-binding protein just like TDP-43. Here, we could confirm the interaction of TAF15 in brain tissue of mice with RNA of three important proteins involved in RNA-metabolism, namely TDP-43, FUS and TAF15 itself."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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
}
