0

I am trying to convert .bed files to vcf by using the function bed2vcf from bedr R package.

I tried the following code:

  cromXvcf <- 
  bed2vcf("cromXmerged2_pruned_removed_sex_mr_hh_sex_pop.bed",
 filename = cromXmerged, zero.based = 1, header = NULL, fasta = "/media/iriel/Cosmos/Doctorado/Proyectos/Cromosoma X/Bases dedatos/human_g1k_v37.fasta")

and it throws the following error:

VALIDATE REGIONS * Checking input type... FAIL ERROR: Not sure what the input format is! Error in is.valid.region(x) :

Can anybody tell what could be wrong? Any other suggestion of how could I do this conversion without using Perl?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Iriel
  • 13
  • 4
  • What exactly does your `bed` file look like? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. You might also consider instead asking for general recommendations at [bioinformatics.se] instead. – MrFlick Aug 07 '20 at 20:15

1 Answers1

1

I solved it by loading bed file to variable and changing datatypes for column 1 and 4. Afterwards I also checked that my reference has chromosomes as chr1..22 not just 1...22. The other thing I checked that my bed file is sorted.

x <- read.table("cromXmerged2_pruned_removed_sex_mr_hh_sex_pop.bed")
x$V1 <- as.character(x$V1)
x$V4 <- as.character(x$V4)
sapply(x, mode)
y <- bed2vcf(x, zero.based=True, header=NULL, fasta="/media/iriel/Cosmos/Doctorado/Proyectos/Cromosoma X/Bases dedatos/human_g1k_v37.fasta")

And it worked fine for me.

Ekat Sim
  • 115
  • 6