### Specify Resources for LR Network Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_lr_network_omnipath.html This example shows how to use specific resources like CellPhoneDB and Guide to Pharmacology when building the ligand-receptor network. ```R op_lr_network <- nichenet_lr_network_omnipath( resources = c('CellPhoneDB', 'Guide2Pharma') ) ``` -------------------------------- ### Example: NicheNet GR Network with Specific Datasets Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_gr_network_harmonizome.html Example demonstrating how to use `nichenet_gr_network_harmonizome` with a subset of datasets, specifically JASPAR, TRANSFAC, and TRANSFAC PWM. ```r # use only JASPAR and TRANSFAC: hz_gr_network <- nichenet_gr_network_harmonizome( datasets = c('jasparpwm', 'transfac', 'transfacpwm') ) ``` -------------------------------- ### Basic cache save and load example Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_cache_load.html A basic example demonstrating how to save HTML content to the cache and then load it back using a URL. This is useful for caching web resources. ```R # basic example of saving and loading to and from the cache: bioc_url <- 'https://bioconductor.org/' bioc_html <- readChar(url(bioc_url), nchars = 99999) omnipath_cache_save(bioc_html, url = bioc_url) bioc_html <- omnipath_cache_load(url = bioc_url) ``` -------------------------------- ### Install OmnipathR from Bioconductor or GitHub Source: https://context7.com/saezlab/omnipathr/llms.txt Installs the stable release from Bioconductor or the development version from GitHub. Loads the library for use. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("OmnipathR") ``` ```r # install.packages("devtools") devtools::install_github("saezlab/OmnipathR") ``` ```r library(OmnipathR) ``` -------------------------------- ### Install Nichenetr Package from GitHub Source: https://github.com/saezlab/omnipathr/blob/master/docs/articles/nichenet.html Install the nichenetr package and its dependencies from GitHub. This is a prerequisite for running the NicheNet pipeline. ```r require(devtools) install_github('saeyslab/nichenetr') ``` -------------------------------- ### Install OmnipathR from GitHub Source: https://github.com/saezlab/omnipathr/blob/master/README.md Installs the OmnipathR package directly from GitHub using the devtools package. This is recommended for accessing the most recent developments. ```r require(devtools) install_github('saezlab/OmnipathR') ``` -------------------------------- ### Get interactions and visualize neighborhood Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/show_network.html This example demonstrates how to fetch interactions using omnipath() and then visualize the neighborhood of a specific node (e.g., 'ATM') using viz_sigmajs_neighborhood. This is useful for exploring local network structures around a protein of interest. ```R interactions <- omnipath() viz_sigmajs_neighborhood(interactions_df = interactions, int_node = "ATM") ``` -------------------------------- ### guide2pharma_download() Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/index.html Downloads interactions from the Guide to Pharmacology database. ```APIDOC ## guide2pharma_download() ### Description Downloads interactions from the Guide to Pharmacology database. ### Method N/A (Function call) ### Endpoint N/A ### Parameters None explicitly documented. ### Request Example ```R guide2pharma_data <- guide2pharma_download() ``` ### Response A data frame of interactions from Guide to Pharmacology. ``` -------------------------------- ### guide2pharma_download Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/guide2pharma_download.html Downloads ligand-receptor interactions from the Guide to Pharmacology (IUPHAR/BPS) database. ```APIDOC ## guide2pharma_download ### Description Downloads ligand-receptor interactions from the Guide to Pharmacology (IUPHAR/BPS) database. ### Method function ### Endpoint NA ### Parameters This function does not take any parameters. ### Value A tibble (data frame) of interactions as it is provided by the database. ### Examples ```R g2p_data <- guide2pharma_download() g2p_data ``` ``` -------------------------------- ### List Enzyme-Substrate Resources Source: https://context7.com/saezlab/omnipathr/llms.txt Lists all available enzyme-substrate interaction resources. No setup required. ```r enzsub_resources() ``` -------------------------------- ### List Available Complex Resources Source: https://context7.com/saezlab/omnipathr/llms.txt Lists all available resources for protein complex data. No setup required. ```r complex_resources() ``` -------------------------------- ### nichenet_lr_network_guide2pharma Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_lr_network_guide2pharma.html Downloads ligand-receptor interactions from the Guide to Pharmacology database and converts it to a format suitable for NicheNet. ```APIDOC ## nichenet_lr_network_guide2pharma ### Description Downloads ligand-receptor interactions from the Guide to Pharmacology database and converts it to a format suitable for NicheNet. ### Usage ```R nichenet_lr_network_guide2pharma() ``` ### Value Data frame with ligand-receptor interactions in NicheNet format. ### See Also `[nichenet_lr_network](nichenet_lr_network.html), [guide2pharma_download](guide2pharma_download.html)` ### Examples ```R g2p_lr_network <- nichenet_lr_network_guide2pharma() ``` ``` -------------------------------- ### Get KEGG Operations - R Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/kegg_operations.html Retrieves a character vector of available operations in the KEGG REST API. No specific setup or imports are required beyond having the OmnipathR package installed. ```r kegg_operations() #> [1] "info" "list" "find" "get" "conv" "link" "ddi" ``` -------------------------------- ### Download and then remove a specific cache entry Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_cache_remove.html This example demonstrates downloading a resource, obtaining its cache version, and then removing that specific cache entry by its key. It also shows how to check if the download was successful. ```R bioc_url <- 'https://bioconductor.org/' version <- omnipath_cache_latest_or_new(url = bioc_url) httr::GET(bioc_url, httr::write_disk(version$path, overwrite = TRUE)) #> Response [https://bioconductor.org/] #> Date: 2024-04-07 15:20 #> Status: 200 #> Content-Type: text/html #> Size: 37.3 kB #> /home/denes/.cache/OmnipathR/41346a00fb20d2a9df03aa70cf4d50bf88ab154a-1 omnipath_cache_download_ready(version) key <- omnipath_cache_key(bioc_url) omnipath_cache_remove(key = key) ``` -------------------------------- ### Get Descendants by Name Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/descendants.html Retrieves the names of descendants for a given ontology term ID. This example demonstrates how to get human-readable names instead of IDs. ```r descendants('GO:0005035', ids = FALSE) #> [1] "tumor necrosis factor receptor activity" #> [2] "death receptor activity" #> [3] "TRAIL receptor activity" #> [4] "TNFSF11 receptor activity" # [1] "tumor necrosis factor-activated receptor activity" # [2] "TRAIL receptor activity" # [3] "TNFSF11 receptor activity" ``` -------------------------------- ### Run NicheNet with custom parameters Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_main.html Example of how to run the `nichenet_main` function while overriding default network resources and optimization parameters. This demonstrates how to exclude certain resources, modify parameters for specific resources, and adjust the number of top ligands and CPU cores used. ```R if (FALSE) { nichenet_results <- nichenet_main( # altering some network resource parameters, the rest # of the resources will be loaded according to the defaults signaling_network = list( cpdb = NULL, # this resource will be excluded inbiomap = NULL, evex = list(min_confidence = 1.0) # override some parameters ), gr_network = list(only_omnipath = TRUE), n_top_ligands = 20, # override the default number of CPU cores to use mlrmbo_optimization_param = list(ncores = 4) ) } ``` -------------------------------- ### Get ancestors by name Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/ancestors.html Retrieves the names of all ancestors for a given ontology term ID. This example demonstrates how to get human-readable names instead of IDs. ```r ancestors('GO:0005035', ids = FALSE) #> [1] "molecular_function" #> [2] "transmembrane signaling receptor activity" #> [3] "death receptor activity" #> [4] "signaling receptor activity" #> [5] "molecular transducer activity" # [1] "molecular_function" # [2] "transmembrane signaling receptor activity" # [3] "signaling receptor activity" # [4] "molecular transducer activity" ``` -------------------------------- ### Print enzyme-substrate paths - R Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/print_path_vs.html This example shows how to find and print enzyme-substrate paths between 'SRC' and 'STAT1' using data from PhosphoSite and SIGNOR. It retrieves enzyme-substrate interactions, constructs a graph, finds the shortest path, and then prints it using print_path_vs. ```R enzsub <- enzyme_substrate(resources=c("PhosphoSite", "SIGNOR")) enzsub_g <- enzsub_graph(enzsub) print_path_vs( igraph::all_shortest_paths( enzsub_g, from = 'SRC', to = 'STAT1' )$res, enzsub_g ) ``` -------------------------------- ### List tables in MetalinksDB Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/metalinksdb_tables.html Call this function to retrieve a character vector of all table names present in the MetalinksDB SQLite database. No setup or imports are required beyond having the OmnipathR package installed. ```R metalinksdb_tables() #> [1] "biospecimen_location" "cell_location" "disease" #> [4] "edges" "metabolites" "pathway" #> [7] "proteins" "tissue_location" ``` -------------------------------- ### Download and filter PrePPI interactions Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/preppi_filter.html Demonstrates how to download PrePPI interactions using `preppi_download` and then filter them by multiple score thresholds using `preppi_filter`. The example shows setting minimum values for 'red', 'str', and 'ort' scores and then checking the number of resulting interactions. ```R preppi <- preppi_download() preppi_filtered <- preppi_filter(preppi, red = 10, str = 4.5, ort = 1) nrow(preppi_filtered) #> [1] 8443 # [1] 8443 ``` -------------------------------- ### Generate Chalmers GEM Network Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/chalmers_gem_network.html This snippet shows how to call the chalmers_gem_network function with default parameters to generate a gene-metabolite interaction network. Note: This example may produce an error if the 'R.matlab' package is not installed, as it's a dependency for loading certain GEM data. ```R gem <- chalmers_gem_network() #> Error in map2(.x, .y, .f, ..., .progress = .progress): ℹ In index: 1. #> ℹ With name: col_types. #> Caused by error in `loadNamespace()`: #> ! there is no package called ‘R.matlab’ ``` -------------------------------- ### Compile Weighted Ligand-Target Links Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_ligand_target_links.html This example demonstrates the full workflow of preparing data and calling the `nichenet_ligand_target_links` function. It requires prior steps to obtain network data, expression data, optimization results, and build the NicheNet model. ```R if (FALSE) { networks <- nichenet_networks() expression <- nichenet_expression_data() optimization_results <- nichenet_optimization(networks, expression) nichenet_model <- nichenet_build_model(optimization_results, networks) lt_matrix <- nichenet_ligand_target_matrix( nichenet_model$weighted_networks, networks$lr_network, nichenet_model$optimized_parameters ) ligand_activities <- nichenet_ligand_activities( ligand_target_matrix = lt_matrix, lr_network = networks$lr_network, # the rest of the parameters should come # from your transcriptomics data: expressed_genes_transmitter = expressed_genes_transmitter, expressed_genes_receiver = expressed_genes_receiver, genes_of_interest = genes_of_interest ) lt_links <- nichenet_ligand_target_links( ligand_activities = ligand_activities, ligand_target_matrix = lt_matrix, genes_of_interest = genes_of_interest, n_top_ligands = 20, n_top_targets = 100 ) } ``` -------------------------------- ### Create NicheNet ligand-target matrix Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_ligand_target_matrix.html This example demonstrates how to build a NicheNet model and then generate the ligand-target matrix. It requires several prerequisite functions from the OmnipathR package. ```R if (FALSE) { networks <- nichenet_networks() expression <- nichenet_expression_data() optimization_results <- nichenet_optimization(networks, expression) nichenet_model <- nichenet_build_model(optimization_results, networks) lt_matrix <- nichenet_ligand_target_matrix( nichenet_model$weighted_networks, networks$lr_network, nichenet_model$optimized_parameters ) } ``` -------------------------------- ### Install OmnipathR Package Source: https://github.com/saezlab/omnipathr/blob/master/docs/articles/omnipath_intro.html Installs the OmnipathR package using BiocManager. Ensure you have a current version of R installed. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("OmnipathR") ``` -------------------------------- ### Install OmnipathR from Bioconductor (Latest Release) Source: https://github.com/saezlab/omnipathr/blob/master/README.md Installs the latest stable release of the OmnipathR package from Bioconductor. Ensure BiocManager is installed first. ```r if (!requireNamespace('BiocManager', quietly = TRUE)) install.packages('BiocManager') ## Last release in Bioconductor BiocManager::install('OmnipathR', version = '3.12') ``` -------------------------------- ### Build Complete COSMOS PKN with cosmos_pkn() Source: https://github.com/saezlab/omnipathr/blob/master/docs/articles/cosmos.html Builds the complete COSMOS PKN by integrating all available resources. This function supports customization through arguments and caches data at various processing levels to shorten processing times. If the cache is available, loading the complete PKN takes only a few seconds. ```R pkn <- cosmos_pkn() pkn ``` -------------------------------- ### Install Missing R Packages Source: https://github.com/saezlab/omnipathr/blob/master/docs/articles/paths.html Checks for and installs missing R packages required for the vignette. It specifically handles installing from GitHub if OmnipathR is not found. ```R missing_packages <- setdiff( c( 'magrittr', 'dplyr', 'purrr', 'igraph', 'rlang', 'tidyselect', 'stringr', 'rmarkdown', 'devtools' ), installed.packages() ) if(length(missing_packages)){ install.packages(missing_packages) } if(!'OmnipathR' %in% installed.packages()){ library(devtools) devtools::install_github('saezlab/OmnipathR') } ``` -------------------------------- ### Get Package Config Path Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_config_path.html A more general function to get the configuration path for a specified package. Defaults to 'OmnipathR'. ```R config_path(user = FALSE, pkg = "OmnipathR") ``` -------------------------------- ### Package Development Setup with devtools Source: https://github.com/saezlab/omnipathr/blob/master/AGENTS.md Loads the OmnipathR package for development using `devtools::load_all()`. This is recommended over `library(OmnipathR)` when actively developing the package. ```r library(devtools) load_all() ``` -------------------------------- ### Install OmnipathR from Bioconductor (Development Version) Source: https://github.com/saezlab/omnipathr/blob/master/README.md Installs the development version of the OmnipathR package from Bioconductor, which includes the latest updates and features. ```r BiocManager::install('OmnipathR', version = 'devel') ``` -------------------------------- ### Download and read data from Zenodo Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/zenodo_download.html This example demonstrates downloading a specific file from a Zenodo archive and reading it with custom parameters. Ensure that the 'read_tsv' function and necessary packages are available in your environment. ```R remap_dorothea <- zenodo_download( zenodo_record = 3713238, zenodo_fname = 'tf_target_sources.zip', path = ( 'tf_target_sources/chip_seq/remap/gene_tf_pairs_genesymbol.txt' ), reader = read_tsv, reader_param = list( col_names = c( 'source_genesymbol', 'target_genesymbol', 'target_ensembl', 'score' ), col_types = cols(), progress = FALSE ), resource = 'ReMap' ) ``` -------------------------------- ### Run NicheNet ligand activity analysis Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_ligand_activities.html This example demonstrates how to use `nichenet_ligand_activities` after preparing the necessary network and expression data. It requires pre-computed `lt_matrix` and `networks` objects, and user-provided transcriptomics data for transmitter and receiver cells, as well as genes of interest. ```R networks <- nichenet_networks() expression <- nichenet_expression_data() optimization_results <- nichenet_optimization(networks, expression) nichenet_model <- nichenet_build_model(optimization_results, networks) lt_matrix <- nichenet_ligand_target_matrix( nichenet_model$weighted_networks, networks$lr_network, nichenet_model$optimized_parameters ) ligand_activities <- nichenet_ligand_activities( ligand_target_matrix = lt_matrix, lr_network = networks$lr_network, # the rest of the parameters should come # from your transcriptomics data: expressed_genes_transmitter = expressed_genes_transmitter, expressed_genes_receiver = expressed_genes_receiver, genes_of_interest = genes_of_interest ) ``` -------------------------------- ### Download LR network from Guide to Pharmacology Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_lr_network_guide2pharma.html Call this function to download the ligand-receptor interaction network from the Guide to Pharmacology database. The output is formatted for NicheNet. ```R g2p_lr_network <- nichenet_lr_network_guide2pharma() ``` -------------------------------- ### Optimize NicheNet parameters Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_optimization.html This example demonstrates how to use the `nichenet_optimization` function. It requires NicheNet formatted networks and expression data. The function returns an object containing the optimal parameter settings. ```R if (FALSE) { networks <- nichenet_networks() expression <- nichenet_expression_data() optimization_results <- nichenet_optimization(networks, expression) } ``` -------------------------------- ### Get organism ID for a resource Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/organism_for.html Use this function to get the organism ID for a specific resource. It handles organism identification by name or NCBI Taxonomy ID. ```r organism_for(10116, 'chalmers-gem') #> [1] "Rat" ``` ```r organism_for(6239, 'chalmers-gem') #> Error in organism_for(6239, "chalmers-gem"): Organism `6239` (common_name: `Caenorhabditis elegans (Nematode, N2)`; common_name: `Caenorhabditis elegans (Nematode, N2)`) is not supported by resource `chalmers-gem`. Supported organisms: Human, Mouse, Rat, Zebrafish, Drosophila melanogaster (Fruit fly), Caenorhabditis elegans (PRJNA13758). # [1] "Worm" ``` -------------------------------- ### Get log file path for a specified package Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_logfile.html Use the `logfile` function to get the path to the log file of a specific R package. Defaults to 'OmnipathR'. ```R logfile(pkg = "OmnipathR") ``` -------------------------------- ### Example Usage of ensembl_id_type Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/uploadlists_id_type.html This example demonstrates the usage of the `ensembl_id_type` function, which is related to identifier type mapping. It shows how to translate an identifier type and the expected output. ```R ensembl_id_type("entrez") #> [1] "entrez" # [1] "GeneID" ``` -------------------------------- ### Run NicheNet Pipeline Source: https://context7.com/saezlab/omnipathr/llms.txt This snippet demonstrates the minimal setup for running the NicheNet pipeline. Ensure you have expressed genes and genes of interest defined. The computation can be intensive and may take several hours. ```r # Minimal example: expressed genes from scRNA-seq data expressed_sender <- c("TGFB1", "VEGFA", "IL6", "CXCL12", "FGF2") expressed_receiver <- c("EGFR", "IL6R", "CXCR4", "FGFR1", "TGFBR1", "MYC", "CDK4", "CDKN1A", "VIM", "SNAI1") genes_of_interest <- c("MYC", "CDK4", "CDKN1A", "VIM", "SNAI1") background_genes <- expressed_receiver # Run pipeline (computationally intensive; may take several hours with full networks) results <- nichenet_main( expressed_genes_transmitter = expressed_sender, expressed_genes_receiver = expressed_receiver, genes_of_interest = genes_of_interest, background_genes = background_genes, n_top_ligands = 20, n_top_targets = 100, # Use only OmniPath (faster, good quality) signaling_network = list(only_omnipath = TRUE), gr_network = list(only_omnipath = TRUE), results_dir = "nichenet_results" ) # Results list elements: # results$networks – prior knowledge networks # results$weighted_networks – resource-weighted networks # results$ligand_target_matrix – ligand → target regulatory potential scores # results$ligand_activities – ranked ligands with Pearson correlation, AUROC head(results$ligand_activities) ``` -------------------------------- ### Load data from cache using URL Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_cache_load.html Loads data from the cache using a URL. This example first saves data to the cache and then loads it back. It demonstrates how to retrieve cached data for inter-cell interactions. ```R url <- paste0( 'https://omnipathdb.org/intercell?resources=Adhesome,Almen2009,', 'Baccin2019,CSPA,CellChatDB&license=academic' ) result <- read.delim(url, sep = '\t') omnipath_cache_save(result, url = url) # works only if you have already this item in the cache intercell_data <- omnipath_cache_load(url = url) class(intercell_data) #> [1] "data.frame" # [1] "data.frame" nrow(intercell_data) #> [1] 17377 # [1] 16622 attr(intercell_data, 'origin') #> [1] "cache" # [1] "cache" ``` -------------------------------- ### Get Complex Resource Names Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/complex_resources.html Call this function to get a character vector containing the names of all available complex resources. The `dataset` argument is ignored for this query type. ```r complex_resources() #> [1] "CFinder" "CORUM" "CellChatDB" "CellPhoneDB" #> [5] "Cellinker" "Compleat" "ComplexPortal" "Guide2Pharma" #> [9] "Havugimana2012" "ICELLNET" "KEGG-MEDICUS" "NetworkBlast" #> [13] "PDB" "SIGNOR" "SPIKE" "hu.MAP" #> [17] "hu.MAP2" ``` -------------------------------- ### Parse OBO file into R data structures Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/obo_parser.html Downloads a generic GO slim OBO file, parses it using obo_parser with tables=FALSE, and then lists the resulting elements. The file is then deleted. ```R goslim_url <- "http://current.geneontology.org/ontology/subsets/goslim_generic.obo" path <- tempfile() httr::GET(goslim_url, httr::write_disk(path, overwrite = TRUE)) # obo <- obo_parser(path, tables = FALSE) unlink(path) # names(obo) # head(obo$relations, n = 2) ``` -------------------------------- ### Initialize OmnipathR and Download Interactions Source: https://github.com/saezlab/omnipathr/blob/master/AGENTS.md Basic workflow to initialize the OmnipathR package and download protein-protein interaction data. Requires the OmnipathR library to be loaded. ```r library(OmnipathR) # Download protein-protein interactions ppi <- import_omnipath_interactions() ``` -------------------------------- ### Get Common Organism Names Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/common_name.html Use this function to get the common English names of organisms. It accepts a vector of organism names or identifiers, which can be mixed types. Returns NA for any input that cannot be found. ```r common_name(c(10090, "cjacchus", "Vicugna pacos")) #> [1] "Mouse" "White-tufted-ear marmoset" #> [3] "Alpaca" # [1] "Mouse" "White-tufted-ear marmoset" "Alpaca" ``` -------------------------------- ### Get UniProt Uploadlists ID Type Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/uploadlists_id_type.html Use this function to get the correct label for an identifier type when performing ID mapping queries with UniProt Uploadlists. It translates common ID type labels into the format expected by UniProt. ```R uploadlists_id_type(label = "entrez") ``` -------------------------------- ### Build NicheNet Model Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/nichenet_build_model.html Demonstrates how to build a NicheNet ligand-target model using the `nichenet_build_model` function. This requires prior steps of obtaining expression data, network data, and performing optimization. ```r if (FALSE) { expression <- nichenet_expression_data() networks <- nichenet_networks() optimization_results <- nichenet_optimization(networks, expression) nichenet_model <- nichenet_build_model(optimization_results, networks) } ``` -------------------------------- ### Print shortest paths between nodes - R Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/print_path_vs.html This example demonstrates how to find and print the shortest path between two nodes ('TYRO3' and 'STAT3') in a network graph derived from SignaLink3 interactions. It first retrieves interactions, builds a graph, finds the shortest path, and then prints it using print_path_vs. ```R interactions <- omnipath(resources = "SignaLink3") OPI_g <- interaction_graph(interactions = interactions) print_path_vs( igraph::all_shortest_paths( OPI_g, from = 'TYRO3', to = 'STAT3' )$vpath, OPI_g ) ``` -------------------------------- ### Implement Slow Doctest for Long-Running Functions Source: https://github.com/saezlab/omnipathr/blob/master/AGENTS.md Example of correctly placing `.slow_doctest()` as the first line within a function body to skip slow examples during R CMD check on build servers. This prevents exceeding time limits. ```r my_function <- function() { .slow_doctest() # ... actual code ... } ``` -------------------------------- ### Load package configuration from a file Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_load_config.html Loads the configuration for the OmnipathR package from a custom YAML file. Ensure the file path is correct and the YAML is properly formatted. This example is conditional and will not run unless explicitly enabled. ```R if (FALSE) { # \dontrun{ # load the config from a custom config file: omnipath_load_config(path = 'my_custom_omnipath_config.yml') } # } ``` -------------------------------- ### Run NicheNet Workflow with nichenet_main Source: https://github.com/saezlab/omnipathr/blob/master/docs/articles/nichenet.html Execute the complete NicheNet workflow, including building prior knowledge and inferring ligand activities. Requires expressed genes in transmitter and receiver cells, and genes of interest. Parameters for individual workflow steps can be overridden. ```R library(OmnipathR) library(nichenetr) nichenet_results <- nichenet_main( expressed_genes_transmitter = expressed_genes_transmitter, expressed_genes_receiver = expressed_genes_receiver, genes_of_interest = genes_of_interest, ``` -------------------------------- ### Report Download as Ready Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_cache_download_ready.html Use this function after a file has been successfully downloaded to update its status in the cache database. It requires the version information obtained from `omnipath_cache_latest_or_new`. ```r bioc_url <- 'https://bioconductor.org/' # request a new version item (or retrieve the latest) new_version <- omnipath_cache_latest_or_new(url = bioc_url) # check if the version item is not a finished download new_version$status #> [1] "unknown" # [1] "unknown" # download the file httr::GET(bioc_url, httr::write_disk(new_version$path, overwrite = TRUE)) #> Response [https://bioconductor.org/] #> Date: 2024-04-07 15:20 #> Status: 200 #> Content-Type: text/html #> Size: 37.3 kB #> /home/denes/.cache/OmnipathR/41346a00fb20d2a9df03aa70cf4d50bf88ab154a-1 # report to the cache database that the download is ready omnipath_cache_download_ready(new_version) # now the status is ready: version <- omnipath_cache_latest_or_new(url = bioc_url) version$status #> [1] "ready" # "ready" version$dl_finished #> [1] "2024-04-07 17:30:27 CEST" # [1] "2021-03-09 16:48:38 CET" omnipath_cache_remove(url = bioc_url) # cleaning up ``` -------------------------------- ### enzsub_resources Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/enzsub_resources.html Get the names of the enzyme-substrate relationship resources available in https://omnipathdb.org/enzsub. ```APIDOC ## enzsub_resources ### Description Retrieves a list of enzyme-substrate relationship resources available in OmniPath. ### Usage enzsub_resources(dataset = NULL) ### Arguments #### dataset Ignored for this query type. ### Value character vector with the names of the enzyme-substrate resources ### Examples enzsub_resources() #> [1] "BEL-Large-Corpus_ProtMapper" "DEPOD" #> [3] "HPRD" "HPRD_MIMP" #> [5] "KEA" "Li2012" #> [7] "MIMP" "NCI-PID_ProtMapper" #> [9] "PhosphoNetworks" "PhosphoSite" #> [11] "PhosphoSite_MIMP" "PhosphoSite_ProtMapper" #> [13] "ProtMapper" "REACH_ProtMapper" #> [15] "RLIMS-P_ProtMapper" "Reactome_ProtMapper" #> [17] "SIGNOR" "SIGNOR_ProtMapper" #> [19] "Sparser_ProtMapper" "dbPTM" #> [21] "phosphoELM" "phosphoELM_MIMP" ``` -------------------------------- ### Retrieve a cache record Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_cache_get.html This example demonstrates how to retrieve a cache record using a URL. It first ensures a record exists (or creates one) using `omnipath_cache_latest_or_new`, then removes it for cleanup, and finally retrieves it using `omnipath_cache_get`. The key and URL of the retrieved record are then printed. ```R bioc_url <- 'https://bioconductor.org/' version <- omnipath_cache_latest_or_new(url = bioc_url) omnipath_cache_remove(url = bioc_url) # cleaning up # retrieve the cache record record <- omnipath_cache_get(url = bioc_url) record$key #> [1] "41346a00fb20d2a9df03aa70cf4d50bf88ab154a" # [1] "41346a00fb20d2a9df03aa70cf4d50bf88ab154a" record$url #> [1] "https://bioconductor.org/" # [1] "https://bioconductor.org/" ``` -------------------------------- ### Load OmnipathR Package Source: https://github.com/saezlab/omnipathr/blob/master/README.md Loads the OmnipathR library. Ensure the package is installed before running. ```r library(OmnipathR) ``` -------------------------------- ### Download and process HMDB metabolites table Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/hmdb_table.html This example demonstrates the default usage of `hmdb_table` to download and process the 'metabolites' dataset. It extracts all available fields by default. ```r hmdb_table() #> # A tibble: 217,920 × 33 #> accession name version status description chemical_formula #> #> 1 HMDB0000001 1-Methylhistidine 5.0 quant… "1-Methylh… C7H11N3O2 #> 2 HMDB0000002 1,3-Diaminopropane 5.0 quant… "1,3-Diami… C3H10N2 #> 3 HMDB0000005 2-Ketobutyric acid 5.0 quant… "2-Ketobut… C4H6O3 #> 4 HMDB0000008 2-Hydroxybutyric acid 5.0 quant… "2-Hydroxy… C4H8O3 #> 5 HMDB0000010 2-Methoxyestrone 5.0 quant… "2-Methoxy… C19H24O3 #> 6 HMDB0000011 3-Hydroxybutyric acid 5.0 quant… "3-Hydroxy… C4H8O3 #> 7 HMDB0000012 Deoxyuridine 5.0 quant… "Deoxyurid… C9H12N2O5 #> 8 HMDB0000014 Deoxycytidine 5.0 quant… "Deoxycyti… C9H13N3O4 #> 9 HMDB0000015 Cortexolone 5.0 quant… "Cortexolo… C21H30O4 #> 10 HMDB0000016 Deoxycorticosterone 5.0 quant… "11-Deoxyc… C21H30O3 #> # ℹ 217,910 more rows #> # ℹ 27 more variables: #> # average_molecular_weight , #> # monisotopic_molecular_weight , #> # iupac_name , #> # traditional_iupac , #> # cas_registry_number , #> # smiles , #> # inchi , #> # inchikey , #> # state , #> # synthesis_reference , #> # chemspider_id , #> # drugbank_id , #> # foodb_id , #> # pubchem_compound_id , #> # pdb_id , #> # chebi_id , … ``` -------------------------------- ### omnipath_get_config_path Source: https://github.com/saezlab/omnipathr/blob/master/docs/reference/omnipath_get_config_path.html Gets the current config file path. It can optionally prioritize the user-level config. ```APIDOC ## omnipath_get_config_path ### Description Gets the current config file path. It can optionally prioritize the user-level config. ### Usage ```R omnipath_get_config_path(user = FALSE) ``` ### Arguments * **user** (Logical): Prioritize the user level config even if a config in the current working directory is available. ### Value Character: path to the config file. ### Examples ```R omnipath_get_config_path() #> [1] "~/.config/OmnipathR/omnipathr.yml" ``` ```