Author
Affiliation

Vagish Hemmige

Montefiore Medical Center/ Albert Einstein College of Medicine

The code in this script generates figures for the manuscript.

Source code

The full R script is available at:

This R script file is itself reliant on the following helper files:

Create Dot-Density Spatial Objects

This section prepares spatial objects used to visualize the geographic distribution of HIV cases.

Rather than shading counties by case counts (a choropleth), this approach uses a dot-density map, where:

  • Each dot represents a fixed number of HIV cases
  • Dots are distributed within county boundaries
  • Higher-density areas visually reflect greater case burden

Why Use Dot-Density Maps?

Dot-density maps have several advantages:

  • They avoid misleading visual effects caused by large but sparsely populated counties
  • They better reflect population concentration rather than land area
  • They provide a more intuitive visual representation of case burden

In this implementation:

  • Each dot represents 100 HIV cases
  • Dots are generated from the county-level county_cases variable

Objects Created

Two spatial lists are generated:

  • county_dots — raw dot-density geometries
  • county_dots_transformed — projected versions for mapping

For each year:

  1. as_dot_density() converts county-level HIV case counts into dot geometries.
  2. The resulting points are transformed to EPSG:5070 (NAD83 / Conus Albers) for consistency with other spatial layers.

Map Projection Standardization

The U.S. state boundary map (states_sf) is also transformed to EPSG:5070.

Using a consistent projected coordinate reference system ensures:

  • Accurate spatial alignment
  • Correct scaling
  • Consistent appearance across figures
  • Proper overlay with transplant center buffers and tract-level data

These spatial objects are later layered into manuscript figures to visualize:

  • Geographic HIV burden
  • Overlay with transplant center service areas
  • Changes across years
Click to show/hide R Code
county_dots<-list()
county_dots_transformed<-list()


for (year_loop in year_list)
  
{
  
  county_dots[[year_loop]]<-as_dot_density(Merged_Counties[[year_loop]], 
                                           "county_cases", 
                                           values_per_dot =100)
  
  county_dots_transformed[[year_loop]]<-county_dots[[year_loop]]%>%
    st_transform(5070)
  
}

#Transform us state map
states_sf_transformed<-states_sf%>%
  st_transform(5070)

Maps of Active and HIV-Performing Transplant Centers

This section generates manuscript-ready maps that overlay transplant center catchment areas on top of the national HIV dot-density map.

For each:

  • Organ
  • Distance definition (e.g., 50 miles, 60 minutes)
  • Year

two types of figures are created:

  1. Active transplant center maps
  2. HIV R+ transplant center maps

Map Layers

Each figure includes three spatial layers:

  1. Dot-density HIV layer
    • Derived from county-level HIV case counts
    • Each dot represents 100 HIV cases
    • Provides visual context for geographic burden
  2. Transplant center catchment areas
    • Either active-center buffers or HIV R+ buffers
    • Displayed as red outlines
    • Represent geographic access zones
  3. U.S. state boundaries
    • Provide geographic reference
    • Drawn without fill for clarity

All layers use the same projected coordinate system (EPSG:5070) to ensure proper alignment.


Active Center Maps

These maps show:

  • All active transplant centers for a given organ
  • Their associated catchment areas
  • Overlayed on national HIV case distribution

The title specifies:

  • Organ type
  • Year

Each figure is saved as an .svg file in the corresponding organ-specific folder.


HIV R+ Center Maps

These maps focus specifically on:

  • Centers that performed HIV R+ transplants
  • Their catchment areas
  • Overlayed on HIV case distribution

The title reflects the analysis year (e.g., 2013–2017 window where applicable).

These figures visually illustrate:

  • How geographic access for PLWH changes over time
  • Differences between general active centers and HIV-performing centers
  • Regions with high HIV burden but limited transplant access

Why These Maps Matter

These figures translate the analytic results into intuitive geographic visualizations that allow readers to:

  • See where HIV burden is concentrated
  • Identify regions lacking nearby transplant access
  • Compare service-area expansion or contraction across years
  • Assess disparities between general and HIV-specific transplant availability

The resulting .svg files are publication-quality and scalable for manuscript submission.

Click to show/hide R Code
Activemap<-list()
HIV_map<-list()

