Making a line graph to depict timecourse data

From this helpful thread in the bioconductor mailing list.

x <- 1:50  ## these would be your genes
 set.seed(1)
 y <- matrix(rnorm(1e4), nc=200) ## this would be your gene expr matrix
 col <- rgb(190, 190, 190, alpha=60, maxColorValue=255)
 matplot(x, y, type='l', col=col)

Just to see what it is doing, I made a simpler example

#variable with 2 rows
one <- 1:2
#matrix with 2 rows and 10 columns
two <- matrix(rnorm(20), nc=10)
two
#           [,1]        [,2]      [,3]        [,4]       [,5]      [,6]      [,7]
#[1,] -0.6822078 -0.25108283  2.425193 -0.05766436 -2.6879801 0.3658529 -1.987125
#[2,] -1.0733665 -0.01278288 -1.403296 -0.13803471 -0.5859938 0.4553595 -1.395202
#          [,8]      [,9]      [,10]
#[1,] -0.281798 1.8890190  1.0734526
#[2,] -1.498866 0.1831983 -0.4870297
#plots each column in the matrix two, along x
matplot(one,two,type='l')

Column 5 of the matrix "two" can most easily be seen as the dotted aqua line (from -2.6879801 to -0.5859938).

This plot could be useful if you wanted to depict the gene expression of 50 genes at 10 timepoints in a timecourse experiment (make a matrix of 10 rows by 50 columns).

Print Friendly, PDF & Email



Creative Commons License
This work is licensed under a Creative Commons
Attribution 4.0 International License
.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.