Hi all,
So I am designing a biological experiment by which i need to distribute 587 different peptides between 80 buckets. Each peptide should be present in 4 buckets, and the restriction is that if peptide X is present in a bucket, then peptides X-2, X-1, X+1, and X+2 are not allowed in that bucket.
I tried to brute force my way through this, by just randomly sampling different combination of buckets until i found a combination that fit this. HOWEVER, i quickly realized I am looking for a quite rare event, because I ended up the same peptide picked twice for at least one pool (and most often in many pools).
This is the code I tried: (not suggesting this is the way forward, but just to share with you what I tried)
# Set rules
buckets = 80
size = 30
coverage = 4
iterations = 100
system.time({
# Create [iteration] random pools
pool_assignent = list()
for (i in 1:iterations) {
pool_assignent[[i]] <- data.frame(pool = rep(1:buckets, 30), peptide = sample(rep(1:587,4), replace = F)) %>%
split(.$pool) %>%
map(~ .$peptide)
}
# Name the pools
names(pool_assignent) <- paste("i_", 1:iterations, sep="")
# Find minimum within each pool
min <- pool_assignent %>%
map(map, dist) %>%
map(map, as.vector) %>%
map(~ bind_rows(.)) %>%
map(~ min(.)) %>%
do.call(rbind, .)
print(min(min))
})
Please let me know if you have any ideas. I did have a look at Sampling without replacement multiple times and ensuring equal samples but was not able to use this code in an effective way. I do believe however, this has to be a structured selection process, and not a random sampling.
Thanks all,
Nils