bedtools

bedtools

TLDR

Intersect two files with respect to the sequences' strand and save the result to {{path/to/output_file}}

>_ bedtools intersect -a [path/to/file_1] -b [path/to/file_2] -s > [path/to/output_file]
copy

Intersect two files with a left outer join, i.e. report each feature from {{file_1}} and NULL if no overlap with {{file_2}}

>_ bedtools intersect -a [path/to/file_1] -b [path/to/file_2] -lof > [path/to/output_file]
copy

Using more efficient algorithm to intersect two pre-sorted files

>_ bedtools intersect -a [path/to/file_1] -b [path/to/file_2] -sorted > [path/to/output_file]
copy

Group file {{path/to/file}} based on the first three and the fifth column and summarize the sixth column by summing it up

>_ bedtools groupby -i [path/to/file] -c 1-3,5 -g 6 -o sum
copy

Convert bam-formated file to a bed-formated one

>_ bedtools bamtobed -i [path/to/file].bam > [path/to/file].bed
copy

Find for all features in {{file_1}}.bed the closest one in {{file_2}}.bed and write their distance in an extra column (input files must be sorted)

>_ bedtools closest -a [path/to/file_1].bed -b [path/to/file_2].bed -d
copy

Copied to clipboard
free 100$ digital ocean credit