# Test of proportion between two groups

I'm trying to compare two groups of ranked lists (of genes) by test of proportion. As shown in the mosaic plot and the data, there is a gene of interest which divides each list into genes ranked above it and below it. I wish to see if there is significant difference in ranking of our gene of interest among the groups (S,N,L and K) which are comprised of two replicates, S1&S2, N1&N2 etc.

Sample  Above   Below
S2  34  809
S1  141 856

N2  62  715
N1  28  864

L2  30  543
L1  33  605

K2  1   542
K1  1   618


For comparison of two single lists I can do a Chi-square test as follows,and get the p-value:

L2_L1.mat <- matrix(c(30,543,33,605),nrow=2,byrow=2)
chisq.test(L2_L1.mat,correct=FALSE)

Pearson's Chi-squared test

data:  L2_L1.mat
X-squared = 0.0024441, df = 1, p-value = 0.9606

N2_L1.mat <- matrix(c(62,715,33,605),nrow=2,byrow=2)
chisq.test(N2_L1.mat,correct=FALSE)

Pearson's Chi-squared test

data:  N2_L1.mat
X-squared = 4.4074, df = 1, p-value = 0.03578


But How to compare two groups like L(L1,L2) and N(N1,N2)