This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to plot "Distribution of SNPs per Mbp"

Hi,

I am trying to get the similar plot below for my data. I have VCF file from GBS analysis. How can I draw this plot from VCF file. Thanks.

enter image description here

plot

Do you have a preferred language? What analysis environments are you familiar with?

please post example data.

2 answers

A similar plot can be generated with CMplot if you have data in such format.

Thanks all.

devarora Your suggestion worked well. Finally I obtained my plot. Thank you so much!

Here's a way to get a text file containing counts of variants per 1Mb bin across hg38 (replace with your assembly of choice):

$ fetchChromSizes hg38 \
    | awk -vOFS="\t" '{ print $1, "0", $2; } \
    | grep -vE '*_*' \
    | sort-bed - \
    | bedops --chop 1000000 - \
    | bedmap --echo --count --delim '\t' - <(vcf2bed < variants.vcf) \
    > answer.txt

Once you have answer.txt, you can bring that into R to make a density plot with ggplot2.

I have an example Rscript from a previous question, which demonstrates use of geom_tile for making an ideogram-like figure similar to what is in your question:

Plotting SNP density heatmap chromosome ideogram

Log in to answer this question.