2525# ' * `ID` name of gene set.
2626# ' * `model_type` record of input model type from `modeling results`.
2727# ' * `fdr_cut` record of input `frd_cut`.
28+ # ' * `GeneList` List of gene names from input set with `fdr < fdr_cut` and
29+ # ' `t_stat > 0`, possible that some gene_names are missing from modeling data.
2830# '
2931# ' @export
3032# ' @importFrom stats fisher.test
@@ -126,6 +128,14 @@ gene_set_enrichment <-
126128 Layer = factor (layer , c(FALSE , TRUE ))
127129 )
128130 })
131+
132+ # # get list of genes
133+ ensembl_list <- model_results $ ensembl [layer ]
134+ gene_name_list <- model_results $ gene [layer ]
135+
136+ sig_geneList <- lapply(geneList_present , function (g ) {
137+ gene_name_list [ensembl_list %in% g ]
138+ })
129139
130140 enrichList <-
131141 lapply(tabList , fisher.test , alternative = " greater" )
@@ -137,6 +147,9 @@ gene_set_enrichment <-
137147 x [2 , 2 ]
138148 }, integer(1 )),
139149 SetSize = vapply(geneList_present , length , integer(1 )),
150+ GeneList = vapply(sig_geneList , function (x ){
151+ paste0(x , collapse = " , " )
152+ }, character (1 )),
140153 stringsAsFactors = FALSE
141154 )
142155 o $ ID <- gsub(" .odds ratio" , " " , rownames(o ))
@@ -149,6 +162,8 @@ gene_set_enrichment <-
149162 enrichTab $ model_type <- " depletion"
150163 }
151164 enrichTab $ fdr_cut <- fdr_cut
165+
166+ enrichTab <- enrichTab [, c(' OR' , ' Pval' , ' test' , ' NumSig' , ' SetSize' , ' ID' , ' model_type' , ' fdr_cut' , ' GeneList' )]
152167
153168 return (enrichTab )
154169 }
0 commit comments