Converts a pubtator_context result into a relation network: graph-ready nodes and edges, plus a lean evidence table that maps each edge back to the PubTator relation row and, when the endpoint mentions share a sentence, the supporting sentence.

pubtator_network(x)

Arguments

x

A list returned by pubtator_context, with entities, relations, and sentences data.tables.

Value

A named list with three data.tables:

nodes

One row per normalized relation endpoint. Columns: id, type, label, n_mentions, and n_pmids. Entity identifiers are used when present; otherwise nodes fall back to type:text.

edges

One row per directed PubTator relation edge. Columns: from, to, relation_type, weight, n_pmids, and n_sentences.

evidence

One row per PubTator relation row. Columns: from, to, relation_type, pmid, relation_id, same_sentence, sentence_distance, and sentence. The sentence is populated only when the relation endpoints share a sentence.

Examples

if (FALSE) { # \dontrun{
pmids <- search_pubmed('"doxorubicin"[TiAb] AND "cardiotoxicity"[TiAb]')

ctx <- pmids |>
  get_records(endpoint = "pubtator") |>
  pubtator_context()

net <- pubtator_network(ctx)
net$nodes
net$edges
net$evidence
} # }