Search
Duplicate
🚧

BED tricks

Sort intervals

chr order
Shell
복사

Merge intervals

Shell
복사

Intersect intervals

Shell
복사

Report intervals in A that have overlap with at least one interval in B

bedtools intersect -u -a [INPUT_A_BED] -b [INPUT_B_BED]
Shell
복사

Report intervals in A that do not overlap any intervals in B

Shell
복사

Compute jaccard index

Shell
복사

Extract genome sequence for given genomic regions as FASTA file

bedtools getfasta -fi [GENOME_FASTA] -bed [INPUT_BED]
Shell
복사

Only get intervals in A that overlaps with B (at least 1bp)

Shell
복사

Make random intervals of fixed lengths

bedtools random -g [GENOME_FASTA]
Shell
복사

Get x-bp flanking regions for each interval

bedtools flank -i [INPUT_BED] -g [GENOME_SIZE]
Shell
복사

Relative distance metrics

Output columns
reldist / count / total / fraction
If there is no spatial correlation between two interval sets, count and fraction values will show uniform distribution, otherwise show higher fraction in smaller reldist's.
bedtools reldist -a [INPUT_A_BED] -b [INPUT_B_BED]
Shell
복사

Annotate

Only get intervals in A that overlaps with B (at least 50% of A interval)

Shell
복사

Genomic context statistics

Shell
복사

Extend each interval for x-bp towards both direction

Shell
복사

Count overlapping bases

Shell
복사

Get midpoints for all intervals

!cat [INPUT_BED] | awk 'BEGIN {FS=OFS="\t"} {print $1, int(($2+$3)/2), int(($2+$3)/2+1)}' |\ bedtools sort -i stdin > [OUTPUT_BED]
Shell
복사

For each interval in A, assign the closest interval in B (also display the distance)

Shell
복사

For each interval in A.bed, get average signals from B.bedGraph

Shell
복사

For each genomic point in A.bed that has intersection with B.bed, compute relative position in the intersecting interval

Shell
복사

Only take conventional chromosomes

Shell
복사

See also