API

Import NetworkCommons as:

import networkcommons as nc

Methods

MOON

methods.prepare_metab_inputs(metab_input, ...)

Prepares the metabolite inputs by adding compartment codes.

methods.is_expressed(x, expressed_genes_entrez)

Determines if a gene is expressed based on the given criteria.

methods.filter_pkn_expressed_genes(...)

Filters out unexpressed nodes from the prior knowledge network (PKN).

methods.filter_input_nodes_not_in_pkn(data, pkn)

Filters the input nodes in the 'data' dictionary that are not present in the PKN.

methods.keep_controllable_neighbours(...)

This function filters out nodes from a dictionary of source nodes that are not controllable from the graph.

methods.keep_observable_neighbours(...)

This function filters out nodes from a dictionary of target nodes that are not observable from the graph.

methods.compress_same_children(...)

Compresses nodes in the graph that have the same children by relabeling them with a common signature.

methods.run_moon_core([upstream_input, ...])

Runs the MOON algorithm to iteratively infer MOON scores from downstream nodes.

methods.filter_incoherent_TF_target(...)

Filters incoherent TF-target interactions from the meta_network based on the given inputs.

methods.decompress_moon_result(moon_res, ...)

Decompresses the moon_res dataframe by mapping the compressed nodes to their corresponding original source using the provided meta_network_compressed_list and the filtered meta_network.

methods.reduce_solution_network(moon_res, ...)

Reduces the solution network based on MOON score cutoffs and returns the reduced network and attribute table.

methods.translate_res(untranslated_network, ...)

Translates the network and attribute table based on the given mapping dataframe.

Topological methods

methods.run_shortest_paths(network, ...[, ...])

Calculate the shortest paths between sources and targets.

methods.run_sign_consistency(network, paths, ...)

Calculate the sign consistency between sources and targets.

methods.run_reachability_filter(network, ...)

Filters out all nodes from the graph which cannot be reached from

methods.run_all_paths(network, source_dict, ...)

Calculate all paths between sources and targets.

methods.compute_all_paths(network, source, ...)

Compute all paths between source and targets.

Random Walk with Restart

methods.add_pagerank_scores(network, ...[, ...])

Add PageRank scores to the nodes of the network.

methods.compute_ppr_overlap(network[, ...])

Compute the overlap of nodes that exceed the personalized PageRank

CORNETO

methods.run_corneto_carnival(network, ...[, ...])

Run the Vanilla Carnival algorithm via CORNETO.

SignalingProfiler

methods.run_signalingprofiler(sources, ...)

Contextualize networks by the SignalingProfiler algorithm.

Prior Knowledge

data.network.get_omnipath([genesymbols, ...])

Retrieves the Omnipath network with directed interactions and specific criteria.

data.network.get_lianaplus([resource, update])

Retrieves the metabolic network used in COSMOS from the server

data.network.get_phosphositeplus([update])

Retrieves the PhosphoSitePlus network from the server

data.network.get_cosmos_pkn([update])

Retrieves the metabolic network used in COSMOS from the server

Datasets

Utils

data.omics.datasets()

Built-in omics datasets.

data.omics.deseq2(counts, metadata, ...[, ...])

Runs DESeq2 analysis on the given counts and metadata.

data.omics.get_ensembl_mappings([update])

Retrieves the mapping between Ensembl attributes for human genes.

data.omics.convert_ensembl_to_gene_symbol(...)

Converts Ensembl IDs to gene symbols using an equivalence dataframe, handles partial matches, and summarizes duplicated entries by taking the maximum value.

DecryptM

data.omics.decryptm_datasets([update])

Table of all DecryptM datasets.

data.omics.decryptm_table(experiment, ...)

One table of omics data from DecryptM.

data.omics.decryptm_experiment(experiment[, ...])

Tables from one DecrptM experiment of one omics modality.

PANACEA

data.omics.panacea_experiments([update])

Table describing the experiments (drug-cell combinations) contained in the Panacea dataset and merging it with the presence of TF_scores.

data.omics.panacea_datatypes()

Table describing the available data types in the Panacea dataset.

data.omics.panacea_tables([cell_line, drug, ...])

One table of countdata and one table of metadata from Panacea if raw data is selected.

data.omics.panacea_gold_standard([update])

Retrieves the gold standard (primary targets and offtargets linked to drugs) used in Panacea from the server.

scPerturb

data.omics.scperturb(dataset)

Access an scPerturb dataset.

data.omics.scperturb_metadata()

Metadata for the scPerturb deposited datasets.

data.omics.scperturb_datasets()

List the datasets available in scPerturb.

CPTAC

data.omics.cptac_cohortsize([update])

Table describing the number of tumor and normal samples per CPTAC cancer type.

data.omics.cptac_fileinfo([update])

Table describing the files contained in the CPTAC dataset.

data.omics.cptac_table(data_type, ...)

One table of omics data from CPTAC.

data.omics.cptac_datatypes()

