say I have 6 people drawing from their own box, each box contains 10,000 unique barcodes. Now at the end of the experiment each person has drawn roughly 10-20 barcodes. How do I test if the barcodes are not siginficantly overlapping between each person. In other words I want to show that the barcodes are just random? I'm thinking of something like a hypergeometric test or some sort of contigency table, however in this case there there are N=6 and 10,000 unique rows.


  • $\begingroup$ @BruceET I think this is a good point - I will try it out. The example above is very close to my real experiment. I did not want to get to technical but esentially the barcodes are strips of DNA with a disntinct signature. Each cells contains the unique barcode and this is a control experiment where we want to make sure that the surviving clones are just due to random and not specific to inserted barcodes. $\endgroup$
    – Ahdee
    Commented Aug 7, 2021 at 1:10
  • $\begingroup$ @BruceET this is interesting, so basically if I can show that through a stimulation given X selection I will have < Y duplicates, I can use this a sort of a baseline? thanks I like it. $\endgroup$
    – Ahdee
    Commented Aug 7, 2021 at 1:33
  • $\begingroup$ OK. Your mechanism seems right. And I did my simulation again. It is rare to have more than 2 duplicates out of 80 selections altogether from the six groups. The 99th percentile is 2 matches, max nr of matches in 100,000 iterations was 5. // Have an appointment now. Will post R code for my my simulation in 3-4 hrs if you want to see it. $\endgroup$
    – BruceET
    Commented Aug 7, 2021 at 1:34
  • $\begingroup$ Fine tuning: is it possible to have a duplicate within one of the six groups?. // For simulation, it is OK to have all six groups sample exact;y 15 barcodes? If not, what is the approx. dist'n of group barcode counts 10-20? Proportions 1:1:2;2,3:4:3:2:2,1:1 out of 22? $\endgroup$
    – BruceET
    Commented Aug 7, 2021 at 2:21
  • $\begingroup$ @BruceET yes, it is possible for all 6 to all have the same barcodes since each sample is drawing from their own box of barcodes. $\endgroup$
    – Ahdee
    Commented Aug 7, 2021 at 2:27

1 Answer 1


R code for simulation per discussion in comments. For comments I did 100,000 iterations; here I did a million iterations for greater precision.

set.seed(806)   # for reproducibility
m = 10^6
d = numeric(m)  # duplicates
n = 80          # barcodes chosen
for (i in 1:m) {
 x = sample(1:10000, n, rep=T)
 d[i] = n - length(unique(x))
[1] 0.315031   # mean nr of matches among 80
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  0.000   0.000   0.000   0.315   1.000   6.000 

quantile(d, c(.9, .95, .99))
90% 95% 99% 
  1   1   2    # rare to get 2 or more matches

With n = 20, we see that it is rare to have one duplicate in a single group of 20. [Even more so for a single group of 10.]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.