0

I am trying to show gene enrichment with modules on the y-axis, enrichment score on the x-axis, number of genes in the dataset based on point size, and p-value based on color. I haven't been able to get the gradient color scale to represent the full range of p-values. I've tried to look for existing sample code to adjust the limits of the gradient scale, but still haven't been able to get it to represent what I'm hoping for. Can anyone please help? Thanks very much in advance.

Here is the basic code (I've tried several iterations on the gradient scale, but no luck):

ggplot(test, aes(x=combined, y=order, colour=p.adjust, size=count)) + 
  geom_point() + 
  scale_colour_gradient(low="red", high="blue") + 
  theme_bw()

And a table of sample data:

count     p.adjust  combined  order
    15  4.81E-09        67         1
    92  6.83E-15        57         2
    88  1.15E-15        54         3
    79  1.07E-09        54         4
    89  8.95E-13        44         5
    81  1.58E-10        41         6
    61  1.75E-09        40         7
    61  1.75E-09        40         8
   117  1.57E-13        38         9
    85  3.99E-11        37        10
   162  7.81E-18        37        11
    86  1.69E-11        36        12
    51  2.17E-08        36        13
    53  2.68E-09        36        14
    53  2.68E-09        35        15
    53  2.83E-08        33        16
    83  2.24E-10        32        17
    50  6.43E-08        32        18
    81  1.24E-09        29        19
    51  5.87E-06        29        20
    80  2.47E-09        28        21
    15  7.87E-05        27        22
    55  1.31E-06        26        23
    78  1.12E-08        25        24
Axeman
  • 32,068
  • 8
  • 81
  • 94
Jeff
  • 1
  • What do you mean by "the full range of p-values"? – bouncyball Apr 26 '17 at 16:09
  • Hi, thank you for replying. I've only been able to generate a plot that shows a gradient scale centered around adjusted p-values (p.adjust) around E-05 (e.g., it goes from 2E-05 to 6E-05, or something like that). So all of the dots on the plot look essentially the same color. But some of the p-values are "even more significant" than others (e.g., 7.81E-18), and I'd like that one to clearly be a different color than the one that is 7.87E-05. I hope that makes sense. Thanks again. – Jeff Apr 26 '17 at 16:41
  • You might want to try transforming the `p.value` column, perhaps using a `logit` transformation: `scale_colour_gradient(low="red", high="blue", trans = scales::logit_trans())` – bouncyball Apr 26 '17 at 16:45
  • You may use `scale_color_gradientn` to and its `values` argument to rescale your values, as described e.g. [here](http://stackoverflow.com/questions/21758175/is-it-possible-to-define-the-mid-range-in-scale-fill-gradient2/21758729#21758729) and [here](http://stackoverflow.com/questions/20581746/small-value-variation-invisible-using-scale-colour-gradient2/20584038#20584038). – Henrik Apr 26 '17 at 16:51
  • Bouncyball and Henrik, thank you for the great suggestions! – Jeff Apr 26 '17 at 16:55
  • `-log10(p.adjust)` is a commonly used transformation for p-values to make them easier to visualize. – bdemarest Apr 26 '17 at 20:03

0 Answers0