I am doing a WGCNA analysis, and there is a piece of code in it: I need to build a matrix later, take TCGA_AML_Members and consMembers for fisher test:
Numbers of femaleand consensus modules
nTCGA_AML_Mods =length(TCGA_AML_Modules)
nConsMods =length(consModules)
Initialize tablesof p-values and of the corresponding counts
pTable = matrix(0,nrow = nTCGA_AML_Mods, ncol = nConsMods);
CountTbl =matrix(0, nrow = nTCGA_AML_Mods, ncol = nConsMods);
Execute all pairwaisecomparisons
for (Tmod in 1: nTCGA_AML_Mods)
for (Cmod in 1: nConsMods)
{
TCGA_AML_Members =(TCGA_AML_Colors == TCGA_AML_Modules[Tmod]);
consMembers =(moduleColors == consModules[Cmod]);
pTable[Tmod, Cmod]= -log10(fisher.test(TCGA_AML_Members, consMembers, alternative = "greater")$p.value);
CountTbl[Tmod, Cmod]= sum(TCGA_AML_Colors == TCGA_AML_Modules[Tmod] & moduleColors ==consModules[Cmod])
}
Error in fisher. Test(TCGA_AML_Members, consMembers, alternative = "greater") :
how can i do this?
2 answers
Fisher test needs a 2x2 table. Try fisher.test(table(TCGA, cons), ...). You also may need to use factor(TCGA, levels=(0,1)) for each argument, or else cases where there aren't any overlap will result in a 1x2 table and break the function.
Log in to answer this question.