When combining multiple GWAS results into a stacked manhattan plot using KaryoploteR, how do you label top SNPs in each set of GWAS results? Instructions provided for labelling a single manhattan plot did not work for the stacked manhattan.
When combining multiple GWAS results into a stacked manhattan plot using KaryoploteR, how do you label top SNPs in each set of GWAS results? Instructions provided for labelling a single manhattan plot did not work for the stacked manhattan.
Hi @jsreddy
You should be able to apply the snp labelling code to the stacked manhattan using almost the same code provided in the example. The key is to give the same autotrack you use for kpPlotManhattan
to the functions used for labeling (kpPoints
and kpText
, for example).
Does it make sense? You should replicate the labeling code as you replicate the call to kpPlotManhattan
and give all functions plotting in the same "track" the same autotrack
configuration.
If this is not clear yet, I can provide a small example. Just ask.
Hope this helps
Bernat
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Thank you @bernatgel for your response, your explanation was absolutely clear. I used the autotrack with kpText() to make sure labels are linked to the corresponding set of results. But I ended up generating a plot with all the labels at the top of the plot.
Code snippet/example can be extremely helpful. I can also send you my code/figure if that helps.
Thanks,
Joseph.
Ok, here's the code then. I've created a small example with two stacked manhattan plots for two traits (all simulated data) with a label on the top snp for each one. All code and images can be found also on github.
Create the simulated data
Create the simulated data with
regioneR::createRandomRegions
(available if you load karyoploteR) and a couple of random number generations. Select the two top snps and compute their y position.One Manhattan plot
Plot only Trait 1 and label the top snp.
And this is the result
Two stacked Manhattan plots
To stack the two manhattan plots we simply add
r0=autotrack(1,2)
to the code plotting the first trait andr0=autotrack(2,2)
to the code plotting the second track. I've also added a couple of labels for clarity.And the image with the two stacked Manhattan plots is this
Hope this helps :)
Bernat
Thank you, Bernat! Will give this a try. Appreciate your response!
Joseph.
Bernat,
Code worked like a charm. Thank you! I learned that you have to include ylim parameters every step of the way. I wasn't doing that before and it was going haywire.
I have a follow-up question, is there a way to just do kpPoints and kpText of the top SNP that reaches a certain p-value threshold in each chromosome? With your current code, if I have multiple SNPs in a CHR that meet the threshold, all those SNPs are being plotted and the text becomes hard to read since it overlaps. I only want to show the top hit per CHR. Is there a flag for this?
Thanks,
Joseph.
Sure, you can do this, but not with a flag.
The key here is the filtering to select the snps you want in
top1
ortop2
. In the code above there's a selection for the top SNP in the dataset. You should first select the top SNP in each chromosome (e.g. split the SNPs by chromosome, select the top one in each chromosome and finally discard any SNP below a certain value). And then use the code above to plot the labels.I'm developing a new package specifically designed for manhattan plots that will make annotation muuuch more simple, but it's not ready yet.
If you need more help with this, just ask.
Bernat