<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# In-Class: Mouse ENCODE & Advanced bedtools"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part I: Mouse on the Genome Browser**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Like for humans, you can view mouse ENCODE data using the UCSC genome browser.\n",
    "Follow these steps to look at a gene in the browser, and then answer the following questions\n",
    "\n",
    "1) Go to the ENCODE website: https://genome.ucsc.edu/ENCODE/\n",
    "\n",
    "2) Under the 'Mouse Data at UCSC' header, click on 'Genome Browser(mm10)\n",
    "\n",
    "3) View the region chr15:35100000-35120000\n",
    "\n",
    "4) Scroll down to the  'Expression and Regulation' Section and change several of the ENCODE data tracks, including several of the RNA-seq ones, on. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. What evidence is there that this region is a gene? What evidence is there that it is not a gene? For hints on what to look for, look at the Enhancer paper from the pre-lab "
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) Now click the 'zoom-out 3x' button. Is there stronger evidence of a gene in this larger region? If so, what is it? Discuss at least 2 RNA-seq and 2 chip-seq data sets."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part II: Comparing marks across tissues and develpment**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You want to study how H3K9ac changes throughout development and tissue types.\n",
    "Find, download and unzip the following data sets (in bed narrowPeak format) from the mouse encode project (http://www.mouseencode.org/) using the 'data search' link on the homepage:\n",
    "\n",
    "ChIP-seq of heart (Mus musculus, adult 8 week), H3K9ac, Bing Ren,  UCSD: file ENCFF454UOO\n",
    "\n",
    "ChIP-seq of liver (Mus musculus, adult 8 week), H3K9ac, Bing Ren, UCSD: file ENCFF787EAZ"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1) Using the intersect function combined with the -v option in bedtools (http://bedtools.readthedocs.org/en/latest/content/bedtools-suite.html), how many regions are there that have evidence of  H3K9ac in heart and not liver? What about liver and not heart? Include the commands you used to generate your numbers."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, download the following dataset:\n",
    "\n",
    "ChIP-seq of heart (Mus musculus, postnatal 0 day mouse heart), H3K9ac, Bing Ren, UCSD: file ENCFF435ZTR"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) What commands would you use to check whether there are more changes in H3K9ac as the mouse develops or between different tissue types?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) Now run your commands. What is your result? Is this suprising to you?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part III: Finding Enhancers**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From reading the paper in the pre-lab, you know that H3K27ac is a mark of active enhancers. You have a list of genes that you think may be active in liver cells. This list is in liver_genes.bed. You now want to find which genes have active enhancers by seeing which ones are near H3K27ac marks. Download the dataset ENCFF545NYE (from Mouse liver, adult). Using unix commands and bedtools' intersect command in combination with the -u flag answer the following questions."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1) How many total genes are in the file liver_genes.bed? How many regions are in the dataset ENCFF545NYE?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "2) How many genes overlap at least one H3K27ac mark?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) However, you know that often H3K27ac occurs upstream of the active gene, so you don't just want to look for genes with H3K27ac marks in the actual gene, but also for genes with marks upstream of the gene. Use the window command in bedtools to increase the size of each genic region in livergenes.bed by 10,000 bases in both directions and perform an overlap analysis. Try running the command with and without the -u flag. What are the differences in the output bed files? How many genes overlap H3K27ac now? Save these genes to Ac_genes.bed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "4) However, you know that H3K27ac alone is not enough to declare that an enhancer is active. H3K4me3 is also associated with active enhancers. Download the dataset ENCFF420PUU from the Mouse Encode project. Use the window function to find how many genes (+10,000 basepairs in either direction) overlap both H3K4me3 and H3K27ac? Save this list of genes as MeAc_genes.bed. Try running the command with and without the -u flag. What are the differences in the output bed files?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Homework: Finding Active Regions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "You also know that H3K9ac is a sign of repressed chromatin. Download H3K9ac data from mouse (ENCFF997COQ), then with the intersect command and -v flag, count the number of genes from MeAc_genes.bed that do NOT also have a H3K9ac mark.  \n",
    "\n",
    "1) What is the bedtools command to do this? (3 points)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) How many genes from MeAc_genes.bed do not have a H3K9ac mark? (2 points)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) Are you convinced that these genes are truly active genes in embroynic mouse liver? Do you think that there may be some genes in liver_genes.txt that are expressed that we missed? Why or why not? What complexities are we overlooking? (5 points)\n",
    "\n",
    "*Hint: Think about issues such as where different marks should be located relative to the gene (from the Enhancer paper in the prelab), whether bedtool's window command was the ideal one to use, and cell type heterogeneity*."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  },
  "name": "Mouse ENCODE In-Class and Homework.ipynb"
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
<commit_msg>Issue #180 addressed - KG<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# In-Class: Mouse ENCODE & Advanced bedtools"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part I: Mouse on the Genome Browser**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Like for humans, you can view mouse ENCODE data using the UCSC genome browser.\n",
    "Follow these steps to look at a gene in the browser, and then answer the following questions\n",
    "\n",
    "1) Go to the ENCODE website: https://genome.ucsc.edu/ENCODE/\n",
    "\n",
    "2) Under the 'Mouse Data at UCSC' header, click on 'Genome Browser(mm9)\n",
    "\n",
    "3) View the region chr15:35100000-35120000\n",
    "\n",
    "4) Scroll down to the  'Expression and Regulation' Section and change several of the ENCODE data tracks, including several of the RNA-seq ones, on. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. What evidence is there that this region is a gene? What evidence is there that it is not a gene? For hints on what to look for, look at the Enhancer paper from the pre-lab "
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) Now click the 'zoom-out 3x' button. Is there stronger evidence of a gene in this larger region? If so, what is it? Discuss at least 2 RNA-seq and 2 chip-seq data sets."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part II: Comparing marks across tissues and develpment**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You want to study how H3K9ac changes throughout development and tissue types.\n",
    "Find, download and unzip the following data sets (in bed narrowPeak format) from the mouse encode project (http://www.mouseencode.org/) using the 'data search' link on the homepage (these datasets will be version mm10 - this is okay):\n",
    "\n",
    "ChIP-seq of heart (Mus musculus, adult 8 week), H3K9ac, Bing Ren,  UCSD: file ENCFF454UOO\n",
    "\n",
    "ChIP-seq of liver (Mus musculus, adult 8 week), H3K9ac, Bing Ren, UCSD: file ENCFF787EAZ"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1) Using the intersect function combined with the -v option in bedtools (http://bedtools.readthedocs.org/en/latest/content/bedtools-suite.html), how many regions are there that have evidence of  H3K9ac in heart and not liver? What about liver and not heart? Include the commands you used to generate your numbers."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, download the following dataset:\n",
    "\n",
    "ChIP-seq of heart (Mus musculus, postnatal 0 day mouse heart), H3K9ac, Bing Ren, UCSD: file ENCFF435ZTR"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) What commands would you use to check whether there are more changes in H3K9ac as the mouse develops or between different tissue types?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) Now run your commands. What is your result? Is this suprising to you?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Part III: Finding Enhancers**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From reading the paper in the pre-lab, you know that H3K27ac is a mark of active enhancers. You have a list of genes that you think may be active in liver cells. This list is in liver_genes.bed. You now want to find which genes have active enhancers by seeing which ones are near H3K27ac marks. Download the dataset ENCFF545NYE (from Mouse liver, adult). Using unix commands and bedtools' intersect command in combination with the -u flag answer the following questions."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1) How many total genes are in the file liver_genes.bed? How many regions are in the dataset ENCFF545NYE?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "2) How many genes overlap at least one H3K27ac mark?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) However, you know that often H3K27ac occurs upstream of the active gene, so you don't just want to look for genes with H3K27ac marks in the actual gene, but also for genes with marks upstream of the gene. Use the window command in bedtools to increase the size of each genic region in livergenes.bed by 10,000 bases in both directions and perform an overlap analysis. Try running the command with and without the -u flag. What are the differences in the output bed files? How many genes overlap H3K27ac now? Save these genes to Ac_genes.bed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "4) However, you know that H3K27ac alone is not enough to declare that an enhancer is active. H3K4me3 is also associated with active enhancers. Download the dataset ENCFF420PUU from the Mouse Encode project. Use the window function to find how many genes (+10,000 basepairs in either direction) overlap both H3K4me3 and H3K27ac? Save this list of genes as MeAc_genes.bed. Try running the command with and without the -u flag. What are the differences in the output bed files?"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Homework: Finding Active Regions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "You also know that H3K9ac is a sign of repressed chromatin. Download H3K9ac data from mouse (ENCFF997COQ), then with the intersect command and -v flag, count the number of genes from MeAc_genes.bed that do NOT also have a H3K9ac mark.  \n",
    "\n",
    "1) What is the bedtools command to do this? (3 points)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) How many genes from MeAc_genes.bed do not have a H3K9ac mark? (2 points)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) Are you convinced that these genes are truly active genes in embroynic mouse liver? Do you think that there may be some genes in liver_genes.txt that are expressed that we missed? Why or why not? What complexities are we overlooking? (5 points)\n",
    "\n",
    "*Hint: Think about issues such as where different marks should be located relative to the gene (from the Enhancer paper in the prelab), whether bedtool's window command was the ideal one to use, and cell type heterogeneity*."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  },
  "name": "Mouse ENCODE In-Class and Homework.ipynb"
 },
 "nbformat": 4,
 "nbformat_minor": 1
}

{'fraction_non_alphanumeric': 0.1408843200396334, 'fraction_numerical': 0.017091899925687392, 'mean_word_length': 3.0483830533968415, 'pattern_counts': {'":': 248, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2646635', 'n_tokens_mistral': 5558, 'n_tokens_neox': 5289, 'n_words': 1938}