############################################### # Function for Mapping 384 and 1536 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) 1536 to 384 mapping P1536 <- matrix(paste(rep("1_",1536), matrix("R",32,48), matrix(1:32,32,48, byrow=F), matrix("_C",32,48), matrix(1:48,32,48, byrow=T), sep=""),32,48, dimnames = list(paste("R", 1:32, sep=""), paste("C", 1:48, sep=""))) P384_1 <- 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)) P384_2 <- matrix(paste(rep(2,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)) P384_3 <- matrix(paste(rep(3,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)) P384_4 <- matrix(paste(rep(4,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)) P768_1 <- matrix(rbind(P384_1, P384_2),16,48) P768_2 <- matrix(rbind(P384_3, P384_4),16,48) P1536_384 <- matrix(t(cbind(P768_1, P768_2)),32,48, dimnames = list(paste("R", 1:32, sep=""), paste("C", 1:48, sep="")), byrow=T) df1536_384 <- data.frame(P1536=as.vector(P1536), P384=as.vector(P1536_384)) df1536_384 <- data.frame(P1536=df1536_384[,1], P384=sub('([A-Z])', '_\\1', as.character(df1536_384[,2]), perl = TRUE)) print("1536 well plate") print(P1536, quote=F) print("Map 4x 384 to 1536") print(P1536_384, quote=F) # insert zeros to allow proper sorting df1536_384[,1] <- gsub("(_\\w)(\\d_)", "\\10\\2",as.character(df1536_384[,1]), perl=T) df1536_384[,1] <- gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df1536_384[,1]), perl=T) df1536_384[,2] <- gsub("(_\\w)(\\d\$)", "\\10\\2",as.character(df1536_384[,2]), perl=T) df1536_384 <- df1536_384[order(df1536_384\$P384),] print("Beginning of conversion table") print(df1536_384[1:8,]) # Generate mapping table for as many plates as you need df1536_384 <- data.frame( Pl1536=gsub("_.*", "",as.character(df1536_384[,1]), perl=T), Loc1536=gsub("^\\d{1,}_", "",as.character(df1536_384[,1]), perl=T), Pl384=gsub("_.*", "",as.character(df1536_384[,2]), perl=T), Loc384=gsub(".*_", "",as.character(df1536_384[,2]), perl=T)) many_df1536_384 <- df1536_384 many_df1536_384[,c(1,3)] <- apply(many_df1536_384[,c(1,3)], 2, as.numeric) temp_df <- many_df1536_384 plate_mapping_fct2 <- function(no_1536_plates=4) { if(no_1536_plates > 1) { for(i in 1:(no_1536_plates-1)) { temp_df <- data.frame( Pl1536=as.numeric(as.vector(temp_df[,1]))+1, Loc1536=temp_df[,2], Pl384=as.numeric(as.vector(temp_df[,3]))+4, Loc384=temp_df[,4]) many_df1536_384 <- rbind(many_df1536_384, temp_df) } } row.names(many_df1536_384) <- 1:length(many_df1536_384[,1]) many_df1536_384 } my_plate_mappings <- plate_mapping_fct2(no_1536_plates=4) print("To generate mapping table for as many plates as you need, run plate mapping function like this (here 4 plates):") print("plate_mapping_fct2(no_1536_plates=4)") print("The example 'my_plate_mappings' contains the mappings for 4 1536-well plates.") print("my_plate_mappings[1:8,]") print(my_plate_mappings[1:8,], quote=F)