Hello,
I am trying to visualize a subset of my gene expression data with "ggplot2" as a lineplot. The x axis represents the subjects and the y axis represents the corresponding gene expression values. In my dataset, there are 4 genotype groups (ReA, ReWT, WTA and WTWT,) with 4 biological replicates. I would like to graph the subjects after each other ordered by genotype . Unfortunately, the order of the subject on the x axis is random. The d.f2 was ordered by "sample" but it did not make any difference. I also tried to incorporate the genotype info but it did not work.
In addition, I would like to change the line colour palette to make the plotted lines more distinguishable or plot each variable name next to the corresponding line to be discernible.
I am wondering if someone could advise me how to fix this.
Thank you in advance.
Anita
My code:
mat= t(exprs(eSet))
colnames(mat) = fData(eSet)$Symbol
rownames(mat) = pData(eSet)$Sample_ID
genotype= pData(eSet)$Genotype
"ReA" "ReWT" "ReA" "ReA" "WTA" "WTWT" etc
mat
Cacna1s Ncstn Psen2 Capn2 Grin1 Mme Aph1a
Re-A1 6.263089 9.363995 7.043813 8.958579 10.35145 6.737548 8.411508
Re-WT2 6.395183 9.268441 7.061662 8.774474 10.43331 6.849888 8.342589
Re-A3 6.158634 9.303803 6.992950 8.928849 10.24111 6.697132 8.382859
Re-A4 6.317536 9.221448 7.027650 8.898634 10.21116 6.946621 8.292705
WT-A6 6.410811 9.312704 7.100520 8.901446 10.35887 6.375570 8.363781
WT-WT7 6.315270 9.182447 6.935652 8.707210 10.26362 6.978126 8.198171
etc.
sample <- rownames(mat)
d.f <- data.frame(sample, mat)
d.f2 <- melt(d.f, id.vars = "sample")
sample variable value
1 Re-A1 Cacna1s 6.263089
2 Re-WT2 Cacna1s 6.395183
3 Re-A3 Cacna1s 6.158634
4 Re-A4 Cacna1s 6.317536
5 WT-A6 Cacna1s 6.410811
6 WT-WT7 Cacna1s 6.315270
|
ggplot(d.f2, aes(sample, value, group = variable, colour = variable)) + geom_line()
|
Thanks Jeremy.
Anita