I am trying to apply Fisher's exact test in R for a matrix which contains count data for a TCR-seq dataset. Each row in the matrix is a different tcr clonotype and each column represents different conditions. The cells have normalized counts (to account for sequencing depth differences) for each tcr for each condition. I want to apply fisher's exact test to test each tcr against rest of the tcr to test null hypothesis that they are not different between conditions.
I am looking for a solution similar to the following line of code that iterates over the full matrix and provides me with a p-value.
apply(tab, 1, function(x) fisher.test(matrix(x,nrow=2,ncol=2))$p.value)
How do I set this up in R?Any suggestions are welcome.
This approach was applied in the following paper. However, since I am not a statistician, I couldn't apply the notations to my script very well.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4442358/
This is similar to the question that has been asked below (but in the context of gene expression).
Thanks.