Genes time-series plots
1
0
Entering edit mode
19 months ago
Leite ★ 1.3k

Dear Biostars

I wonder if someone could give me some tips on how to build a graph similar to this in R:

enter image description here

My data has this format, different days, divided by severity and the genes (normalised z-score)

I tried ggplo2 + geom_line but no progress, nothing worked.

enter image description here

Best, Leite

time-series genes r plots Proteins • 727 views
ADD COMMENT
0
Entering edit mode
19 months ago
Trivas ★ 1.7k

You'll want to use the pivot_longer function so you have a column for day, a column for severity, a column for gene, and a column of values. Then in ggplot, your aes will be x = day, y = values, color = severity. You might also want to use facet_wrap(~ gene).

ADD COMMENT
0
Entering edit mode

Dear Trivas,

I try like you said, but it didn't work...

   Oxphos_proteins <- Oxphos_proteinas %>% pivot_longer(cols=c("COX6C", "COX7A2",   "COX7C"),
                names_to='Genes',
                values_to='z_score')

ggplot(Oxphos_proteins, aes(x = day, y = z_score)) +
  geom_line(aes(color = severity), size = 1, na.rm=TRUE)

enter image description here

ADD REPLY
0
Entering edit mode

It's because your day vector is not of type numeric.

ADD REPLY
0
Entering edit mode

Thanks Trivas!

I tried some changes, but it still doesn't look good. Any other tips?

enter image description here

ADD REPLY

Login before adding your answer.

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