This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bedtools nuc : calculating the GC content in a sliding window

Hello everyone!

I found in an article that they used bedtools nuc to calculate : GC content within a 50-bp window, & GC content within a 1000-bp window.

When I try to read the manual of bedtools nuc I found this:

Usage:   bedtools nuc [OPTIONS] -fi <fasta> -bed <bed/gff/vcf>

Output format:

    The following information will be reported after each BED entry:
        1) %AT content
        2) %GC content

So I tried to run this command but I don't get the output that I want :

bedtools nuc -fi hg19.fasta -bed file.bed > output_bedtoolsnuc.tsv

#1_usercol      2_usercol       3_usercol       4_usercol       5_usercol       6_pct_at        7_pct_gc        8_num_A 9_num_C 10_num_G        11_num_T        12_num_N        13_num_oth      14_seq_len
1       133322   133323   ACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC/A        +       1.000000        0.000000        1       0       0
       0       0       0       1

How can I get gc_50 & gc_1000 by using bedtools nuc?

Thank you

gc bedtools

1 answer

The BED file you provide -bed must provide either 50 or 1000bp intervals. Use bedtools makewindows for that.

Okay thank youuu, I have another question, how can i construct the bed file ? I only have vcf file. I there a way to convert vcf file to bed ?

You mean the interval file? Just use bedtools makewindows, it will provide you with a BED file of bins of user-defined size for any genome. If you want to subset it for your variant file then use bedtools intersect to only retain windows that overlap your variants.

Log in to answer this question.