Closed Ning-L closed 3 years ago
https://github.com/mcanouil/analysis_templates/blob/67dce67de0a67f46261ad323209868894822285f/R/12-ora_gsea.R#L342-L347
write_xlsx( x = setNames(lapply(enrich_sets, FUN = function(.enrich) { if (!is.null(.enrich)) { tmp <- .enrich@result tmp[["peripheral_enrichment"]] <- unlist(lapply(seq_along(tmp$ID), function(i) { enriched <- names(.enrich@geneList)[names(.enrich@geneList) %in% .enrich@geneSets[[tmp$ID[i]]]] paste0(setdiff( enriched, unlist(strsplit(tmp$core_enrichment[i], split = "/")) ), collapse = "/") })) return(tmp) } else data.frame() }), gsub("Gene Ontology", "GO", names(enrich_sets))), path = file.path(output_directory, "gene_set_enrichment.xlsx") )
Thanks, I'll update the code with a slight modification of your proposal. Those "R templates" are more likely to be part of an R package or something else to allow easier access/use.
https://github.com/mcanouil/analysis_templates/blob/67dce67de0a67f46261ad323209868894822285f/R/12-ora_gsea.R#L342-L347