I have the assembly file of a certain lizard species, I wanted to recreate Fig. 2 of the following paper, which compares the GC content distribution over 5kb windows, how would I go about doing this?


enter image description here


1 Answer 1


I would suggest using bedtools makewindows and bedtools nuc to compute the GC content for genomic windows as shown in Fig 2 of the linked paper.

See related question here.

This will slice the genome into 5Kbp (or whatever size specified to makewindows) pieces and compute the GC content of each piece, which can be plotted as a distribution as in the figure.

Something like this would work for the 5000 bp example:

# assemble a bedtools compatible genome file:
# see https://www.biostars.org/p/70795/ for hints how to do this.
bedtools makewindows -w 5000 -g my_genome.genome > windows.bed # you just made this .genome file manually
bedtools nuc -bed windows.bed -fi my_genome.fasta > windows_gc.bed

The bed output file will contain the GC content of each window in the 7_pct_gc column (according to my understanding of the output file).

  • 1
    $\begingroup$ Please note that you do not have to make ".genome" file manually if you have samtools. You could simply generate an index file by running samtools faidx genome.fasta, and use the output file with extension .fasta.fai as input in your makewindwos command. $\endgroup$
    – Supertech
    Sep 16 at 13:34
  • 1
    $\begingroup$ tail -n +2 windows_gc.bed | cut -f 5 | awk '{printf("%d\n",$1*100)}' | sort | uniq -c | sed 's/^ *//'| sed 's/ /,/'>output.csv. This should print a CSV file which you can easily plot. $\endgroup$
    – Supertech
    Sep 16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.