roc: Plot ROC or precision-recall curves

View source: R/network-benchmark.R

rocR Documentation

Plot ROC or precision-recall curves

Description

Plot one or more network member-recovery benchmarks. ROC mode reports normalized specificity and sensitivity. max_p truncates curves at a threshold specified by a one-sided enrichment p-value. Precision-recall mode reports recall and precision as proportions, uses precision 1 before the first positive prediction, and shows the class prevalence as its no-skill baseline.

Usage

roc(
  tpvsfp,
  mode = "roc",
  max_p = 1,
  coff_z = NULL,
  cex_main = 1,
  cex_leg = 0.75,
  main = NULL,
  use_lty = FALSE,
  print_stats = TRUE,
  sort_by_letter_and_remove = FALSE
)

Arguments

tpvsfp

Prediction list from nea_member_recovery_benchmark(), or a named list of them.

mode

Plot coordinates. Supported values are "roc" (an alias for "specificity_vs_sensitivity"), "prc" (an alias for "sensitivity_vs_tdp"), "recall_vs_tdp", "f1_vs_tdp", "tdp_vs_mcc", "sensitivity_vs_f1", and "sensitivity_vs_mcc".

max_p

Maximum one-sided enrichment p-value shown in ROC mode. The default, 1, retains the complete curve.

coff_z

Deprecated direct cutoff for the NEA z-score. It remains available when max_p is not supplied; supplying both explicitly is an error.

cex_main, cex_leg

Text sizes for title and legend.

main

Plot title.

use_lty

Use varying line types. For more than six curves, colors cycle through a six-color palette before line types 1, 2, and 3 cycle.

print_stats

Show node and edge counts. Counts shared by all curves are printed once below the main title; differing counts appear in the legend.

sort_by_letter_and_remove

Remove a leading letter-and-colon prefix.

Details

Curves and their colors are ordered alphabetically by their displayed labels. A prediction element may contain scalar col and lty fields to override its automatically assigned style. Differing network sizes are appended on the same legend line for labels of at most 24 characters. Longer labels put the sizes on a second line and use slightly smaller legend text. Common sizes are printed once below the title, which is useful when curves compare renderers on the same network. When benchmark marker thresholds are available, a top-left legend identifies the circle as p and the cross as FDR.

OR (odds ratio), shown next to each network name in the legend when mark_fdr is not NULL and returned as odds_ratio, is calculated as sensitivity / (1 - specificity) (Merid et al., 2014), i.e. sensitivity divided by the false-positive rate at the cutoff selected by mark_fdr. Both sensitivity and the false-positive rate must be non-zero; otherwise OR is NA. With equally sized positive and negative gene sets, a higher OR at a fixed mark_fdr indicates a lower false-positive rate for a given sensitivity. This is not the cross-product odds ratio of a 2 by 2 contingency table. The returned column contains the same ratio at every displayed cutoff so that the marked value can be inspected directly.

Value

Invisibly, an alphabetically named list of data frames containing the x coordinate, y coordinate, score cutoff, and Merid-style odds_ratio used for every displayed curve. ROC coordinates are specificity and sensitivity; precision-recall coordinates are recall and true discovery proportion.

References

Merid SK, Goranskaya D, Alexeyenko A (2014). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/1471-2105-15-308")}.

See Also

nea_member_recovery_benchmark()

Examples

net <- igraph::graph_from_edgelist(matrix(c(
  "b", "c", "b", "d", "e", "f", "a", "g", "f", "g",
  "b", "h", "d", "h", "c", "i", "a", "j", "b", "j",
  "e", "j", "h", "k", "c", "l"
), ncol = 2, byrow = TRUE), directed = FALSE)
prediction <- nea_member_recovery_benchmark(net,
  list(pathway = c("a", "b", "c", "d", "g")),
  seed = 7, verbose = FALSE)
curves <- roc(list(example_network = prediction), mode = "roc")
curves$example_network

NEArender documentation built on Nov. 28, 2026, 5:10 p.m.