A biological network: HMP/U01

This graph summarizes similarities among HMP+U01 16S amplicon samples. The supplied object records a representation based on taxa at at least 1% relative abundance followed by principal component analysis, and a nearest-neighbor construction with k=3. Coarsening reduces the original giant component to 1,828 vertices and 4,656 weighted edges.

The biological labels are community state types (CSTs) and finer subtypes. Use them to interpret groups in the drawing; separated colors do not by themselves establish that the geometry is accurate.

Inspect the graph

data(hmp.u01.gc.coarse)
g <- hmp.u01.gc.coarse
knitr::kable(data.frame(Quantity=c('Original giant-component vertices',
  'Coarsened vertices','Undirected edges','Selected k'),
  Value=unlist(g$graph_info[c('original_vertices','coarse_vertices','edge_count','selected_k')],use.names=FALSE)))
Quantity Value
Original giant-component vertices 6474
Coarsened vertices 1828
Undirected edges 4656
Selected k 3

The original giant component has 6,474 vertices. Seven other components were discarded in the recorded preparation; no claim is made here about their arrangement. This coarsened weighted HMP/U01 object differs from the unweighted HMP graph in the external-engine comparison.

Compare three layouts

The selector opens with SGD metric MDS, followed by weighted GRIP (metric="edge_length") and hop-based GRIP. The SGD and weighted-GRIP fits use the same coarsened graph, positive edge lengths, three dimensions and seed 1. SGD uses full weighted graph distances, uniform pair weights, a random start and a 200-iteration budget, without edge-KK refinement. Weighted GRIP uses its edge-length hierarchy and default optimization settings. This is a one-seed illustration, not a controlled method-ranking experiment.

Hop-based GRIP uses supplied edge lengths for adjacent attractions and hop distances for hierarchy searches. The selector shows its default preset with seed 1. The preset comparison below also includes tree and torus settings.

HMP/U01: select a layout; CST colors are identical across layouts. Drag to rotate; scroll to zoom. Display only: each layout is centered and scaled to unit RMS radius; saved fits and scores are unchanged.

Rotation helps distinguish actual branches from overlaps in projection. Coordinates are centered and uniformly rescaled to the same root-mean-square radius for display, so each method is visible despite its different fitted scale. Shapes and orientations are preserved, with common bounds and an unchanged camera when switching. CST colors remain fixed. Saved coordinates and diagnostics are unchanged; this display does not compare absolute scale or align layouts to a biological reference.

Fit status

knitr::kable(fresh$sgd$value$metadata$starts,digits=4)
start initialization initial_raw_stress raw_stress normalized_stress iterations converged termination backend_stress warnings error elapsed_seconds native_seed pair_updates best_epoch
1 random 1878328 100509.5 0.0149 200 FALSE iteration_limit 24913.1 161.216 1209877091 333975600 200
knitr::kable(data.frame(Method=c("SGD metric MDS","Weighted GRIP"),
  Seconds=c(fresh$sgd$elapsed_seconds,fresh$weighted_grip$elapsed_seconds)),digits=2)
Method Seconds
SGD metric MDS 184.82
Weighted GRIP 2.36

An iteration limit means that SGD returned coordinates without meeting its stopping criterion. Weighted GRIP uses a fixed optimization schedule; returning a layout is not a convergence claim. The scores below describe the hop-based preset candidates; they do not score the SGD or weighted-GRIP fits.

Compare the recorded candidates

knitr::kable(results$preset_summary[,c('candidate','sampled.stress.mean',
  'edge.length.cv.mean','cluster.separation.mean','score.composite')],digits=3)
candidate sampled.stress.mean edge.length.cv.mean cluster.separation.mean score.composite
default 0.407 0.734 2.310 0.062
torus 0.461 0.962 3.401 0.625
tree 0.490 1.097 3.706 0.812

Stress describes graph-distance agreement; cluster separation describes the CST labels. Their priorities may differ. This saved search has one seed per candidate, so it does not measure variation over random starts.

The recorded local search varied final refinement rounds and repulsion near the selected settings. Its full summaries and individual outcomes are retained in results$local_search_summary and results$local_search_runs.

knitr::kable(results$local_search_summary[,c('candidate','final.rounds',
  'repulsion.factor','sampled.stress.mean','cluster.separation.mean')],digits=3)
candidate final.rounds repulsion.factor sampled.stress.mean cluster.separation.mean
hmp.local.final_rounds.224.repulsion_factor.125 224 1.25 0.507 3.820
hmp.local.final_rounds.288.repulsion_factor.125 288 1.25 0.506 3.763
hmp.local.final_rounds.224.repulsion_factor.075 224 0.75 0.509 3.846
hmp.local.final_rounds.288.repulsion_factor.075 288 0.75 0.510 3.785

Reproduce the weighted fits

Start with SGD metric MDS for a new weighted graph-distance fit. The edge-length GRIP alternative used in the selector is shown below. This recipe uses edge-length distances; the preset tables above use hop-based GRIP.

mds <- metric.mds(adj.list=g$adj_list,weight.list=g$weight_list,
  n=length(g$adj_list),dim=3,backend='sgd',init='random',seed=1,
  max.iter=200,pair.weights='uniform',diagnostics=FALSE)
coords <- grip(adj.list=g$adj_list,weight.list=g$weight_list,
  n=length(g$adj_list),dim=3,metric='edge_length',seed=1)
score.layout(coords,adj.list=g$adj_list,weight.list=g$weight_list,
  n=length(g$adj_list),clusters=g$vertex_data$cst,edge.crossings='never')

See weighted layouts for the metric semantics and Choosing and evaluating for repeated seeds and candidate selection.

Data and coarsening record

The object contains adj_list, parallel weight_list, vertex_data, and graph_info. The vertex metadata includes aggregated CST and subtype labels. The recorded coarsening rounds are:

knitr::kable(g$graph_info$coarsening_rounds)
round n_old n_new
1 6474 3449
2 3449 1828

Saved results reside in extdata/hmp_u01_gc_coarse/vignette_results.rds in the installed package. They include candidate settings, scores, fitted coordinates, and the software session. To run the hop-based preset comparison into a separate file, explicitly set the output path before sourcing its script:

Sys.setenv(GRIP_HMP_RESULTS_OUTPUT='fresh-hmp-results.rds')
source(system.file('scripts','precompute-hmp-results.R',package='grip'))

That script reproduces its documented hop-based workflow; it does not rerun the weighted recipe above. Use separate output files for each comparison.

The SGD and weighted-GRIP fits are stored in weighted_layouts.rds, with settings, warnings, runtimes, source/data checksums and session information. Reproduce them from the source checkout with Rscript inst/scripts/precompute-hmp-layout-selector.R. This does not overwrite the hop-based preset comparison.