This portion of the code initializes lists to classify transplant centers by activity status and HIV transplant volume for each organ and year of interest. These classifications are used downstream for geographic access analyses, state-level summaries, and figure generation.
For example, the nested list HOPE_center_volumes can be used to identify the number of HIV D+/R+ transplants performed at each transplant center for each organ and each time period.
HOPE_center_volume[["kidney]][["2017"]] will yield a data frame of HOPE kidney volumes for centers that performed at least one HOPE adult transplant in the 2013-2017 time period.
Key lists created:
Active_tx_centers: any adult transplant in the year defined by the inner list
HIV_center_volumes: any HIV R+ transplant in the five-year period
HOPE_center_volumes: any HIV D+/R+ transplant in the five-year period
State_level_transplant_volumes: HIV R+ volumes by state
Transplant_centers_active: similar to the first list active_tx_centers but with different variable composition
Click to show/hide R Code
for (organ_loop in organ_list){for (year_loop in year_list) { Active_tx_centers[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>%filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>%#Adult recipientmutate(year_transplant=year(REC_TX_DT))%>%filter(year_transplant==as.numeric(year_loop))%>%group_by(REC_CTR_CD)%>%count()%>%pull(REC_CTR_CD)#Calculate center level volumes for pts with HIV in five-year period ending in year for active centers HIV_center_volumes[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>%filter(REC_HIV_STAT=="P")%>%filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>%#Adult recipientmutate(year_transplant=year(REC_TX_DT))%>%filter(year_transplant>=(as.numeric(year_loop)-4) & year_transplant<=as.numeric(year_loop))%>%group_by(REC_CTR_CD)%>%count()%>%filter(REC_CTR_CD %in% Active_tx_centers[[organ_loop]][[year_loop]])#Identify HOPE centers in years of interest HOPE_center_volumes[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>%filter(REC_HIV_STAT=="P")%>%filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>%mutate(year_transplant=year(REC_TX_DT ))%>%filter(year_transplant>=(as.numeric(year_loop)-4) & year_transplant<=as.numeric(year_loop))%>%left_join(donor_deceased)%>%filter(DON_HIV_NAT %in%c("P", "P: Positive")| DON_ANTI_HIV %in%c("P", "P: Positive"))%>%group_by(REC_CTR_CD )%>%count()#Convert to state transplant volumes for recipients with HIV State_level_transplant_volumes[[organ_loop]][[year_loop]]<-HIV_center_volumes[[organ_loop]][[year_loop]]%>%mutate(state_code =substr(REC_CTR_CD, 1, 2))%>%group_by(state_code)%>%summarize(total_HIV_transplants=sum(n, na.rm =TRUE))#Create DFs for active centers in years of interest Transplant_centers_active[[organ_loop]][[year_loop]]<-Transplant_centers_all[[organ_loop]]%>%filter(OTCCode %in% Active_tx_centers[[organ_loop]][[year_loop]]) }}
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.
Figures:Visualizations of costs, risks, and model-based estimates.
---title: "Classify centers"format: html---The code in this script creates the cohort of kidney transplant patients eligible for the study for use in other scripts.::: {.Rcode title="Source code"}The full R script is available at:- [`R/classify_centers.R`](https://github.com/VagishHemmige/HOPE-CDC-analysis-2026/blob/master/R/classify_centers.R)This R script file is itself reliant on the following helper files:- [`R/setup.R`](https://github.com/VagishHemmige/HOPE-CDC-analysis-2026/blob/master/R/setup.R)- [`R/functions.R`](https://github.com/VagishHemmige/HOPE-CDC-analysis-2026/blob/master/R/functions.R):::## Initialize listsThis portion of the code initializes lists to classify transplant centers by activity status and HIV transplant volume for each organ and year of interest. These classifications are used downstream for geographic access analyses, state-level summaries, and figure generation.For example, the nested list `HOPE_center_volumes` can be used to identify the number of HIV D+/R+ transplants performed at each transplant center for each organ and each time period.`HOPE_center_volume[["kidney]][["2017"]]` will yield a data frame of HOPE kidney volumes for centers that performed at least one HOPE adult transplant in the 2013-2017 time period.Key lists created:- `Active_tx_centers`: any adult transplant in the year defined by the inner list- `HIV_center_volumes`: any HIV R+ transplant in the five-year period- `HOPE_center_volumes`: any HIV D+/R+ transplant in the five-year period- `State_level_transplant_volumes`: HIV R+ volumes by state- `Transplant_centers_active`: similar to the first list `active_tx_centers` but with different variable composition```{r, eval=FALSE}for (organ_loop in organ_list){ for (year_loop in year_list) { Active_tx_centers[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>% filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>% #Adult recipient mutate(year_transplant=year(REC_TX_DT))%>% filter(year_transplant==as.numeric(year_loop))%>% group_by(REC_CTR_CD)%>% count()%>% pull(REC_CTR_CD) #Calculate center level volumes for pts with HIV in five-year period ending in year for active centers HIV_center_volumes[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>% filter(REC_HIV_STAT=="P")%>% filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>% #Adult recipient mutate(year_transplant=year(REC_TX_DT))%>% filter(year_transplant>=(as.numeric(year_loop)-4) & year_transplant<=as.numeric(year_loop))%>% group_by(REC_CTR_CD)%>% count()%>% filter(REC_CTR_CD %in% Active_tx_centers[[organ_loop]][[year_loop]]) #Identify HOPE centers in years of interest HOPE_center_volumes[[organ_loop]][[year_loop]]<-tx[[organ_loop]]%>% filter(REC_HIV_STAT=="P")%>% filter(REC_AGE_IN_MONTHS_AT_TX>=216)%>% mutate(year_transplant=year(REC_TX_DT ))%>% filter(year_transplant>=(as.numeric(year_loop)-4) & year_transplant<=as.numeric(year_loop))%>% left_join(donor_deceased)%>% filter(DON_HIV_NAT %in% c("P", "P: Positive")| DON_ANTI_HIV %in% c("P", "P: Positive"))%>% group_by(REC_CTR_CD )%>% count() #Convert to state transplant volumes for recipients with HIV State_level_transplant_volumes[[organ_loop]][[year_loop]]<-HIV_center_volumes[[organ_loop]][[year_loop]]%>% mutate(state_code = substr(REC_CTR_CD, 1, 2))%>% group_by(state_code)%>% summarize(total_HIV_transplants=sum(n, na.rm = TRUE)) #Create DFs for active centers in years of interest Transplant_centers_active[[organ_loop]][[year_loop]]<-Transplant_centers_all[[organ_loop]]%>% filter(OTCCode %in% Active_tx_centers[[organ_loop]][[year_loop]]) }}```## Other portions of the analysis- [**Setup**](setup.qmd): Defines global paths, data sources, cohort inclusion criteria, and analysis-wide constants.- [**Functions**](functions.qmd): Reusable helper functions for cohort construction, matching, costing, and modeling.- [**Tables**](tables.qmd): Summary tables and regression outputs generated from the final models.- [**Figures**](figures.qmd):Visualizations of costs, risks, and model-based estimates.- [**About**](about.qmd): methods, assumptions, and disclosures