I have a matrix of 8 rows and 12 columns, and randomly distributed 10 different treatments with 9 replicates and a final treatment only with 6 replicates in the matrix. The code might be redundant, but it was the first think that came to mind and worked. I just wanted to have a scheme so that I could follow easily afterwards in the lab, to avoid mistakes:
library(ggplot2)
library(RColorBrewer)
library(reshape2)
library(scales)
replicates<-c(rep(seq(1:11),c(rep(9,10),6)));replicates
dimna<-list(c("A","B","C","D","E","F","G","H"),seq(1,12,1))
plate<-array(sample(replicates),dim=c(8,12),dimnames=dimna);plate
platec<-melt(plate);platec
guide<-ggplot(platec,aes(Var2,Var1,fill=factor(value))) + geom_tile()+geom_text(aes(fill=factor(value),label=value)) + ylim(rev(levels(platec$Var1))) + theme_bw() + theme(panel.grid.major.y=element_blank(),panel.grid.minor.y=element_blank(),panel.grid.major.x=element_blank(), axis.text.x=element_text(size=10), axis.title.y=element_blank(), axis.text.y=element_text(size=12)) + scale_fill_brewer(name="",palette="Spectral") + scale_x_continuous("",labels=c(seq(1,12,1)),breaks=c(seq(1,12,1)));guide
However, now imagine that I take measurements for the randomized matrix multiple times. And for the data processing I need to identify the treatment and replicates in the matrix. I can either have the data at the end in a columnwise:
A1 A2 A3 A4 A5 A6 A7 A8
0.12 0.2 0.124 0.14 0.4 0.18 0.46 0.47
0.13 0.21 0.6 0 0 0.58 0.4 0.2
0.15 0.248 0.58 0.4 0.2 0.248 0.2 0.18
0.18 0.46 0.47 0.3 0.21 0.2 0.21 0.58
0.1784 0.14 0.95 0.7 0.248 0.21 0.248 0.248
.
.
.
Or rowwise fashion:
A1 0.12 0.13 0.15 0.18 0.1784
A2 0.2 0.21 0.248 0.46 0.14
A3 0.124 0.6 0.58 0.47 0.95
A4 0.14 0 0.4 0.3 0.7
A5 0.4 0 0.2 0.21 0.248
A6 0.18 0.58 0.248 0.2 0.21
A7 0.46 0.4 0.2 0.21 0.248
A8 0.47 0.2 0.18 0.58 0.248
...
Is there a way in R in which I can relate the random matrix to the data I have collected, I have no clue on how to begin even. I'm really sorry for not having an attempt even, but I honestly wouldn't know on how to start