How Do I Convert An Illumina Export File To Bed?
1
2
Entering edit mode
14.2 years ago
Andrew ▴ 20

I have some illumina data generated from the latest version of the illumina pipeline (1.6.0) I need to convert my data into BED to view in ucsc genome browser.

This seems like it should be a fairly common task, however, I am unable to find any scripts to convert my data.

bed • 5.0k views
ADD COMMENT
0
Entering edit mode

We can probably find/write you perl or python scripts that do this, what are you comfortable running?

ADD REPLY
3
Entering edit mode
14.2 years ago
Biostar User ★ 1.0k

I found a script on another site, Uses perl but I have not checked for correctness:

#!/usr/bin/perl

use strict;
use warnings;
use IO::File;

my $filename = shift @ARGV;
die "Usage\n\tperl sorted2bed.pl s_X_sorted.txt > s_X_sorted.bed\n" unless $filename;
chomp $filename;

my $fh = new IO::File;
$fh->open("< $filename") or die "Can't open file $filename for reading: $!";

my $count = 1;
while(my $line = <$fh>){
   warn "Line $count\n" if $count%1000 == 0;
   $count++;
   my @line = split "\t", $line;
   my $chr = $line[10];
   $chr =~ s/(.+)\.fa/$1/;
   #Illumina is 1-based, BED is 0-based
   my $start = $line[12]-1;
   my $read = $line[8];
   my $end = $start + length $read;
   my $strand = $line[13] eq 'F' ? '+': '-';
   my $score = $line[15];
   my $bedline = "$chr\t$start\t$end\t$read\t$score\t$strand\n";
   print $bedline;
}
$fh->close;

warn "Done";
ADD COMMENT
0
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 2609 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6