<p>Based on the description in your question, I don't think this assumption is correct:</p>
<blockquote>
<p>I believe what they refer in this exercise is that the target file should be something like the whole chr sizes of hg19 hg19.chr.sizes [. . .]</p>
</blockquote>
<p>I understand that the question is asking you to simply produce a random selection of sub-regions from chromosome 7, all of which fall within the larger region 40000000-50000000. It can't be the list of chromosome sizes since, first of all, the question is asking you to get regions from chr17 only, and second because that just wouldn't make sense: only chr17 is relevant here, so the rest would be useless and, in any case, the length of the chromosome itself isn't helpful information.</p>
<p>The idea here is to demonstrate that given a set of genomic regions and a list of start and end coordinates of exons, you can calculate how many of your exons overlap the target regions. Therefore, the steps to follow would be:</p>
<ol>
<li>Generate random intervals in the 40000000-50000000 range.</li>
<li>Get the bed file for all human coding genes on hg19. You should indeed be able to download this from the UCSC genome browser, among other places.</li>
<li>Use a tool, <code>bedtools</code> or build your own using <code>awk</code>, or anything else that takes your fancy and for each gene found in the chr7:40000000-50000000 range, calculate how many bases of its exons fall within your randomly chosen selection of regions.</li>
</ol>
<p>Of course, the best thing to do would be to ask your teacher to clarify.</p>

CC BY-SA 4.0
2021-11-07T17:54:45.847Z
2021-11-07T17:54:45.847Z
terdon
<p>This sounds like homework - can you post what you have tried so far + a few lines of the input files + your code? Also, please add the &quot;homework&quot; tag if this is homework, or a task from a learning exercise.</p>
<p>Without giving it away think about the information in your <code>Refseq exon list file</code>. Is it a 3-field bed file with just coordinates, <a href="https://en.wikipedia.org/wiki/BED_(file_format)" rel="nofollow noreferrer">or is it the expanded file format with fields 4-12?</a> Do you really need to download the RefSeq annotation, or can you parse the information in your bed file to answer your question?</p>
<p>It sounds like this is your ultimate goal:</p>
<blockquote>
<p>For each gene, get the fraction of exonic bases that was covered by the target file.</p>
</blockquote>
<p>What information from the <a href="https://bedtools.readthedocs.io/en/latest/content/tools/coverage.html" rel="nofollow noreferrer">output of <code>bedtools coverage</code></a> will give you this answer? Does this information exactly match the spec you provided? Are there other tools in <code>bedtools</code> you could use to achieve the same thing?</p>
<p>Side note: It isn't 100% clear what you are asking and what your inputs are. I think the policy here isn't to outright answer homework questions without seeing evidence of some attempts. Someone can provide a better answer if you can update your question.</p>