for (organ_loop in organ_list) {
  for (distance_loop in distance_list){
    for (year_loop in year_list) {
      
      #Map all transplant centers and a 50-mile catchment area upon the dot map of HIV
      Activemap[[organ_loop]][[year_loop]]<-ggplot() +
        geom_sf(data = county_dots_transformed[[year_loop]], size = 0.3, color = "navy", alpha = 0.5) +
        theme_minimal() +
        labs(title = paste("Radius around",organ_loop, "transplant centers,", year_loop),
             subtitle = "(1 dot = 100 HIV cases)")+
        geom_sf(data=Transplant_centers_active_buffer[[organ_loop]][[distance_loop]][[year_loop]], color="red", fill=NA)+
        geom_sf(data=states_sf_transformed, fill=NA)
      ggsave(paste0("figures/",organ_loop,"/Active ", organ_loop," ",distance_loop," map", year_loop,".svg"))
      
      
      
      #Map transplant centers with HIV R+ and a 60 minute catchment area upon the dot map of HIV, 2013-2017
      HIV_map[[organ_loop]][[year_loop]]<-ggplot() +
        geom_sf(data = county_dots_transformed[[year_loop]], size = 0.3, color = "navy", alpha = 0.5) +
        theme_minimal() +
        labs(title = paste0(as.numeric(year_loop)-4, " - ", year_loop))+
        geom_sf(data=Transplant_centers_HIV_buffer[[organ_loop]][[distance_loop]][[year_loop]], color="red", fill=NA)+
        geom_sf(data=states_sf_transformed, fill=NA)
      ggsave(paste0("figures/",organ_loop,"/HIV ", organ_loop," ",distance_loop," map", year_loop,".svg"))
      
      
    }
  }
}

Paired Plots for PLWH Comparing Years

This section generates side-by-side comparison plots to visualize changes in geographic access between 2017 and 2022.

Rather than showing maps, these figures present paired summary plots that directly compare:

  • Coverage in 2017
  • Coverage in 2022

for each organ, distance definition, and center category.


What These Plots Show

For each:

  • Organ
  • Distance (e.g., 50 miles, 60 minutes)

the script produces paired plots for:

  • Active transplant centers
  • Active centers (with optional comparison of PLWH vs non-HIV population)
  • HIV R+ centers
  • HOPE (HIV D+/R+) centers

Each plot compares the percentage of the population within geographic reach across the two years.


How the Plots Are Created

All plots are generated using a reusable helper function:

make_paired_plot()

This function:

  • Extracts aggregated results
  • Aligns year-specific values
  • Formats titles and labels
  • Produces consistent visual styling

The distance_label variable converts internal codes (e.g., 50mile, 60min) into reader-friendly labels such as:

  • “50 miles”
  • “60 mins”

Comparing PLWH and Non-HIV Populations

For active centers, a second version of the paired plot is generated with:

include_nonHIV = TRUE

This version overlays:

  • Coverage for people living with HIV
  • Coverage for the non-HIV population

This allows visual assessment of whether geographic access differs between populations.


Output Format

Each plot is saved in two formats:

  • .svg — publication-quality vector graphics
  • .png — presentation-friendly raster format

Images are saved at:

  • Width: 12 inches
  • Height: 6 inches
  • White background
  • High-resolution rendering via ragg

Why These Figures Matter

These paired plots provide a clear visual summary of:

  • Expansion or contraction of transplant access over time
  • Differences between center categories
  • Potential disparities in geographic coverage
  • Organ-specific variation in access

They translate tabular percentage changes into intuitive, publication-ready visuals suitable for the manuscript.

