YinLiLin / CMplot

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

Incorrect behavior highlight.text.col #36

Closed YannLeGuen closed 3 years ago

YannLeGuen commented 4 years ago

Hi, It appears that the specifications for highlight.tex.col and highlight.col are incorrect.

highlight.text.col
a vector or list, the color for added text.

These actually cannot accept a list.

Error in text.default(lay[indd, 1] + 0.5 * lay[indd, 3], lay[indd, 2] +  : 
  invalid color specification
In addition: Warning messages:
1: In plot.xy(xy.coords(x, y), type = type, ...) :
  supplied color is neither numeric nor character
2: In plot.xy(xy.coords(x, y), type = type, ...) :
  supplied color is neither numeric nor character
3: In plot.xy(xy.coords(x, y), type = type, ...) :
  supplied color is neither numeric nor character
4: In plot.xy(xy.coords(x, y), type = type, ...) :
  supplied color is neither numeric nor character
5: In text.default(lay[indd, 1] + 0.5 * lay[indd, 3], lay[indd, 2] +  :
  supplied color is neither numeric nor character
6: In text.default(lay[indd, 1] + 0.5 * lay[indd, 3], lay[indd, 2] +  :
  supplied color is neither numeric nor character
7: In text.default(lay[indd, 1] + 0.5 * lay[indd, 3], lay[indd, 2] +  :
  supplied color is neither numeric nor character
8: In text.default(lay[indd, 1] + 0.5 * lay[indd, 3], lay[indd, 2] +  :

Thus, the color by dot can't be specified with multracks=T, only one vector of color can be specified and this is the same for all subplots. Could you please correct this issue or point me towards the part of your code to change?

YinLiLin commented 4 years ago

Thanks for the feedback. Could you please give a copy of the script you ran for this issue?

YannLeGuen commented 4 years ago

I think the behavior is easy to reproduce.

You can use any file with several traits then assign a color to each SNP depending on a condition. Let's say that you randomly assign one value among red, blue, green, orange to each SNP.

Then for each trait you want to color the SNP only when it pass suggestive level. You can write:

 colors <- list(
   dfb$GeneC[dfb[trait1]<1e-5],
   dfb$GeneC[dfb[trait2]<1e-5],
   dfb$GeneC[dfb[trait3]<1e-5],
   dfb$GeneC[dfb[trait4]<1e-5]
 )

Assuming you dfb dataframe as a column GeneC corresponding to the color of each SNP.

Then try to assign highlight.text.col = colors in CMplot and you will get the error above.