ggplot2 with scale_color_viridis for RNA-Seq data

Hi all,
Newbie here (R and Community). I am trying to make a plot similar to the image i have attached above. I have read in my csv file which looks like:

Pathway Enrichment score P-value
A 7 0.000890689
B 5 0.00153159
C 4 0.0135758
D 6 0.0202194
E 8 0.0243308
F 9 0.0321035
G 1 0.04837
H 2 0.0491552

I have tried using others scripts but because i have very limited R knowledge the best i can do is make a ggplot with the enrichment values only. Any help would be appreciated before i give up and just use excel without viridis.

Hi Niki, welcome to R and this community.

For future queries you might want to learn how to create a reprex (reproducible example) as these help people to help you, and you may also find that you discover the solution for yourself during the process.

This might help to get you started though:

library(tidyverse)
my <- read_csv("Pathway,Enrichment score,P-value
A,7,0.000890689
B,5,0.00153159
C,4,0.0135758
D,6,0.0202194
E,8,0.0243308
F,9,0.0321035
G,1,0.04837
H,2,0.0491552")

ggplot(my) + geom_bar(aes(x = Pathway,
                          y = `Enrichment score`,
                          fill =`P-value`), stat = 'identity') +
                     coord_flip() + scale_fill_viridis_c()

Ron.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.