Essentially, I have a dataset that I've created that looks like the following, where the headers are the wavelengths for each well in a 384-well plate.
> minipeaks
Wavel. X280 X282 X284 X286 X288 X290 X292 X294 X296
1 A1 34 62 57 52 48 89 104 134 142
2 A2 34 61 56 52 72 89 102 134 140
3 A3 68 62 84 105 119 134 185 227 266
4 A4 68 92 85 104 120 133 186 210 247
5 A5 103 123 141 182 191 222 269 361 424
6 A6 103 124 113 131 143 178 206 264 316
7 A7 136 153 141 156 192 244 285 364 404
8 A8 136 124 142 157 167 199 245 322 368
9 A9 170 155 171 208 215 244 327 418 478
10 A10 136 155 169 182 192 222 287 344 423
I'm having trouble creating a data.frame that I can plot. I'm guessing I need to take column 2:10 for each row, make a sequence of the wavelengths considered, and a repeat vector of the well name, and change this into a data.frame.
So far, I've tried running using plyr::ldply
, but haven't much success, because I keep getting the follow error:
> waves <- seq(from = 280, to = 850, by = 2)
> ldply(minipeaks, function(z) {
+ data.frame(wavelength = waves[1:(dim(z)[2]-1)],
+ well = rep(as.character(z$Wavel.), (dim(z)[2]-1)),
+ value = as.numeric(z[, 2:dim(z)[2]]))
+ })
Error in 1:(dim(z)[2] - 1) : argument of length 0
Called from: data.frame(wavelength = waves[1:(dim(z)[2] - 1)], well = rep(as.character(z$Wavel.),
(dim(z)[2] - 1)), value = as.numeric(z[, 2:dim(z)[2]]))
What might be the best way to resolve this problem? What am I totally missing?!