Skip to content

Commit 7d74806

Browse files
committed
Move GeneList to last col
1 parent 20d2ef8 commit 7d74806

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

R/gene_set_enrichment.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
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
}

man/gene_set_enrichment.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)