saezlab / decoupleR

R package to infer biological activities from omics data using a collection of methods.
https://saezlab.github.io/decoupleR/
GNU General Public License v3.0
176 stars 23 forks source link

get_collectri is hard coded for human #109

Closed karJac closed 7 months ago

karJac commented 7 months ago

Hi,

After installing the decoupleR package from Bioconductor on R version 4.3.2, I encountered an issue with the function decoupleR::get_collectri(). Although the function's description suggests that it supports both human and mouse datasets, its implementation appears to be hardcoded exclusively for human data.

image

We can see in the code that parameter "organism" is not being caleld inside OmnipathR::collectri(). The default parameter for "organism" in OmnipathR::collectri() is human, thus the function is hardcoded for "human".

image

Here is the code of get_collectri function with correct calling of "organism" parameter:


get_collectri <- function(organism = "human", split_complexes = FALSE){
  if (organism == "human"){
    organism <- "9606"
  } else if (organism == "mouse"){
    organism <- "10090"
  } else {
    stop("Interactions are available only for human and mouse!")
  }

  collectri <- OmnipathR::collectri(organism=organism) #default organism is human
  cols <- c("source_genesymbol", "target_genesymbol", "is_stimulation", 
            "is_inhibition")
  collectri_interactions <- collectri[!stringr::str_detect(collectri$source, 
                                                           "COMPLEX"), cols]
  collectri_complex <- collectri[stringr::str_detect(collectri$source, 
                                                     "COMPLEX"), cols]
  if (!split_complexes) {
    collectri_complex <- collectri_complex %>% dplyr::mutate(source_genesymbol = dplyr::case_when(stringr::str_detect(source_genesymbol, 
                                      "JUN") | stringr::str_detect(source_genesymbol, "FOS") ~ 
                    "AP1", stringr::str_detect(source_genesymbol, "REL") | 
                    stringr::str_detect(source_genesymbol, "NFKB") ~ 
                    "NFKB"))
  }
  collectri <- base::rbind(collectri_interactions, collectri_complex) %>% 
    dplyr::distinct(.data$source_genesymbol, .data$target_genesymbol, 
                    .keep_all = TRUE) %>% dplyr::mutate(weight = dplyr::case_when(is_stimulation == 
                         1 ~ 1, is_stimulation == 0 ~ -1)) %>% dplyr::select(.data$source_genesymbol, 
                                    .data$target_genesymbol, .data$weight) %>% dplyr::rename(source = .data$source_genesymbol, 
                                          target = .data$target_genesymbol, mor = .data$weight, 
                                    )
  return(collectri)
}

Now it seems to work properly. image

Hope that my post will be helpful for you and thank you for creating this package! Karol

deeenes commented 7 months ago

Hi Karol,

This has been fixed long time ago, I recommend to update the package from this git repo:

library(remotes)
remotes::install_github('saezlab/decoupleR')

I'll check why the update is not included in the latest BioC release.

Best,

Denes

karJac commented 7 months ago

It seems that BiocManager::install("decoupleR") installed the version 2.6.0, instead of the latest 2.8.0, because BiocManager was outdated (3.16 instead of 3.18). My bad then, sorry for the confusion.