YinLiLin / CMplot

📊 Circular and Rectangular Manhattan Plot
511 stars 112 forks source link

highlighting SNPs with multracks #15

Closed lgarvert closed 2 years ago

lgarvert commented 4 years ago

Hello YinLiLin,

Thank you very much for this function. I have two questions concerning the highlighting of SNPs.

1) Is it possible to add names to certain SNPs without changing their colour? Of course, I could manually write the chromosome colour to the highlight.col vector but is their a way to do this automatically without having to look up the chromosome colour of each SNP first?

2) I'd like to plot 3 traits with multracks in separate axes and label/highlight the lead SNPs of each trait, i.e. I need separate highlight vectors for each trait. Is that possible?

Thank you :)

YinLiLin commented 4 years ago

Hi,

Thank you for using CMplot. Sorry for the questions you proposed, CMplot can't achieve them now, but I will try to tweak the codes for your requirements, and I will feed back here if finished.

Best.

YinLiLin commented 4 years ago

Hi,

The functions of CMplot have been updated on Github. This functions are not available at CRAN, but I will submit it to CRAN soon if it works without problems. For question 1, please set 'highlight.col=NULL'. For question 2, please assign 'highlight', 'highlight.text' to be a list, then different traits could highlight different SNPs. If there are in vector, all traits would highlight the same SNPs.

Cheers Lilin

lgarvert commented 4 years ago

Hello Lilin,

thank you very much for updating your function so quickly. The labeling of different SNPs for each trait works perfectly in my examples. Thanks! I only encountered a small problem when using 'highlight.col=NULL". It worked fine for my first plot but for the second one it mixed up the colors of some of the SNPs (see picture).

Do you have any idea how to solve this? Thank you in advance.

Best, Linda

example_cmplot
YinLiLin commented 4 years ago

Hi Linda,

Sorry for that, it seems that cross-use of colour index for highlighted SNPs happened in CMplot, may you please share the code you used for this figure? I am not sure which type of plot would produce this problem.

regards, Lilin

lgarvert commented 4 years ago

Hi Lilin,

I'm sorry for my late reply. The above problem occured when I tried to plot a manhattan plot with three traits. The code I used looked like this:

CMplot(genes_complete[,c(1,2,3,6,8,10)],plot.type="m", multracks=TRUE, LOG10=TRUE,threshold=0.05, threshold.col = "red", threshold.lty = 1, threshold.lwd = 1, col=c("#3489DB", "#F39C12", "#9B59B6", "#2ECC71"), amplify=FALSE,width=14,cex.axis=2, cex=2, highlight.col=NULL, highlight=genes_test, highlight.text=genes_names_test, highlight.cex = 2, file="jpg",memo="genes_example",dpi=330, file.output=TRUE,verbose=TRUE)

The plot for the first trait looks fine but for the second and third traits the colors of the highlighted SNPs are mixed up. What I observed in my example is that the colors for traits 2 and 3 are assigned according to the order of the colors in trait one. For example if in trait one the highlighted SNPs 1, 8 and 9 have to be colored blue and the rest yellow, that works fine. But now for traits 2 and 3 it also colors the 1st, 8th and 9th SNP blue and the rest yellow, even though they are differend SNPs on differend chromosomes. I hope this explanation is understandable.

Best, Linda

YinLiLin commented 4 years ago

Hi Linda,

Thank you for pointing out the problem. This bug has been fixed, please source the online script and then try again. Please feel free to connect me if it doesn't work.

cheers, Lilin