Skip to contents

Plot One Neighborhood

Usage

plot_one_neighborhood(
  napistu_list,
  vertices,
  edges,
  reaction_sources,
  sc_id,
  sc_name,
  score_overlay = NULL,
  score_label = NULL,
  score_palette = NULL,
  join_scores_on = "s_id",
  max_labeled_species = 30L,
  network_layout = "fr",
  edge_weights = NULL,
  edge_width = 0.5
)

Arguments

napistu_list

A list containing loaded assets and bindings to Python modules.

sbml_dfs

SBML_dfs - the core pathway representation of the Napistu Python library

napistu_graph

Network graph - a Python igraph subclass with Napistu-specific attributes and methods

species_identifiers

Species identifier mappings

precomputed_distances

optional, distances between species nodes

species_names

A tibble containing the names of all genes, proteins, molecules, etc

identifiers_nest

A tibble with one row per ontology and a nested tibble containing all the identifiers and their corresponding molecular species

python_modules

A named list of Python modules: `napistu`

python_environment

See validate_python_environment

napistu_config

A `napistu_config` object dictating how the `napistu_list` was initialized

loaded_at

A date-time object indicating when `napistu_list` was initialized

vertices

table of species and reactions, produced by create_neighborhood_table

edges

table of connections between species and reactions, produced by create_neighborhood_table

reaction_sources

table describing the model(s) each reaction comes from, produced by create_neighborhood_table

sc_id

compartmentalized species identifier of focal node

sc_name

name of focal node

score_overlay

optional, vertex-level scores containing `score` and the merging attribute specified in `join_on`

score_label

optional, name of disease being overlaid

score_palette

optional, color palette for scores

join_scores_on

attribute to use when merging score_overlays and vertices

max_labeled_species

maximum number of species to label (to avoid overplotting)

network_layout

method to used for creating a network layout (e.g., `fr`, `kk`, `drl`)

edge_weights

Numeric vector of edge weights, character string naming an edge attribute, NULL to use graph's "weight" attribute, or NA to explicitly use no weights

edge_width

width of edges on graph

Value

a ggplot2 grob

Examples

suppressPackageStartupMessages(library(dplyr))
setup_napistu_list(create_napistu_config())
#> 
#> ── Setting up Napistu environment ──────────────────────────────────────────────
#> No Python configuration specified, setting up conda environment
#> Using existing conda environment "napistu-env"
#> Python version 3.11 meets requirements
#> No assets configuration specified, loading bundled package data
#>  Creating derived assets
#>  Creating a table of species names to support lookups by name
#>  Loading sbml_dfs from sbml_dfs.pkl
#> Error in value[[3L]](cond): Failed to load sbml_dfs from
#> /home/runner/work/_temp/Library/napistu.r/extdata/test_pathway/sbml_dfs.pkl:
#> ImportError: /usr/lib/x86_64-linux-gnu/libcrypto.so.3: version `OPENSSL_3.3.0'
#> not found (required by
#> /usr/share/miniconda/envs/napistu-env/lib/python3.11/lib-dynload/_ssl.cpython-311-x86_64-linux-gnu.so)
#> Run `reticulate::py_last_error()` for details.
species_id <- random_species(napistu_list)
#> Error: object 'napistu_list' not found

neighborhood_table <- create_neighborhood_table(
    napistu_list,
    species_id,
    network_type = "hourglass",
    max_neighbors = 30L,
    max_steps = 15L
)
#> Error: object 'napistu_list' not found

entry <- 1
vertices <- neighborhood_table$vertices[[entry]]
#> Error: object 'neighborhood_table' not found
edges <- neighborhood_table$edges[[entry]]
#> Error: object 'neighborhood_table' not found
reaction_sources <- neighborhood_table$reaction_sources[[entry]]
#> Error: object 'neighborhood_table' not found
sc_id <- neighborhood_table$sc_id[entry]
#> Error: object 'neighborhood_table' not found
sc_name <- neighborhood_table$sc_name[entry]
#> Error: object 'neighborhood_table' not found

score_overlay <- vertices %>%
    dplyr::filter(node_type == "species") %>%
    dplyr::distinct(s_id) %>%
    dplyr::sample_frac(0.5) %>%
    dplyr::mutate(score = stats::rnorm(dplyr::n()))
#> Error: object 'vertices' not found

# score_overlay <- summarize_indication(
#   napistu_list,
#   disease_id = "EFO_0000400",
#   create_neighborhood_summary_table(neighborhood_table)
#   )

plot_one_neighborhood(
    napistu_list,
    vertices,
    edges,
    reaction_sources,
    sc_id,
    sc_name,
    score_overlay = NULL
)
#> Error: object 'napistu_list' not found

plot_one_neighborhood(
    napistu_list,
    vertices,
    edges,
    reaction_sources,
    sc_id,
    sc_name,
    score_overlay = score_overlay,
    score_palette = "log2 fold-change"
)
#> Error: object 'napistu_list' not found