# want to calculate significance of pairwise sharing between lists. Standard hypergeometric test seems inappropriate

I want to calculate if the percentage of sharing of strings (genes in this case) between lists is significantly more than expected by chance for multiple pairwise comparisons between lists of strings.

I know there are hypergeometric tests one can do online for this but they ask you to input the number of genes in the genome as a backgroun. My lists each come from slightly different subsets of the genome, so using a single overall genome size for this test is innappropriate. I think I will have more accurate results if I subsample from the specific groups of genes that I have used to create each list.

I have multiple lists of strings of different size. I have manually calculated the percentage pairwise sharing of strings between each list. For example for list A and list B I count how many strings occur in both lists then calculate what percentage this is of the combined size of list A and list B.

Toy example:

List A:

[1,] "EDA"
[2,] "MGN2"
[3,] "5RSK"
[4,] "TOLL4"
[5,] "BBOX"


List B:

[1,] "EDA"
[2,] "TOLL4"
[3,] "KAR2"
[4,] "HARL3"


Here two strings (EDA, TOLL4) are shared between the two lists. There are 9 strings in total (list A + list B), so the percentage sharing between lists is 22.2% (is this an appropriate way to calculate percentage sharing between two lists?)

I have made the same calculation of percentage pairwise sharing (maybe overlap is a better term) between several other lists. I now want to test whether this overlap is significant using a resampling approach. I would appreciate any help.

Each of these lists is itself a subsample from a larger list. For example list A is a sample of 5 strings from a larger group A (size : 100 strings). List B is a subsample of 4 strings from group B (size : 200 strings) and so on for each list. Therefore to calculate if the sharing I observe between list A and list B is significantly more than expected by chance I think I need to randomly sample 5 strings from group A and 4 strings from group B (without replacement), then calculate the percentage overlap between these two randomly sampled lists. Then if I repeat this process 100 times I can create a distribution of percentage overlap scores and compare this to my observed overlap of 22.2%.

I have some previous code that I was using to do overlaps from multiple combined lists but I don't think it will scale well to doing this process for multiple pairwise comparisons, eg List A - List B, List A - List C, List B - List C, etc. This can be seen at How to create a loop to repeat random sampling procedure in R

I would appreciate any help on calculating these pairwise percentage sharing values, or advice on how to make my question clearer.