1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Dec 16, 2022 at 21:18
  • $\begingroup$ So it seems like you've (very reasonably) got confused between the two different types of bed file - one of them is used to store genomic coordinate data and then one is used as part of the plink data set. You want the latter, but I function you used is for the former. Annoying I know... $\endgroup$
    – user438383
    Dec 17, 2022 at 9:53

1 Answer 1

2
$\begingroup$

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 '_').

...
$\endgroup$
4
  • 1
    $\begingroup$ +1, but it's probably best to use plink2 for this, I think it's much quicker and can handle some different kind of variants I think. $\endgroup$
    – user438383
    Dec 17, 2022 at 9:57
  • 3
    $\begingroup$ Oh wow. I've never worked with PLINK so this is news to me. Why in the world would they call their format "bed"? That's just... $\endgroup$
    – terdon
    Dec 17, 2022 at 14:00
  • $\begingroup$ @user438383 Updated, thanks! $\endgroup$
    – Steve
    Dec 18, 2022 at 11:08
  • 1
    $\begingroup$ @terdon as an experienced bioinformatician this shouldn’t surprise you :) $\endgroup$
    – user438383
    Dec 18, 2022 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.