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

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.

R • 340 views
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.

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

2
Entering edit mode
3 months ago
bkleiboeker ▴ 320

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)))