How to make line graph with circles in R
1
0
Entering edit mode
11 months ago
cthangav ▴ 80

Hello,

I saw these figures in a paper and wanted to make a similar graphs. Is there a function to do this kind of line graph in R that you would recommend?

I have a list of genes and would need to run go term enrichment on them, then obtain some p-values so that they can be represented as circle size on the graph.

Your input is appreciated, thank you.

Graphs

R • 781 views
ADD COMMENT
2
Entering edit mode

Speaking generically since you didn't provide example data, you would minimally start off with a 3 column data frame df with columns fold_change, pval, and what I assume is day.

Your call to ggplot would then look something like.

ggplot(df, aes(x=day, y=fold_change)) +
  geom_line() +
  geom_point(aes(size=-log10(pval)))

Adding additional lines and such would require dataset specific modifications to the input data or ggplot call, but I won't cover those since example data and desired output wasn't provided.

ADD REPLY
2
Entering edit mode

I explained in this 👉 post. Please refer.

Apparently, you can also use this online tool -> https://cparsania.shinyapps.io/FungiExpresZ/ to generate such plot with few clicks

ADD REPLY
2
Entering edit mode
11 months ago
bkleiboeker ▴ 370

Sure, you can just call both geom_point() and geom_line(). If you want to make them look exactly like the authors, I'd probably pass group into the main aes() call and "size = -log10(p-value)" into the aes() call just for geom_point()

Edit: I agree with rpolicastro, but I just realized you should also add color to the main aes() also. Copying his example, now with a fourth column called tissue:

ggplot(data, aes(x=day, y=fold_change, color = tissue)) +
  geom_line() +
  geom_point(aes(size=-log10(pval)))
ADD COMMENT

Login before adding your answer.

Traffic: 1927 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