Click to show/hide R Code
for (organ_loop in organ_list) {
  for (distance_loop in distance_list){
    
    
    
    #Create distance label
    distance_label <- dplyr::case_when(
      stringr::str_detect(distance_loop, "mile$") ~ 
        paste0(stringr::str_remove(distance_loop, "mile"), " miles"),
      stringr::str_detect(distance_loop, "min$") ~ 
        paste0(stringr::str_remove(distance_loop, "min"), " mins")
    )
    
    
    #Create paired plot for active, no HIV
    paired_plot<-make_paired_plot(organ=organ_loop,
                                  distance=distance_loop,
                                  outcome="active",
                                  buffer_list=Transplant_centers_active_buffer,
                                  year1="2017",
                                  year2="2022",
                                  plottitle=glue::glue("Active {organ_loop} transplant center, {distance_label}")
    )
    
    
    
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} active.svg"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           bg = "white")
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} active.png"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           dpi = 150,
           device = ragg::agg_png,
           bg = "white")

    
    #Create paired plot for active, comparing HIV to non-HIV
    paired_plot<-make_paired_plot(organ=organ_loop,
                                  distance=distance_loop,
                                  outcome="active",
                                  buffer_list=Transplant_centers_active_buffer,
                                  year1="2017",
                                  year2="2022",
                                  plottitle=glue::glue("Active {organ_loop} transplant center, {distance_label}"),
                                  include_nonHIV = TRUE
    )
    
    
    
    
    ggsave(glue("figures/{organ_loop}/Active{organ_loop}CenterCombinedPlot{distance_loop}.svg"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           bg = "white")
    
    ggsave(glue("figures/{organ_loop}/Active{organ_loop}CenterCombinedPlot{distance_loop}.png"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           dpi = 150,
           device = ragg::agg_png,
           bg = "white")
    
    
    
    #Create paired plot for HIV
    paired_plot<-make_paired_plot(organ=organ_loop,
                                  distance=distance_loop,
                                  outcome="HIV",
                                  buffer_list=Transplant_centers_HIV_buffer,
                                  year1="2017",
                                  year2="2022",
                                  plottitle=glue::glue("Active HIV R+ {organ_loop} transplant center, {distance_label}"))
    
    
    
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HIV.svg"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           bg = "white")
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HIV.png"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           dpi = 150,
           device = ragg::agg_png,
           bg = "white")
    
    
    #Create paired plot
    paired_plot<-make_paired_plot(organ=organ_loop,
                                  distance=distance_loop,
                                  outcome="HOPE",
                                  buffer_list=Transplant_centers_HOPE_buffer,
                                  year1="2017",
                                  year2="2022",
                                  plottitle=glue::glue("Active HOPE D+/R+ {organ_loop} transplant center, {distance_label}"))
    
    
    
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HOPE.svg"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           bg = "white")
    
    ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HOPE.png"), 
           paired_plot, 
           width = 12, height = 6, units = "in",
           dpi = 150,
           device = ragg::agg_png,
           bg = "white")
    
    
    
  }
}

Tract-Level Catchment Distribution Plots (Beeswarm Plots)

This final section generates tract-level distribution plots that visualize how HIV burden is distributed across transplant center catchment areas.

Unlike the previous paired plots—which summarize overall percentages—these figures show variation across individual census tracts.


What These Plots Display

For each:

  • Organ
  • Distance definition

the function plot_center_HIV_catchment() produces a beeswarm-style plot comparing:

  • 2017
  • 2022

Each point represents a census tract within the active-center catchment area.

These plots allow readers to see:

  • The distribution of HIV burden across accessible tracts
  • Whether access expansion disproportionately affected higher- or lower-burden areas
  • How tract-level patterns shift over time

Why Use a Beeswarm-Style Plot?

A beeswarm (or jittered dot) plot:

  • Displays each tract individually
  • Avoids overplotting
  • Preserves the full distribution
  • Makes shifts in spread, clustering, or skewness visible

This complements the aggregate percentage results by showing the underlying geographic heterogeneity.


Output Format

Each plot is saved as:

  • .svg — scalable vector graphic suitable for publication
  • .png — high-resolution raster image for presentations

White backgrounds and high-resolution rendering ensure consistent visual quality across manuscript and slide use.


Why This Figure Matters

These plots move beyond national summaries and highlight:

  • Within-catchment variation
  • Regional concentration of HIV burden
  • Whether access improvements are evenly distributed

Together with maps and paired summary plots, they provide a multi-level view of geographic access to transplant services.

Click to show/hide R Code
for (organ_loop in organ_list) {
  for (distance_loop in distance_list){
    
    
    catchment_plot<-plot_center_HIV_catchment(organ=organ_loop,
                              distance=distance_loop,
                              buffer_list=tracts_in_buffers_active[[organ_loop]][[distance_loop]],
                              year1="2017",
                              year2="2022")
    
    
    
    ggsave(glue("figures/{organ_loop}/Beeswarm {organ_loop} plot 2026-2-14 {distance_loop}.svg"), 
           catchment_plot, 
   #        width = 12, height = 6, units = "in",
           bg = "white")
    
    ggsave(glue("figures/{organ_loop}/Beeswarm {organ_loop} plot 2026-2-14 {distance_loop}.png"), 
           catchment_plot, 
  #         width = 12, height = 6, units = "in",
           dpi = 150,
           device = ragg::agg_png,
           bg = "white")
  }
}

Other portions of the analysis

  • Setup: Defines global paths, data sources, cohort inclusion criteria, and analysis-wide constants.
  • Functions: Reusable helper functions for cohort construction, matching, costing, and modeling.
  • Tables: Summary tables and regression outputs generated from the final models.
  • About: methods, assumptions, and disclosures