How to plot "Distribution of SNPs per Mbp"
2
2
Entering edit mode
2.9 years ago
Curls ▴ 40

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 • 1.9k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

please post example data.

ADD REPLY
5
Entering edit mode
2.9 years ago
tothepoint ▴ 800

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

ADD COMMENT
0
Entering edit mode

Thanks all.

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

ADD REPLY
1
Entering edit mode
2.9 years ago

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

ADD COMMENT

Login before adding your answer.

Traffic: 2889 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6