Is It Possible To Intersect A Csv File With A Bed File?
3
0
Entering edit mode
10.9 years ago
fmfshog • 0

Hello,

I have a csv file that contains my raw data. I am interested in 2 columns: start end positions. I am aiming to intersect these 2 columns from the file with another bed file that contains the regions i am interested of also start and end positions. can someone help?

• 6.0k views
ADD COMMENT
2
Entering edit mode
10.9 years ago
KCC ★ 4.1k

I would convert the file to a tab separated file. You can do that in excel for instance and probably some other types of office software. Make sure the columns are in the same order as a standard BED file (https://genome.ucsc.edu/FAQ/FAQformat.html).

Then do the intersection using something like bedtools or bedops.

ADD COMMENT
2
Entering edit mode
10.9 years ago

The BEDOPS bedops application has lots of set operations, including --intersect for calculating the intersection of two sorted BED files; here is a diagram of a selection of them:

bedops overview

The idea is that you convert the CSV file to UCSC BED (probably convert it to a tab-delimited file and use awk to print out specific columns in BED-field order), sort both BED files, then do bedops --intersect on the two sorted BED files.

Note that you might want the --element-of operator, instead of --intersect. See the figure above and the documentation for a more detailed explanation of the difference.

Feel free to check out the BEDOPS site and post any questions here or on our user forum. Hope this helps!

ADD COMMENT
0
Entering edit mode

thanks! that was very helpful:)

ADD REPLY
0
Entering edit mode
10.9 years ago

"csv" only means that commas are delimiters. No one will know what columns have what information in your csv. Unless your .csv is enormous, just throw it in Excel, and convert it to a .bed file. (Or use awk, or whatever)

ADD COMMENT

Login before adding your answer.

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