retrieving rows from a bed file
2
0
Entering edit mode
11 months ago
kimkes25 ▴ 30

Hello . my goal is to have this kind of bed file: Capture4

and be able to enter a chrom number and a range between chromeStart and chromeEnd, and to recieve all rows that match it. what is the best way to do it? Thanks

bed • 345 views
ADD COMMENT
2
Entering edit mode
11 months ago

Some clean-up work is needed. Export your file from Excel as a tab-delimited file. Clean it of Microsoft line endings and make a headerless, sorted file via sort-bed:

$ tr -d '\r' elements.tsv | sort-bed - > elements.bed

Then via bedops:

$ CHROM=chr1
$ START=12345
$ END=23456
$ bedops -e 100% elements.bed <(echo -e "${CHROM}\t${START}\t${END}") > answer.bed

The file answer.bed will contain all elements within the specified bounds, on the specified chromosome. Adjust CHROM, START, and END as needed.

Reference:

  1. https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html#element-of-e-element-of
  2. https://bedops.readthedocs.io/en/latest/content/reference/file-management/sorting/sort-bed.html
ADD COMMENT
4
Entering edit mode
11 months ago
awk -F '\t' '($1=="chr1" && !( $2>10000  ||  $3 <= 100))' input.bed

or use bedtools intersect

ADD COMMENT

Login before adding your answer.

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