kaustubhad / fastman

An R package for fast and efficient visualizing of GWAS results using Q-Q and Manhattan plots directly from PLINK output files.
GNU General Public License v3.0
36 stars 8 forks source link

Add vertical lines to Manhattan plot #2

Closed LTibbs closed 2 years ago

LTibbs commented 2 years ago

First, thank you for developing this package. I have GWAS data with > 20 million markers and could not plot it with qqman.

I would like to add vertical lines to my Manhattan plot to indicate specific sites on the genome. This is possible in the qqman package, as discussed in https://github.com/stephenturner/qqman/issues/23. However, when I use abline() after fastman(), no line is drawn on the plot.

How can I add vertical lines to a Manhattan plot in fastman?

Thank you.

soumyasubhraparia commented 2 years ago

Hello. Thank you for using our package.

You can add vertical lines to your Manhattan plot using abline() after fastman(). Here is an example code which worked at my end.

png('test.png', width = 10, height = 6, units = 'in', res = 300); fastman(m)+abline(v=7); dev.off();

Please let me know if this works for you.

soumyasubhraparia commented 2 years ago

In fact the following code also worked for me.

png('test.png', width = 10, height = 6, units = 'in', res = 300); fastman(m); abline(v=7); dev.off();

Please let me know if either of these two works for you.

LTibbs commented 2 years ago

Thank you for your reply. Yes, I was able to get add a vertical line with your code. I think the problem was that I was using, for example, abline(v=50), assuming that this line would be placed at base 50 of chromosome 1, as is the case in qqman. However, this does not seem to be the case in fastman and so abline(v=50) was beyond the limits of the figure. Instead, abline(v=7) places a vertical line towards the end of chromosome 6 in my case.

Could you please explain the conversion between the coordinates used in fastman and in abline()? For example, if I wanted to put a vertical line at base 100 on chromosome 10, what value of v would I use in abline()?

kaustubhad commented 2 years ago

Hi, sorry for the delay in getting back to you. Are you looking to do such annotations only when displaying a single chromosome? If so, you need to pass the abline value in Mb units, not BP. If you look at the X axis label for such plots, it displays the unit Mb. So, for example, the command below produces a vertical line at location 25 Mb. png(file="tmp2.png",width=10, height=6, units="in", res=300); fastman(tmp2); abline(v=25); dev.off();

Do you want this functionality in multi-chromosome i.e. typical manhattan plots as well? That would be difficult to accomplish I think, because the locations are appended one after another for subsequent chromosomes.

tmp2

LTibbs commented 2 years ago

OK, thanks for letting me know that the line units need to be given in Mb rather than bp units. That answers my question.