I am intersecting two files and afterwards doing a fisher test and an enrichment test on the results. However after running the fisher test there is an error which I do not understand.
> ee=c()
> E=c()
> for (e in 1: length(conditions))
+ {
+ for(i in 1: length(view))
+ {
+ A=length(na.omit(intersect(conditions[,e], view[,i])))
+ B=length(na.omit(intersect(conditions[,1], view[,i])))
+ C=length(na.omit(conditions[,e]))
+ D=length(na.omit(conditions[,1]))
+ ee=c(ee, fisher.test(matrix(c(A,B-A,C-A,A-B-C+D),nrow=2,ncol=2)
+ ,alternative="two.sided")$p.val)
+ E=c(E, (A/B) / ((C-A)/(D-B)))
+ } + } Error in fisher.test(matrix(c(A, B - A, C - A, A - B - C + D), nrow = 2, : all entries of 'x' must be nonnegative and finite
ee
[1] 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
[8] 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 2.429018e-05 1.572763e-01 1.000000e+00
[15] 3.620512e-03 6.605189e-01 3.930938e-01 7.564593e-01 8.356520e-01 8.354842e-01 8.718355e-01
[22] 1.000000e+00 7.174337e-01 1.813913e-01 3.480816e-01 9.189262e-02 8.892926e-01 6.528839e-02
[29] 1.000000e+00 8.452332e-01 1.000000e+00 1.000000e+00 1.000000e+00
E
[1] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[11] NaN 0.2527881 0.6250381 0.9075342 2.1028830 0.8772727 0.6801843 1.1282051 0.8698752 0.9007353
[21] 0.9247312 NaN 0.8624535 1.3294461 0.5018939 0.5030426 1.0376344 1.5870968 0.9445438 0.9242424
[31] 0.9570313 0.9907834 NaN
The "conditions" dataframe contains 10 columns, and the "view" dataframe contains 11 columns. After intersection I would expect a 110 results to come out of the fisher test and enrichment caculation (E=c(E, (A/B) / ((C-A)/(D-B))) ) ,not 33 as in the output. There are NA's in both the dataframes but the na.omit should take care of that, all other values are just positive numerical values.
Help would be really appreciated.