This is a test version of Biostars. For the public version, visit https://www.biostars.org.
problem with bedtools complement: how to extract strand information?

Hi everyone,

I have a minor trouble when using bedtools complement. My gff3 file contains Chr start end strand etc. information. I want to use bedtools complement to extract other regions, however, the command bedtools complement -i gff_file -g genome_file gives me three columns: Chr, start, end. The output does not have strand information.

Thank you very much

bedtools

This tool would give you the regions of your genome_file which are not in your gff_file. What strand you expect from output?

2 answers

You can not get additional information about the complement regions of your interest regions. The main goal of executing bedtools complement command should be to get all off-target regions of your genome, not to "annotate" those regions.

Thanks a lot, Manu and airan, I understand the command only outputs region range information.

Taking the complement of both strands separately worked for me.

grep -v '+$' sorted_gff_file | bedtools complement -i stdin -g genome_file | sed 's/$/\t-/' > complement_file
grep '+$' sorted_gff_file | bedtools complement -i stdin -g genome_file | sed 's/$/\t+/' >> complement_file

You can sort the complement file after this.

Log in to answer this question.