List describing the data types available in the CPTAC dataset.

data.omics.cptac_extend_dataframe(df)

Extends the DataFrame by duplicating rows based on Tumor and Normal columns.

NCI60

data.omics.nci60_datasets([update])

Table of all NCI60 datasets (cell types).

data.omics.nci60_datatypes()

Table of all NCI60 data types.

data.omics.nci60_table(cell_line, data_type)

One table of omics data from NCI60.

Phospho-EGF meta-analysis

data.omics.phospho_egf_datatypes()

Table describing the available data types in the Phospho EGF dataset.

data.omics.phospho_egf_tables([type])

A table with the corresponding data type for the phospho EGF dataset.

Evaluation and description

eval.get_number_nodes(network)

Get the number of nodes in the network.

eval.get_number_edges(network)

Get the number of edges in the network.

eval.get_mean_degree(network)

Get the mean degree centrality of the network.

eval.get_mean_betweenness(network)

Get the mean betweenness centrality of the network.

eval.get_mean_closeness(network)

Get the mean closeness centrality of the network.

eval.get_connected_targets(network, target_dict)

Get the number of connected targets in the network.

eval.get_recovered_offtargets(network, ...)

Get the number of off-targets recovered by the network.

eval.get_graph_metrics(network, target_dict)

Get the graph metrics of a network.

eval.get_metric_from_networks(networks, ...)

Get the graph metrics of multiple networks.

eval.get_ec50_evaluation(network, ec50_dict)

Get the EC50 evaluation of a network.

eval.run_ora(graph, net[, metric, ascending])

Run over-representation analysis on a custom set of genes.

eval.get_phosphorylation_status(network, ...)

Calculates the phosphorylation status metrics for a given network and dataframe.

eval.perform_random_controls(graph, ...[, ...])

Performs random controls of a network by shuffling node labels and running the inference function.

eval.shuffle_dict_keys(dictionary, items)

Shuffle the keys of a dictionary.

Visualization

visual.NetworkXVisualizer(network[, color_by])

An advanced visualizer that extends NetworkVisualizerBase with additional features.

visual.YFilesVisualizer(network)

A class for visualizing network graphs interactively using the yFiles HTML widget.

visual.get_styles()

Return a dictionary containing styles for different types of networks specific to yFiles visualizations.

visual.set_style_attributes(item, base_style)

Set attributes for a graph item (node or edge) based on the given styles.

visual.merge_styles(default_style, custom_style)

Merge custom styles with default styles to ensure all necessary fields are present.

visual.get_comparison_color(category, styles)

Get the color for nodes or edges based on the comparison category.

visual.get_edge_color(effect, styles)

Get the color for an edge based on its effect.

visual.update_node_property(node[, type, value])

visual.update_edge_property(edge[, type, value])

visual.apply_node_style(node, style)

Apply the given style to a node.

visual.apply_edge_style(edge, style)

Apply the given style to an edge.

visual.build_volcano_plot(data[, log2fc, ...])

visual.build_ma_plot(data, log2fc, mean_exp)

visual.plot_pca(dataframe, metadata[, ...])

Plots the PCA (Principal Component Analysis) of a dataframe.

visual.build_heatmap_with_tree(distance_df)

Build a heatmap with hierarchical clustering based on a Jaccard distance matrix.

visual.lollipop_plot(df, label_col, value_col)

Function to plot metrics using a lollipop plot from a DataFrame.

visual.create_heatmap(results[, terms, ...])

Create a heatmap.

visual.plot_density(df, gene_ids[, ...])

Plots density of intensity values for specified genes, including mean and quantile lines, and separates distributions by groups if metadata is provided.

visual.plot_scatter(df[, summarise_df, ...])

Plot a scatter plot with customizable column labels.

visual.plot_rank(df[, bio_ids, figsize, ...])

Plot a protein abundance rank plot.

Utilities

utils.to_cornetograph(graph)

Convert a networkx graph to a corneto graph, if needed.

utils.to_networkx(graph[, ...])

Convert a corneto graph to a networkx graph, if needed.

utils.read_network_from_file(file_path[, ...])

Read network from a file.

utils.network_from_df(network_df[, ...])

Create a network from a DataFrame.

utils.get_subnetwork(network, paths)

Creates a subnetwork from a list of paths.

utils.decoupler_formatter(df, columns)

Format dataframe to be used by decoupler.

utils.targetlayer_formatter(df[, ...])

Format dataframe to be used by the network methods.

utils.handle_missing_values(df[, threshold, ...])

Handles missing values in a DataFrame by filling them with a specified function or value, or dropping the rows.

utils.subset_df_with_nodes(network, dataframe)

Subsets a dataframe using the nodes of a network as the index.

utils.node_attrs_from_corneto(graph)

Extract node attributes from a corneto graph to a pandas dataframe.

utils.edge_attrs_from_corneto(graph)

Extract edge attributes from a corneto graph to a pandas dataframe.