text: user16652: I have some .bed files (and .bim and .fam files) containing data for a number of different samples, and I need to convert them to .vcf.
  I've found bed2vcf which is from the bedr R package, and also available as a stand-alone python program of the same name, but it requires a .fasta file corresponding to the reference genome used to create the .bed file. So we need to know what genome reference build was used to get the right .fasta.
  Question Is there any tool or way to inspect the files I have and determine what genome reference build is required to do a correct conversion to .vcf, or is there any other method?
  There is a bed2vcf related post here.
  
  user10775: There are two different kinds of .bed files in bioinformatics; one related to storing genomic coordinate data and one which is part of the plink binary dataset, so it's important to check which kind of file you are actually converting. If you have .bed, .bim and .fam files, you could use PLINK 2.0 to export them as VCF:
  plink2 --bfile [prefix] --export vcf --out <prefix>
  
  The relevant options from the docs:
  <...>
  
    --bfile  <prefix> ['vzs'] : Specify .bed + .bim[.zst] + .fam prefix
  
  <...>
  
    --out <prefix>     : Specify prefix for output files.
  
  <...>
  
    --export <output format(s)...> [{01 | 12}] ['bgz'] ['id-delim='<char>]
             ['id-paste='<column set descriptor>] ['include-alt']
             ['omit-nonmale-y'] ['spaces'] ['vcf-dosage='<field>] ['ref-first']
             ['bits='<#>] ['sample-v2']
      Create a new fileset with all filters applied.  The following output
      formats are supported:
  
  ...
  
      * 'vcf',     : VCF (default version 4.3).  If PAR1 and PAR2 are present,
        'vcf-4.2',   they are automatically merged with chrX, with proper
        'bcf',       handling of chromosome codes and male ploidy.
        'bcf-4.2'    When the 'bgz' modifier is present, the VCF file is
                     block-gzipped.  (This always happens with BCF output.)
                     The 'id-paste' modifier controls which .psam columns are
                     used to construct sample IDs (choices are maybefid, fid,
                     iid, maybesid, and sid; default is maybefid,iid,maybesid),
                     while the 'id-delim' modifier sets the character between the
                     ID pieces (default '_').
  
  ...
  
  
original_text: 16652: <p>I have some .bed files (and .bim and .fam files) containing data for a number of different samples, and I need to convert them to .vcf.</p>
  <p>I've found <a href="https://www.rdocumentation.org/packages/bedr/versions/1.0.7/topics/bed2vcf" rel="nofollow noreferrer"><code>bed2vcf</code> which is from the <code>bedr</code> R package</a>, and also available as a stand-alone python program of the same name, but it requires a .fasta file corresponding to the reference genome used to create the .bed file. So we need to know what genome reference build was used to get the right <code>.fasta</code>.</p>
  <p><strong>Question</strong> Is there any tool or way to inspect the files I have and determine what genome reference build is required to do a correct conversion to .vcf, or is there any other method?</p>
  <p>There is a <code>bed2vcf</code> related post <a href="https://stackoverflow.com/questions/63306507/convert-bed-file-to-vcf-with-bed2vcf-function">here</a>.</p>
   10775: <p>There are two different kinds of <code>.bed</code> files in bioinformatics; one related to storing <a href="https://en.wikipedia.org/wiki/BED_(file_format)" rel="nofollow noreferrer">genomic coordinate data</a> and one which is part of the <a href="https://www.cog-genomics.org/plink/1.9/formats#bed" rel="nofollow noreferrer">plink binary dataset</a>, so it's important to check which kind of file you are actually converting. If you have <code>.bed</code>, <code>.bim</code> and <code>.fam</code> files, you could use <a href="https://www.cog-genomics.org/plink/2.0/" rel="nofollow noreferrer">PLINK 2.0</a> to export them as VCF:</p>
  <pre><code>plink2 --bfile [prefix] --export vcf --out &lt;prefix&gt;
  </code></pre>
  <p>The relevant options from the docs:</p>
  <pre><code>&lt;...&gt;
  
    --bfile  &lt;prefix&gt; ['vzs'] : Specify .bed + .bim[.zst] + .fam prefix
  
  &lt;...&gt;
  
    --out &lt;prefix&gt;     : Specify prefix for output files.
  
  &lt;...&gt;
  
    --export &lt;output format(s)...&gt; [{01 | 12}] ['bgz'] ['id-delim='&lt;char&gt;]
             ['id-paste='&lt;column set descriptor&gt;] ['include-alt']
             ['omit-nonmale-y'] ['spaces'] ['vcf-dosage='&lt;field&gt;] ['ref-first']
             ['bits='&lt;#&gt;] ['sample-v2']
      Create a new fileset with all filters applied.  The following output
      formats are supported:
  
  ...
  
      * 'vcf',     : VCF (default version 4.3).  If PAR1 and PAR2 are present,
        'vcf-4.2',   they are automatically merged with chrX, with proper
        'bcf',       handling of chromosome codes and male ploidy.
        'bcf-4.2'    When the 'bgz' modifier is present, the VCF file is
                     block-gzipped.  (This always happens with BCF output.)
                     The 'id-paste' modifier controls which .psam columns are
                     used to construct sample IDs (choices are maybefid, fid,
                     iid, maybesid, and sid; default is maybefid,iid,maybesid),
                     while the 'id-delim' modifier sets the character between the
                     ID pieces (default '_').
  
  ...
  </code></pre>
  