CC BY-SA 4.0
2021-11-07T16:36:00.450Z
The problem is that I don't have the input files. The question implicitly hints on what should be downloaded from public resources but I don't know what to download in the first place =(. If I knew it then surely my attempt would be here.
moth
CC BY-SA 4.0
2021-11-07T18:05:02.073Z
Download the refseq human genome annotation in gff format. You can find that in the older versions here: https://www.ncbi.nlm.nih.gov/genome/?term=human . You can use this gff file to do all of the things that you mentioned above.
conchoecia
CC BY-SA 4.0
2021-11-07T15:49:43.830Z
2021-11-07T15:49:43.830Z
conchoecia
<p>I'm doing an exercise that asks for two files:</p>
<ul>
<li>Input 1: <code>A target file</code> (.bed format) contains multiple regions from
<code>chr7:40000000-50000000</code> of human reference genome GRCh37 (hg19)</li>
<li>Input 2: <code>Refseq exon list file</code> (.bed format) for all human coding genes
(hg19 position)</li>
</ul>
<p>The final goal is:</p>
<p>For all genes located in <code>chr7:40000000-50000000</code>, get the summary statistics of the target file coverage. (For each gene, get the fraction of exonic bases that was covered by the target file).</p>
<ul>
<li><p>I believe what they refer in this exercise is that the target file
should be something like the whole chr sizes of hg19 <code>hg19.chr.sizes</code> and <code>refseq_exon_list</code> the list of exons from reqseq database. Both can be
downloaded from tools like <a href="https://genome.ucsc.edu/cgi-bin/hgTables?hgsid=1207958047_1HLrWSX8jM6O6nujrnQsrG0p1Da8" rel="nofollow noreferrer">table browser</a> .Is that correct ?</p>
</li>
<li><p>I'm not sure which files I should download here to perform this task.
Once downloaded the file I believe what I need to do is to restrict
the <code>refseq_exon_list</code> by the requested region and then perform
coverage with something like <code>bedtools</code>. Something on those lines
<code>bedtools coverage -a hg19.chr.sizes -b reqseq_exon_list</code>.</p>
</li>
</ul>
<p>Am i right here ? Any input is appreciated, thanks.</p>

<bedtools><data-download><coverage><refseq>
Understanding exercise on file coverage with question on summary statistics
# Understanding exercise on file coverage with question on summary statistics

(Asked by: username_0 on 2021-11-07)

I'm doing an exercise that asks for two files:

* Input 1: `A target file` (.bed format) contains multiple regions from
  `chr7:40000000-50000000` of human reference genome GRCh37 (hg19)
* Input 2: `Refseq exon list file` (.bed format) for all human coding genes
  (hg19 position)

The final goal is:

For all genes located in `chr7:40000000-50000000`, get the summary statistics of the target file coverage. (For each gene, get the fraction of exonic bases that was covered by the target file).

* I believe what they refer in this exercise is that the target file
  should be something like the whole chr sizes of hg19 `hg19.chr.sizes` and `refseq_exon_list` the list of exons from reqseq database. Both can be
  downloaded from tools like [table browser](https://genome.ucsc.edu/cgi-bin/hgTables?hgsid=1207958047_1HLrWSX8jM6O6nujrnQsrG0p1Da8) .Is that correct ?
* I'm not sure which files I should download here to perform this task.
  Once downloaded the file I believe what I need to do is to restrict
  the `refseq_exon_list` by the requested region and then perform
  coverage with something like `bedtools`. Something on those lines
  `bedtools coverage -a hg19.chr.sizes -b reqseq_exon_list`.

Am i right here ? Any input is appreciated, thanks.

**Tags:** bedtools, data-download, coverage, refseq

---

## 2 answers

### Answer by username_1 on 2021-11-07. Score: 1

Based on the description in your question, I don't think this assumption is correct:

> I believe what they refer in this exercise is that the target file should be something like the whole chr sizes of hg19 hg19.chr.sizes [. . .]

I understand that the question is asking you to simply produce a random selection of sub-regions from chromosome 7, all of which fall within the larger region 40000000-50000000. It can't be the list of chromosome sizes since, first of all, the question is asking you to get regions from chr17 only, and second because that just wouldn't make sense: only chr17 is relevant here, so the rest would be useless and, in any case, the length of the chromosome itself isn't helpful information.

The idea here is to demonstrate that given a set of genomic regions and a list of start and end coordinates of exons, you can calculate how many of your exons overlap the target regions. Therefore, the steps to follow would be:

1. Generate random intervals in the 40000000-50000000 range.
2. Get the bed file for all human coding genes on hg19. You should indeed be able to download this from the UCSC genome browser, among other places.
3. Use a tool, `bedtools` or build your own using `awk`, or anything else that takes your fancy and for each gene found in the chr7:40000000-50000000 range, calculate how many bases of its exons fall within your randomly chosen selection of regions.

Of course, the best thing to do would be to ask your teacher to clarify.


---

### Answer by username_2 on 2021-11-07. Score: 0

This sounds like homework - can you post what you have tried so far + a few lines of the input files + your code? Also, please add the "homework" tag if this is homework, or a task from a learning exercise.

Without giving it away think about the information in your `Refseq exon list file`. Is it a 3-field bed file with just coordinates, [or is it the expanded file format with fields 4-12?](https://en.wikipedia.org/wiki/BED_(file_format)) Do you really need to download the RefSeq annotation, or can you parse the information in your bed file to answer your question?

It sounds like this is your ultimate goal:

> For each gene, get the fraction of exonic bases that was covered by the target file.

What information from the [output of `bedtools coverage`](https://bedtools.readthedocs.io/en/latest/content/tools/coverage.html) will give you this answer? Does this information exactly match the spec you provided? Are there other tools in `bedtools` you could use to achieve the same thing?

Side note: It isn't 100% clear what you are asking and what your inputs are. I think the policy here isn't to outright answer homework questions without seeing evidence of some attempts. Someone can provide a better answer if you can update your question.

> **Comments:**
> **username_0**: The problem is that I don't have the input files. The question implicitly hints on what should be downloaded from public resources but I don't know what to download in the first place =(. If I knew it then surely my attempt would be here.  
> **username_2**: Download the refseq human genome annotation in gff format. You can find that in the older versions here: https://www.ncbi.nlm.nih.gov/genome/?term=human . You can use this gff file to do all of the things that you mentioned above.  

---

