Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Set custom background? #11

Closed
mkrdonovan opened this issue Feb 23, 2021 · 9 comments
Closed

[BUG] Set custom background? #11

mkrdonovan opened this issue Feb 23, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@mkrdonovan
Copy link

Fantastic GO enrichment tool!

Wondering if the option to set your own custom background has been implemented or if there are plans to?

Thanks!

@mkrdonovan mkrdonovan added the bug Something isn't working label Feb 23, 2021
@AviMaayan
Copy link

@mkrdonovan
Copy link
Author

Thanks for the tip! Will give it a try--wasn't familiar with Appyters before, but it's a very cool concept. Still, would love to have bg optional in the R Enrichr package :)

@JoyOtten
Copy link

I totally agree that it would be a very nice option to have background genes as an option in the R enrichr package.

@julien-roux
Copy link

Here is a recent paper illustrating again the risks of not using the correct background for enrichment analyses: https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1009935

So this feature would definitely be needed! A lot of biologists use the app without paying attention to this problem....

@d0minicO
Copy link

Agreed! I loved how easy the tool was to set up in R using the enrichR package. Now having to use something else because without a custom background it is unusable unfortunately... Anyone worth their salt will ask what background was used, and if you haven't used correct one then you come out with a red face.

@AviMaayan
Copy link

It is there. We implemented support for background. The background is already implemented and available in the R package. It will be added to the UI soon.

@d0minicO
Copy link

Great! Please could you describe how to use it? I've looked at the vignette and reference manual but can't seem to find any mention of background... Thanks for the great tool!

@lachmann12
Copy link

lachmann12 commented Apr 24, 2023

Hi there,

Below is some R code that demonstrates how to perform background correction with the Enrichr API:

(The input file should contain one gene symbol per line)

library(jsonlite)
library(httr)

baseurl <- "https://maayanlab.cloud/speedrichr/api/"

#1. Upload a gene set for enrichment analysis.
#This function returns an identifier that is needed for later calls (userListId)
genelist <- readLines("testinput.txt")
description <- "Example gene list"

ENRICHR_URL <- paste0(baseurl, "addList")
payload <- list(
  list = upload_file("testinput.txt"),
  description = description
)
response <- POST(ENRICHR_URL, body = payload, encode = "multipart")
data <- fromJSON(content(response, as = "text"))
print(toJSON(data, pretty = TRUE))

#2. Upload the background
#The function returns an identifier that we will need for later calls (backgroundid)
backgroundgenes <- readLines("human_genes.tsv")

ENRICHR_URL <- paste0(baseurl, "addbackground")
payload <- list(
  background = backgroundgenes
)
response <- POST(ENRICHR_URL, body = payload)
data_back <- fromJSON(content(response, as = "text"))
print(toJSON(data_back, pretty = TRUE))

#3. List available libraries, we can then select one of these libraries for the enrichment analysis calculation
ENRICHR_URL <- paste0(baseurl, "listlibs")
response <- GET(ENRICHR_URL)
data_libs <- fromJSON(content(response, as = "text"))
print(toJSON(data_libs, pretty = TRUE))

#4. Pass IDs retrieved from step 1 and step 2 and a gene set library from step 3. Here we select a library, and apply the enrichment analysis using the two previously uploaded gene sets.
library_name <- "GO_Biological_Process_2018"

ENRICHR_URL <- paste0(baseurl, "backgroundenrich")
payload <- list(
  userListId = data$userListId,
  backgroundid = data_back$backgroundid,
  backgroundType = library_name
)
response <- POST(ENRICHR_URL, body = payload)
data_ben <- fromJSON(content(response, as = "text"))
print(toJSON(data_ben, pretty = TRUE))

@lachmann12
Copy link

lachmann12 commented Apr 24, 2023

The input files are: "testinput.txt" and "human_genes.tsv". The "human_genes.tsv" is the background gene set and "testinput.txt" the gene set to run enrichment against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants