Below is an example of how to use the PIC-SURE API to perform analysis in a R environment such as Jupyter Notebook. The data in this example is the NHANES Unified Dataset.
If you use Jupyter Notebook, you can use the ipynb file.
To obtain a key for the API, visit this page. A public_user key will be displayed in the top right of your screen. Replace the key in the step labeled "Start a secure session with the API" with the key you obtain.Retrieving NHANES PCB-153 levels for two different ages (20-39 and 40-59)
Load Required Libraries
Build Required URLs
These URLs represent the different web service calls to the PIC-SURE API. We build different strings to represent the different functions of the API.
Get Age and PCB153 data
Gathers clinical data using both i2b2 and i2b2/tranSMART. We first declare a subset of patients we want to pull data on, all the patients that have data on PCB153 status, then we declare the fields to pull for those patients.
Start a secure session with the API
$status = 'success'
Download in CSV Format
Transform Results and run t.test
No encoding supplied: defaulting to UTF-8.
Welch Two Sample t-test data: as.numeric(results4analysis$pcb153) by results4analysis$AgeGroup t = -19.387, df = 1411.4, p-value < 2.2e-16 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.2228082 -0.1818622 sample estimates: mean in group 1 mean in group 2 0.1184880 0.3208232