View source: R/import-network-matrix.R
| import_network | R Documentation |
Read a global undirected network from a tabular edge list, import a square
adjacency matrix, or normalize a supported network object. Reciprocal and
duplicate edges are collapsed and self-links are removed. When scored
duplicate rows disagree, a warning reports their count and examples. The
highest edge score is retained, or the highest absolute score when an
absolute-value selector is used. The selected source edge-score column
becomes the single canonical igraph weight attribute or
adjacency-aligned legacy weights. In a user-supplied scored table, a source
score of zero is interpreted as no edge and skipped. Existing network
objects and curated adapters preserve zero edge weights.
import_network(
source,
from_column = 1L,
to_column = 2L,
score_column = NULL,
min_score = NULL,
n_top = NULL,
greedy = TRUE,
header = FALSE,
sep = "\t",
comment_char = "",
case_sensitive = FALSE,
verbose = TRUE,
output_network_format = c("igraph", "sparse", "legacy"),
species,
input_id_format = master_id_format(species),
id_mappings = NULL,
ambiguous = c("error", "drop", "first", "expand"),
unmapped = c("keep", "drop", "error"),
is_matrix = FALSE,
min_abs_score = NULL,
n_abs_top = NULL
)
source |
File path, URL, connection, matrix, data frame, or supported network object. |
from_column, to_column |
Names or one-based indices of edge endpoint columns. |
score_column |
Optional name or one-based index of the source edge
score column. Its numeric values are stored as edge weights. If |
min_score |
Optional minimum retained edge score. |
n_top |
Optional number of highest-scoring unique edges to retain. |
greedy |
Boundary-tie policy used with |
header |
Whether a text source has a header row. Ignored for a matrix or data frame. |
sep |
Field separator used for text sources. Ignored for a matrix or data frame. |
comment_char |
Comment marker used for text sources. The default disables comment processing. Ignored for a matrix or data frame. |
case_sensitive |
Preserve case when matching node identifiers. |
verbose |
Report the imported node and edge counts. |
output_network_format |
Return an igraph, sparse, or legacy NEArender network. |
species |
Required species identifier. Accepts any scientific/common
name, package species ID, three-letter KEGG style organism ID, or
taxonomy ID listed by |
input_id_format |
Submitted identifier format. Defaults to
|
id_mappings |
Optional object from |
ambiguous, unmapped |
Mapping policies passed to |
is_matrix |
Treat |
min_abs_score |
Optional minimum retained absolute edge score. This is useful for signed adjacency matrices such as correlation matrices. The signed value is preserved as the edge weight. |
n_abs_top |
Optional number of unique edges with the highest absolute
scores to retain. Signed edge weights are preserved. The |
An edge weight is stored metadata; it is not automatically a
transition probability. Renderers such as rwr.render() and
pagerank.render() use topology alone unless use_edge_weights = TRUE.
A transition probability is derived, when requested, by normalizing the
non-negative outgoing edge weights.
NEArender does not create directed networks. With is_matrix = TRUE,
source must therefore be a symmetric adjacency matrix. Asymmetric
matrices are rejected rather than interpreted as directed networks.
For dense matrices, edge-score filtering is applied while the matrix is
scanned, so excluded cells are never materialized as edge rows. Top-N
selection uses bounded chunks to determine its score boundary first.
After a matrix import, temporary edge tables are collected. On Linux
systems using glibc, free allocator pages are also returned to the
operating system so repeated imports do not retain their peak RSS.
Pathway Commons aggregates interaction evidence from multiple curated
resources and records supporting publications for most edges. The
catalogued pathwaycommons_hgnc adapter derives a PubMed-count edge
score: the number of distinct supporting publications plus a 0.5
pseudocount. Relations without a linked PubMed record therefore remain
edges with weight 0.5. With load_network_database(),
min_score = 1.5 requires at least one publication and
min_score = 2.5 requires at least two.
A checked and normalized undirected igraph object by default, a
sparse network, or a named-adjacency-list network. Weighted igraph output
has one numeric weight edge attribute; sparse output stores binary
adjacency separately from weights; legacy output stores named
adjacency-aligned weights. Identifier and repair metadata are available
through normalization_info().
available_databases(), load_network_database(), read_network(),
export_network(), convert_network()
edges <- data.frame(from = c("A", "B", "B"), to = c("B", "A", "C"),
score = c(0.8, 0.9, 0.7))
import_network(edges, "from", "to", "score", verbose = FALSE,
species = "human")
correlation <- matrix(c(0, 0.8, -0.4, 0.8, 0, 0.2, -0.4, 0.2, 0),
nrow = 3, dimnames = list(c("A", "B", "C"), c("A", "B", "C")))
import_network(correlation, is_matrix = TRUE, min_abs_score = 0.4,
verbose = FALSE, species = NULL, input_id_format = "custom")
import_network(correlation, is_matrix = TRUE, n_abs_top = 2,
greedy = NULL, verbose = FALSE, species = NULL,
input_id_format = "custom")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.