Convert .Txt Into Bed Files
2
3
Entering edit mode
13.3 years ago
Bioscientist ★ 1.7k

I used paired-end sequence data for copy number variation study; and eventually get .txt files as output. I'm hoping to use Bedtools to compare my results with others.

Can I convert .txt files into .bed files? (I don't see option in Bedtools)

If Bedtools is not working, what software can I use for data comparison?

my lines of txt is just like:

deletion    chr9:6169901-6173000    3100
deletion    chr9:7657401-7658800    1400
deletion    chr9:8847501-8848600    1100
deletion    chr9:10010201-10011600    1400
deletion    chr9:10126601-10127700    1100

thx

edit: I converted the txt files into bedpe format, which looks like

chr21    18542801    18543500
chr21    18545701    18545900
chr21    19039901    19040600
chr21    19164301    19169400
chr21    19366001    19370200
chr21    19639601    19640300
chr21    20493701    20495700
chr21    20581401    20583000
chr21    20880901    20882700
chr21    21558601    21559700

Then I started to compare two bedpe, looking for overlapping region, using the command like:

pairToPair -a 1.bedpe -b 2.bedpe > share.bedpe

Then I see the errors:

It looks as though you have less than 6 columns.  Are you sure your files are tab-delimited?

MY bed file have only three columns, seems it requires 6....What's the problem here? thx

comparison bedtools • 12k views
ADD COMMENT
0
Entering edit mode

Can you give a few sample lines from your .txt file?

ADD REPLY
8
Entering edit mode
13.3 years ago
Farhat ★ 2.9k

If you are on a unix or mac system the following command will convert to bed.

awk '{gsub(/[:-]/, "\t", $2); print $2}' infile.txt > outfile.bed
ADD COMMENT
0
Entering edit mode

thx, that works!

ADD REPLY
0
Entering edit mode

hi but i got another problem........can you have a look at my edit? thx

ADD REPLY
0
Entering edit mode

I guess pairToPair may be looking for strand information. You can add a dummy column to bring it to 6 since that information is not there in the txt file. awk '{gsub(/[:-]/, "\t", $2); print $2 "\t" $1 "\t0\t+" }' infile.txt > outfile.bed

ADD REPLY
1
Entering edit mode
13.3 years ago
Swbarnes2 ★ 1.6k

The .bed you made is not a paired end bed, which is what the pairToPair operation calls for.

Look in the manual; a paired end bed has the start and stop coordinates of a read 1 and a read 2. You don't have that, and it doesn't look appropriate for what you want to do anyway.

I think intersectBed is probably what you want to be running; to compare your observed CNVs with other CNVs. That'll take your plain bed format.

ADD COMMENT
0
Entering edit mode

thx! this makes more sense to me now!

ADD REPLY

Login before adding your answer.

Traffic: 2690 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