Skip to content

feat: v14.0 citation audit filters + network node sizing (#135, #145)#168

Merged
seanthimons merged 4 commits intomainfrom
v14-citation-network-evolution
Mar 20, 2026
Merged

feat: v14.0 citation audit filters + network node sizing (#135, #145)#168
seanthimons merged 4 commits intomainfrom
v14-citation-network-evolution

Conversation

@seanthimons
Copy link
Copy Markdown
Owner

Summary

Test plan

  • 170 lines of new unit tests for node sizing calculations (test-citation-network.R)
  • Verify citation audit table sorting/filtering works with real data
  • Verify network graph node sizes update when switching metric dropdown
  • Confirm FWCI migration runs cleanly on existing databases

Closes #135, closes #145

#145 — Citation audit filters and controls:
- Add FWCI column to citation_audit_results (migration 011)
- Carry FWCI through enrich_ranked_with_metadata pipeline
- ASC/DESC sort toggle, FWCI as 4th sort option
- Year range, min citations, min FWCI, min frequency filters
- FWCI column in results table with color-coded values

#135 — Changing citation size by new calculation metric:
- Capture FWCI in network node data (seed, discovered, all frames)
- New get_sizing_metric() with 4 modes: citations, age-weighted,
  FWCI, connectivity (degree)
- Sizing dropdown in network controls, live re-size via proxy
- FWCI shown in node tooltips when available

23 new unit tests for compute_node_sizes, get_sizing_metric,
and enrich_ranked_with_metadata FWCI handling.
Copilot AI review requested due to automatic review settings March 19, 2026 17:30
@seanthimons seanthimons changed the title feat: citation audit filters + network node sizing (#135, #145) feat: v14.0 citation audit filters + network node sizing (#135, #145) Mar 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds citation audit sorting/filtering controls and expands citation-network node sizing options, while propagating FWCI through the audit + network pipelines to support FWCI-based UI features.

Changes:

  • Add FWCI support end-to-end: DB schema/migration, audit enrichment, and network node/tooltips.
  • Add citation audit UI controls for sort direction + filters (year range, min citations, min FWCI, min frequency).
  • Add network node sizing modes (citations / age-weighted / FWCI / connectivity) with live resizing + new unit tests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/testthat/test-citation-network.R New unit tests for node sizing + sizing-metric selection + FWCI propagation in audit enrichment.
migrations/011_add_fwci_to_audit_results.sql Migration intended to add fwci column to citation_audit_results.
R/db.R Adds fwci column to citation_audit_results schema + persists FWCI when saving audit results.
R/citation_audit.R Ensures fwci is included when enriching ranked audit results with metadata.
R/mod_citation_audit.R Adds sorting direction + filtering UI and logic, plus optional FWCI column display.
R/citation_network.R Adds FWCI to network node data, introduces sizing-metric helper, supports FWCI tooltip line.
R/mod_citation_network.R Adds sizing dropdown UI and observer to live-update node sizes via proxy updates.
README.md Documents node sizing modes and audit filters; updates file tree to mention audit modules.
TODO.md Marks issues #135 and #145 as completed and adds them to the completed list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

}
}
# Min collection frequency filter
if (!is.null(input$min_frequency) && input$min_frequency > 2) {
Comment on lines +454 to +471
has_fwci_data <- "fwci" %in% names(results) && any(!is.na(results$fwci))

# Compute year bounds for filter
all_results <- audit_results()
valid_years <- all_results$year[!is.na(all_results$year)]
yr_bounds <- if (length(valid_years) > 0) {
c(min(valid_years), max(valid_years))
} else {
c(1900L, as.integer(format(Sys.Date(), "%Y")))
}

# Sort choices — include FWCI only if data exists
sort_choices <- c("Collection Frequency" = "collection_frequency",
"Global Citations" = "cited_by_count",
"Year" = "year")
if (has_fwci_data) {
sort_choices <- c(sort_choices, "FWCI" = "fwci")
}
"collection_frequency" = results[order(results$collection_frequency, decreasing = sort_desc), ],
"cited_by_count" = results[order(results$cited_by_count, decreasing = sort_desc), ],
"year" = results[order(results$year, decreasing = sort_desc, na.last = TRUE), ],
"fwci" = results[order(results$fwci, decreasing = sort_desc, na.last = TRUE), ],
Comment on lines +428 to +434
selectInput(
ns("size_by"),
tags$span("Size Nodes By",
title = "Control what determines node size. Age-weighted divides citations by paper age to surface newer impactful papers."),
choices = choices,
selected = "citations"
)
if (has_fwci) {
sprintf("FWCI available for %d of %d nodes", fwci_count, nrow(net_data$nodes))
} else {
"FWCI not available for network nodes (only returned by some OpenAlex endpoints)"
Comment on lines 586 to +592
# Cube-root transform: better spread than log1p for power-law data.
# cbrt(100)=4.6, cbrt(1000)=10, cbrt(15000)=24.7
# Gives 5x visual difference between 1k and 15k citations
# (log1p only gives 1.4x — high-citation nodes look the same)
transformed <- pmax(cited_by_counts, 0)^(1/3)
safe_values <- pmax(values, 0, na.rm = TRUE)
safe_values[is.na(safe_values)] <- 0
transformed <- safe_values^(1/3)
-- Supports filtering/sorting audit results by field-weighted citation impact
-- Pattern matches v13's refiner_results table which already stores FWCI

ALTER TABLE citation_audit_results ADD COLUMN fwci DOUBLE;
- Make migration 011 idempotent with IF NOT EXISTS (fresh DB crash)
- Compute has_fwci_data from unfiltered results (UI flicker fix)
- Fix min-frequency filter threshold (> 1 instead of > 2)
@seanthimons seanthimons merged commit 152ffdb into main Mar 20, 2026
1 check passed
seanthimons added a commit that referenced this pull request Mar 20, 2026
…-evolution"

This reverts commit 152ffdb, reversing
changes made to b2d0816.
@seanthimons seanthimons deleted the v14-citation-network-evolution branch March 22, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Citation audit filters and controls Changing citation size by new calculation metric

2 participants