################################################## # Function for Mapping 24/48/96 to 384 Well Plates ################################################## # (1) 384 Plate P384 <- matrix(paste(rep(1,384), matrix(LETTERS[1:16],16,24, byrow=F), matrix(1:24,16,24, byrow=T), sep=""),16,24, dimnames = list(LETTERS[1:16], 1:24)) # (2) 384_4x96 Mapping Plate P96_1 <- matrix(paste(rep(1,96), matrix(LETTERS[1:8],8,12, byrow=F), matrix(1:12,8,12, byrow=T), sep=""),8,12, dimnames = list(LETTERS[1:8], 1:12)) P96_2 <- matrix(paste(rep(2,96), matrix(LETTERS[1:8],8,12, byrow=F), matrix(1:12,8,12, byrow=T), sep=""),8,12, dimnames = list(LETTERS[1:8], 1:12)) P96_3 <- matrix(paste(rep(3,96), matrix(LETTERS[1:8],8,12, byrow=F), matrix(1:12,8,12, byrow=T), sep=""),8,12, dimnames = list(LETTERS[1:8], 1:12)) P96_4 <- matrix(paste(rep(4,96), matrix(LETTERS[1:8],8,12, byrow=F), matrix(1:12,8,12, byrow=T), sep=""),8,12, dimnames = list(LETTERS[1:8], 1:12)) P192_1 <- matrix(rbind(P96_1, P96_2),8,24) P192_2 <- matrix(rbind(P96_3, P96_4),8,24) P384_96 <- matrix(t(cbind(P192_1, P192_2)),16,24, dimnames = list(LETTERS[1:16], 1:24), byrow=T) print("384 well plate") print(P384, quote=F) print("Map 4x 96 to 384") print(P384_96, quote=F) # (3) 384_8x48 Mapping Plate P48_1 <- matrix(paste(rep(1,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_2 <- matrix(paste(rep(2,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_3 <- matrix(paste(rep(3,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_4 <- matrix(paste(rep(4,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_5 <- matrix(paste(rep(5,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_6 <- matrix(paste(rep(6,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_7 <- matrix(paste(rep(7,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P48_8 <- matrix(paste(rep(8,96), matrix(LETTERS[1:8],8,6, byrow=F), matrix(1:6,8,6, byrow=T), sep=""),8,6, dimnames = list(LETTERS[1:8], 1:6)) P96_48_1 <- matrix(cbind(P48_1, P48_2),8,12) P96_48_2 <- matrix(cbind(P48_3, P48_4),8,12) P96_48_3 <- matrix(cbind(P48_5, P48_6),8,12) P96_48_4 <- matrix(cbind(P48_7, P48_8),8,12) P192_48_1 <- matrix(rbind(P96_48_1, P96_48_2),8,24) P192_48_2 <- matrix(rbind(P96_48_3, P96_48_4),8,24) P384_48 <- matrix(t(cbind(P192_48_1, P192_48_2)),16,24, dimnames = list(LETTERS[1:16], 1:24), byrow=T) print("Map 8x 48 to 384") print(P384_48, quote=F) # (4) 384_16x24 Mapping Plate for(i in 1:16) { assign(paste("P24_",i, sep=""), matrix(paste(rep(i,24), matrix(LETTERS[1:4],4,6, byrow=F), matrix(1:6,4,6, byrow=T), sep=""),4,6, dimnames = list(LETTERS[1:4], 1:6))) } for(i in seq(1, 16, by=2)) { assign(paste("P48_", which(seq(1, 16, by=2)==i), sep=""), matrix(rbind(eval(parse(text=paste("P24_", i, sep=""))), eval(parse(text=paste("P24_", i+1, sep="")))),4,12)) } for(i in seq(1, 8, by=2)) { assign(paste("P96_24_", which(seq(1, 8, by=2)==i), sep=""), matrix(t(cbind(eval(parse(text=paste("P48_", i, sep=""))), eval(parse(text=paste("P48_", i+1, sep=""))))),8,12, dimnames = list(LETTERS[1:8], 1:12), byrow=T)) } print("Map 4x 24 to 96") print(P96_24_1, quote=F) P192_24_1 <- matrix(rbind(P96_24_1, P96_24_2),8,24) P192_24_2 <- matrix(rbind(P96_24_3, P96_24_4),8,24) P384_24 <- matrix(t(cbind(P192_24_1, P192_24_2)),16,24, dimnames = list(LETTERS[1:16], 1:24), byrow=T) print("Map 16x 24 to 384 (not printed)") # (5) Conversion table df384_96_48_24 <- data.frame(P384=as.vector(P384), P96=as.vector(P384_96), P48=as.vector(P384_48), P24=as.vector(P384_24)) df384_96_48_24 <- data.frame( P384=sub('([A-Z])', '_\\1', as.character(df384_96_48_24[,1]), perl = TRUE), P96=sub('([A-Z])', '_\\1', as.character(df384_96_48_24[,2]), perl = TRUE), P48=sub('([A-Z])', '_\\1', as.character(df384_96_48_24[,3]), perl = TRUE), P24=sub('([A-Z])', '_\\1', as.character(df384_96_48_24[,4]), perl = TRUE)) df384_96_48_24 <- data.frame( # insert zeros to allow proper sorting P384=gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df384_96_48_24[,1]), perl=T), P96=gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df384_96_48_24[,2]), perl=T), P48=gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df384_96_48_24[,3]), perl=T), P24=gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df384_96_48_24[,4]), perl=T)) df384_96_48_24 <- df384_96_48_24[order(df384_96_48_24\$P96),] print("Beginning of conversion table") print(df384_96_48_24[1:8,]) # (6) Clean things up rm(list=ls(pattern='P192*|P96*|P48*|P24*')) # (7) Generate mapping table for as many plates as you need df384_96_48_24 <- data.frame( Pl384=gsub("_.*", "",as.character(df384_96_48_24[,1]), perl=T), Loc384=gsub(".*_", "",as.character(df384_96_48_24[,1]), perl=T), Pl96=gsub("_.*", "",as.character(df384_96_48_24[,2]), perl=T), Loc96=gsub(".*_", "",as.character(df384_96_48_24[,2]), perl=T), Pl48=gsub("_.*", "",as.character(df384_96_48_24[,3]), perl=T), Loc48=gsub(".*_", "",as.character(df384_96_48_24[,3]), perl=T), Pl24=gsub("_.*", "",as.character(df384_96_48_24[,4]), perl=T), Loc24=gsub(".*_", "",as.character(df384_96_48_24[,4]), perl=T)) many_df384_96_48_24 <- df384_96_48_24 many_df384_96_48_24[,c(1,3,5,7)] <- apply(many_df384_96_48_24[,c(1,3,5,7)], 2, as.numeric) temp_df <- many_df384_96_48_24 plate_mapping_fct <- function(no_384_plates=32) { if(no_384_plates > 1) { for(i in 1:(no_384_plates-1)) { temp_df <- data.frame( Pl384=as.numeric(as.vector(temp_df[,1]))+1, Loc384=temp_df[,2], Pl96=as.numeric(as.vector(temp_df[,3]))+4, Loc96=temp_df[,4], Pl48=as.numeric(as.vector(temp_df[,5]))+8, Loc48=temp_df[,6], Pl24=as.numeric(as.vector(temp_df[,7]))+16, Loc24=temp_df[,8]) many_df384_96_48_24 <- rbind(many_df384_96_48_24, temp_df) } } row.names(many_df384_96_48_24) <- 1:length(many_df384_96_48_24[,1]) many_df384_96_48_24 } my_plate_mappings <- plate_mapping_fct(no_384_plates=32) print("To generate mapping table for as many plates as you need, run plate mapping function like this (here 32 plates):") print("plate_mapping_fct(no_384_plates=32)") print("The example 'my_plate_mappings' contains the mappings for 32 384-well plates.") print("my_plate_mappings[1:8,]") print(my_plate_mappings[1:8,], quote=F) # (8) Save mappings to files # write.table(P384_96, file="P384_96.txt", row.names=T, col.names=NA, quote=F, sep="\t") # write.table(P384_48, file="P384_48.txt", row.names=T, col.names=NA, quote=F, sep="\t") # write.table(df384_96_48_24, file="df384_96_48_24.txt", row.names=T, col.names=NA, quote=F, sep="\t") # write.table(my_plate_mappings, file="my_plate_mappings.txt", row.names=T, col.names=NA, quote=F, sep="\t")