<p>You can convert to VCF and use <a href="http://bedops.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">BEDOPS</a> <code>vcf2bed --insertions</code>, <code>vcf2bed --deletions</code> and <code>vcf2bed --snvs</code> to segregate the VCF into three subsets.</p>

<p>For convenience, BEDOPS conversion tools deal with index shifts, <a href="http://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion/vcf2bed.html" rel="nofollow noreferrer">including <code>vcf2bed</code></a>. The resulting BED file is 0-indexed, half-open.</p>

CC BY-SA 3.0
2017-10-20T01:29:13.310Z
Thanks @Alex Reynolds.  Is there any way to do this but without segregating the VCF into subsets?
Sarah
CC BY-SA 4.0
2024-03-28T23:28:57.080Z
Coming back year later I can say genomic coordinate systems can be tricker than I ever imagined years ago when I wrote this question, especially when converting between different formats lol. Here is a good article explaining 1 based vs 0 based positions. https://www.biostars.org/p/84686/ . VCF format is generally 1 based and BED format is generally 0 based. But also some programs use 1-ish or 0-ish indexing so it gets confusing (looking at you VarSeq ;) )
Sarah
CC BY-SA 3.0
2017-10-06T22:02:32.183Z
2017-10-06T22:02:32.183Z
Alex Reynolds
<p>Starting with a chromosome # and position, I am trying to get chromStart and chromEnd values for a .bed file, but I am not sure how to calculate chromEnd when I have a variant that is an insertion or deletion.  </p>

<p>My file is not a VCF file but it gives the chromosome number, chromosomal position (pos), reference (ref) allele, and alternate (alt) allele for each genetic variant, like you would find in a VCF file.  The tricky part is that not all of my variants are single nucleotide base changes--I also have insertions and deletions that can be multiple bases long.</p>

<p>For SNPs I am setting chromStart = pos - 1, and chromEnd = start + 1 = pos.  (Note, .bed format requires 0-based indexing and the end position is exclusive. See <a href="https://genome.ucsc.edu/FAQ/FAQformat.html" rel="nofollow noreferrer">https://genome.ucsc.edu/FAQ/FAQformat.html</a>) </p>

<p>I am unsure of how to handle indels though (insertions and deletions).  Currently I am adding the length of the reference allele to the starting position to get the end position (chromEnd = start + len(ref)).  I am not sure if this is right though. </p>

<p>I will be using this .bed file with a .bed file from Gencode and bedtools. Does anyone know the standard way the research community (or at least Gencode) treats indels when determining chromosomal position for .bed files? Thanks!</p>

CC BY-SA 3.0
2017-10-04T06:53:10.623Z
Usually people don't convert such things to BED files. `bedtools` understands VCF format, so why not convert to that, since it seems most of the information is already there?
Devon Ryan
CC BY-SA 3.0
2017-10-04T07:24:53.720Z
Could you explain why you are trying to make this into a bed file? Is it for displaying it in a genome browser? I don't really see how a bed file could even show an indel, unless it were by using the coordinates of the reference genome.
terdon
CC BY-SA 3.0
2017-10-04T17:54:11.237Z
Hi, @terdon I am trying to make this into a BED file so that I can find which variants overlap exonic areas in the genome. I have a BED file from Gencode listing protein coding regions, and I want to know which of my variants overlap with the exome.
Sarah
CC BY-SA 3.0
2017-10-04T17:55:03.437Z
Hi @Devon Ryan, if the best thing to do would be to convert it to VCF format, will the bedtools intersect command be able to compare a VCF file with a BED file, or would I need to convert the Genecode BED to VCF?
Sarah
CC BY-SA 3.0
2017-10-05T06:57:23.290Z
bedtools is able to compare BED and VCF files, you don't need to convert anything at that point.
Devon Ryan
CC BY-SA 3.0
2017-10-06T15:30:04.113Z
The best way to determine which variants affect exomes is to run through an annotation tool like the VEP (http://www.ensembl.org/info/docs/tools/vep/index.html) for which you need a VCF.
Emily_Ensembl
<human-genome><bed><bedtools><gencode>
Dealing with indels when converting a position to chromStart and chromEnd for a bed file
# Dealing with indels when converting a position to chromStart and chromEnd for a bed file

(Asked by: username_0 on 2017-10-04)

Starting with a chromosome # and position, I am trying to get chromStart and chromEnd values for a .bed file, but I am not sure how to calculate chromEnd when I have a variant that is an insertion or deletion.

My file is not a VCF file but it gives the chromosome number, chromosomal position (pos), reference (ref) allele, and alternate (alt) allele for each genetic variant, like you would find in a VCF file. The tricky part is that not all of my variants are single nucleotide base changes--I also have insertions and deletions that can be multiple bases long.

For SNPs I am setting chromStart = pos - 1, and chromEnd = start + 1 = pos. (Note, .bed format requires 0-based indexing and the end position is exclusive. See <https://genome.ucsc.edu/FAQ/FAQformat.html>)

I am unsure of how to handle indels though (insertions and deletions). Currently I am adding the length of the reference allele to the starting position to get the end position (chromEnd = start + len(ref)). I am not sure if this is right though.

I will be using this .bed file with a .bed file from Gencode and bedtools. Does anyone know the standard way the research community (or at least Gencode) treats indels when determining chromosomal position for .bed files? Thanks!

**Tags:** human-genome, bed, bedtools, gencode
> **Comments:**
> **username_1**: Usually people don't convert such things to BED files. `bedtools` understands VCF format, so why not convert to that, since it seems most of the information is already there?  
> **username_2**: Could you explain why you are trying to make this into a bed file? Is it for displaying it in a genome browser? I don't really see how a bed file could even show an indel, unless it were by using the coordinates of the reference genome.  
> **username_0**: Hi, @terdon I am trying to make this into a BED file so that I can find which variants overlap exonic areas in the genome. I have a BED file from Gencode listing protein coding regions, and I want to know which of my variants overlap with the exome.  
> **username_0**: Hi @Devon Ryan, if the best thing to do would be to convert it to VCF format, will the bedtools intersect command be able to compare a VCF file with a BED file, or would I need to convert the Genecode BED to VCF?  
> **username_1**: bedtools is able to compare BED and VCF files, you don't need to convert anything at that point.  
> **username_3**: The best way to determine which variants affect exomes is to run through an annotation tool like the VEP (http://www.ensembl.org/info/docs/tools/vep/index.html) for which you need a VCF.  

---

## 1 answers

### Answer by username_4 on 2017-10-06. Score: 1

You can convert to VCF and use [BEDOPS](http://bedops.readthedocs.io/en/latest/index.html) `vcf2bed --insertions`, `vcf2bed --deletions` and `vcf2bed --snvs` to segregate the VCF into three subsets.

For convenience, BEDOPS conversion tools deal with index shifts, [including `vcf2bed`](http://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion/vcf2bed.html). The resulting BED file is 0-indexed, half-open.

> **Comments:**
> **username_0**: Thanks @Alex Reynolds.  Is there any way to do this but without segregating the VCF into subsets?  
> **username_0**: Coming back year later I can say genomic coordinate systems can be tricker than I ever imagined years ago when I wrote this question, especially when converting between different formats lol. Here is a good article explaining 1 based vs 0 based positions. https://www.biostars.org/p/84686/ . VCF format is generally 1 based and BED format is generally 0 based. But also some programs use 1-ish or 0-ish indexing so it gets confusing (looking at you VarSeq ;) )  

---

