Commit 28a1da79 authored by smorabit's avatar smorabit
Browse files

enrichR waits 5 seconds

parent 410ecac2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Package: hdWGCNA
Title: hdWGCNA
Version: 0.2.17
Version: 0.2.18
Authors@R: c(
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0002-7768-4856")),
+7 −0
Original line number Diff line number Diff line
# hdWGCNA 0.2.18 (2023-04-14)
## Added
- None.

## Changes
- We noticed on rare occasion that EnrichR would give duplicated results for different modules, so we added a new option in `RunEnrichr` to wait in between sending requests to the EnrichR server (default is 5 seconds).

# hdWGCNA 0.2.17 (2023-03-27)
## Added
- None.
+16 −3
Original line number Diff line number Diff line
@@ -6,21 +6,32 @@
#' @param seurat_obj A Seurat object
#' @param dbs character vector of EnrichR databases
#' @param max_genes Max number of genes to include per module, ranked by kME.
#' @param wait logical indicating whether or not to wait some time between sending requests to the EnrichR server.
#' @param wait_time the number of seconds to wait between sending requests to the EnrichR server. Value must be less than 60.
#' @param wgcna_name The name of the hdWGCNA experiment in the seurat_obj@misc slot
#' @keywords scRNA-seq
#' @export
#' @examples
#' RunEnrichr
RunEnrichr <- function(
  seurat_obj,
  dbs = c('GO_Biological_Process_2021','GO_Cellular_Component_2021','GO_Molecular_Function_2021'),
  max_genes = 100,
  wait = TRUE,
  wait_time = 5,
  wgcna_name=NULL, ...
){

  # get data from active assay if wgcna_name is not given
  if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}

  # check wait_time 
  if(!is.numeric(wait_time)){
    stop(paste0('wait_time must be a numeric.'))
  } 
  if(wait_time > 60 | wait_time < 1){
    stop(paste0('Invalid value selected for wait_time, must be greater than 0 and less than 60.'))
  }

  # get modules:
  modules <- GetModules(seurat_obj, wgcna_name)
  mods <- levels(modules$module)
@@ -39,10 +50,13 @@ RunEnrichr <- function(
    } else{
      cur_genes <- subset(modules, module == cur_mod) %>% .$gene_name %>% as.character
    }
    
    # run the enrichment test
    enriched <- enrichR::enrichr(cur_genes, dbs)

    if(wait){
      Sys.sleep(wait_time)
    }

    # collapse into one db
    for(db in names(enriched)){
      cur_df <- enriched[[db]]
@@ -72,7 +86,6 @@ RunEnrichr <- function(
#' @param wgcna_name The name of the hdWGCNA experiment in the seurat_obj@misc slot
#' @keywords scRNA-seq
#' @export
#' @examples
#' OverlapModulesDEGs
OverlapModulesDEGs <- function(
  seurat_obj,
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="https://smorabit.github.io/hdWGCNA/index.html">hdWGCNA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.17</span>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.18</span>
      </span>
    </div>

+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="index.html">hdWGCNA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.17</span>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.18</span>
      </span>
    </div>

Loading