Plot genes derived from time course experiment as line graph
1
0
Entering edit mode
9 weeks ago
camillab. ▴ 50

Hi!

I would like to plot the log2FC of 80 genes of a time course experiment (from 0 to 168hrs) as line plot. So originally my dataset has the genes in rows and the log2FC per time point in column but looking a way to do it I found this post so I transposed the dataset obtaining:

A tibble: 11 x 80
   timepoints MAPK10  PCSK2  PCSK5  APBA1 CACNA1D    MME ITPR3 LOC395985
        <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl>  <dbl> <dbl>     <dbl>
 1          0 -1.10  -2.91  -1.00  -0.980  -0.575 -0.573 0.849   1.27   
 2         24 -1.86  -4.76  -1.72  -1.60   -2.28  -0.749 0.332  -1.12   
 3         48 -1.49  -4.42  -1.67  -1.79   -2.39  -0.457 0.120  -0.658  
 4         54 -0.859 -3.54  -1.30  -1.64   -2.24  -0.128 0.559   0.726  
 5         60 -1.45  -3.90  -2.20  -1.94   -2.73   0.110 0.155   0.25

But when I try to follow the post (literally exactly the same code) I do not get any plot (not even the line plot for each gene). I checked if there were any NA and if the columns were character (df2 <- df %>% mutate_if(is.character,as.numeric) ) !

What am I doing wrong??

Thank you!

Camilla

line RNAseq ggplot R • 246 views
ADD COMMENT
1
Entering edit mode
6 weeks ago
gglim ▴ 110

Dont know if this plot is what you want:

library(tidyr)
library(dplyr)
library(ggplot2)
test.df <- data.frame(a=seq(1:10),
                      matrix(nrow = 10,ncol = 80,data = runif(800)))
names(test.df) <- c("timepoints",paste0(rep("gene",80),seq(1:80)))
test.df.long <- test.df %>% pivot_longer(all_of(paste0(rep("gene",80),seq(1:80))))
test.df.long %>% 
  ggplot(aes(x= timepoints,y=value,color=name)) + 
    geom_line(aes(group = name))

However, as Chirag said in that old post, for so many genes, its better to use heatmap.

library(pheatmap)
test.trans <- test.df %>% t()
colnames(test.trans) <- paste0("T",test.trans[1,])
test.trans <- test.trans[-1,]
pheatmap(test.trans,
         cluster_cols = FALSE,
         show_rownames = FALSE)

...and here is the plot

EDIT: The line plot is too big to show.

ADD COMMENT
0
Entering edit mode

heatmap

ADD REPLY

Login before adding your answer.

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