help with ggplot
1
0
Entering edit mode
21 months ago
shallot • 0

So here's the snip of the ORA result provided to me and I want to plot dotplot using ggplot.

snip

ggplot(data = test12,
  aes(x = Condition, y = GO, size = FoldChange)
  ) + 
  geom_point(aes(color = 'P-value')) + 
  scale_color_gradient(low = "blue", high = "red")

It's giving me error: Discrete value supplied to continuous scale

Any idea what I might be doing wrong. Any help is appreciated!

ggplot • 1.2k views
ADD COMMENT
1
Entering edit mode

What is the output to:

class(test12$GO)
class(test12$Condition)
unique(test12$Condition)

But before that, why are you trying to set color using a continuous value? Shouldn't you bin the p-value then set a color based on, say, if the pvalue < 0.05 or >=0.05?

ADD REPLY
0
Entering edit mode

oh hey, they are as follow:

 - class(test12$GO) = character
 - class(test12$Condition) = character
 - unique(test12$Condition) = "+" "-"

I am so sorry but I am not sure what you mean by continuous value and bin the p-value, also, results are taken from DAVID I guess so only p-value of <0.05 are exported

ADD REPLY
3
Entering edit mode
21 months ago
Ram 44k

It could be that your p-value is of character class. Check that. Your code works fine in my example:

dat12 <- data.frame(
  GO=LETTERS[1:6],
  Condition = c("+","-","+","-","+","-"),
  FoldChange = sample(1:10,6),
  pvalue = c(4.2E-02, 2.05E-02, 1.89E-03, 1.44E-02, 1.78E-06,7.04E-03)
)

dat12
  GO Condition FoldChange   pvalue
1  A         +          8 4.20e-02
2  B         -         10 2.05e-02
3  C         +          6 1.89e-03
4  D         -          4 1.44e-02
5  E         +          3 1.78e-06
6  F         -          2 7.04e-03

ggplot(dat12,
  aes(x = Condition, y = GO, size = FoldChange)) + 
  geom_point(aes(color=pvalue)) + 
  scale_color_gradient(low = "blue", high = "red")

plot

ADD COMMENT
0
Entering edit mode

Oh heya, So I copy pasted necessary things in a new excel, loaded it and checked the class of pvalue (it's numeric) and still getting the same error of supplying discrete value to continuous scale :(

ADD REPLY
0
Entering edit mode

I have no clue how, but I tried using your code, and it somehow worked!!! Thanks a lot. I tried it with another datasheet too and it is working, I Can't thank you enough

ADD REPLY
1
Entering edit mode

It should be fun trying to figure out why your initial code/dataset did not work. I've moved my comment to an answer - please accept it to resolve the post.

ADD REPLY
0
Entering edit mode

I am definitely trying that!! And done! Thanks again!!

ADD REPLY

Login before adding your answer.

Traffic: 1664 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6