Package: iglu-py
PurposeWe are releasing a Python wrapper (iglu-py) for the R package "iglu" (iglu-r), since a large number of developers and diabetes researchers program primarily in Python. We hope this abstraction makes development with iglu even easier and more user-friendly.Note thatiglu-ris the "source of truth" and alliglu-pyfunctions simply call the correspondingiglu-rfunction internally. In other words,there is no new functionality in iglu-py that is not iglu-r(seeFunctionalitybelow for more details).CitationPlease citebothiglu-pyand the originaliglu-rpackage.Fernandes NJ, Chun E, Gaynanova I (2023). iglu-py: Interpreting Glucose Data from Continuous Glucose Monitors. Python package version 1.0.0.Broll S, Buchanan D, Chun E, Muschelli J, Fernandes N, Seo J, Shih J, Urbanek J, Schwenck J, Gaynanova I (2021). iglu: Interpreting Glucose Data from Continuous Glucose Monitors. R package version 3.0.0.Getting StartedInstallation$ pip install iglu-pyThis will automatically install all the necessary Python dependencies for you.There isno needto download R,iglu-r, or any other CRAN package directly. Version 3.5.0 ofiglu-rcomes bundled withiglu-pyand will be installed automatically on the first runtime.⚠️ If you already haveiglu-rinstalled on your machine,iglu-pywill use that version ofiglu-rinternally instead of the bundled Version 3.5.0.SeeChanging the Version of "iglu-r" Used by "iglu-py"below to change to your desired version.How to Useimport iglu_py as iglu
import pandas as pd

# 1. Load pandas DF through any method, not exclusive to CSV
# DF must have 3 columns:
# > id: string or int
# > time: POSIX.ct()
# > gl: numeric type

df = pd.read_csv('path_to_file.csv')

# 2. Run metrics
# The output is a pandas DF.

iglu.mean_glu(df)

iglu.mage(df) # uses default arguments in iglu-py
iglu.mage(df, short_ma = 3, long_ma = 35) # overrides defaults

# 3. Load example data
example_data: pd.DataFrame = iglu.example_data_1_subject

iglu.mage(example_data)

# 4. Launch interactive GUI
iglu.iglu_shiny()SeeFunctionalitybelow for the list of Python functions and data available iniglu-py. Seeiglu-r Function Documentationto know the acceptable arguments & data types for the implementediglu-pyfunctions.When reading the aforementionediglu-rdocumentation & coding in Python,always use Python typesnot R ones. Only use types in the Python column of the table below.PythonRTrue/FalseTRUE/FALSEPandas DataFrametibblePandas DataFrameData Framestrcharacterint|floatnumericlistvectorChanging the Version of "iglu-r" Used by "iglu-py"By default, the R-versioniglu v3.5.0comes embedded in iglu-py. However, you can change this version if you desire.Follow these simple steps below.Uninstall Previousiglu-rVersion: run the following code in Python to delete the previous version ofigluimport iglu_py

iglu_py.uninstall_iglu()Install a new version ofiglu:Way 1: Download most recent version released onCRANimport iglu_py

iglu_py.install_iglu(name = 'iglu', name_type = 'CRAN')Way 2: Get a TAR GZIP file of the desirediglu-rversion fromCRANor make one by tar-gzipping theiglu-r GitHub repo(the GitHub is slightly ahead of official-release on CRAN). Then do:import iglu_py

iglu_py.install_iglu(name = 'absolute/path/to/file', name_type = 'absolute')Update Metrics, If Needed:You only need to edit theiglu-pysource code in Case 2 & 3 below.CASE 1: A metric in the newiglu-rversion has different default parameters from the oldiglu-rversionNo change toiglu-pysource code needed.Simply use theiglu-pyfunction as normal, passing in the required parameters and any optional ones as well.CASE 2: A metric in the newiglu-rversion has different non-default/required parametersAdd the parameters to the function definition inpackage-path/iglu_py/metrics.pyThen, in thepackage-pathdirectory, run in the terminalcd directory/to/package-path/
pip uninstall iglu_py
pip install .CASE 3: The newiglu-rversion has a metric not in previous iglu version:add the metric to thepackage-path/iglu_py/metrics.pyfile following the examples already there (note: don't add "default parameters" to the function definition - instead, use**kwargsin Python to prevent overriding those defaults specified in the R package)import the metric into thepackage-path/iglu_py/__init__.pyfileFunctionalityiglu-pyallows most functionality iniglu-rincluding all metrics, data processing functions, and an interactive GUI.However, plotting programmatically is unavailable. Please use the Shiny app to generate and download plots iniglu-pyor the originaligluR package.(There is no plan to support plotting programmatically in iglu-py due to the complexity of the task.)See the tables below to understand what is accessible iniglu-pyvs.iglu-r.FeaturePythonRCommentInteractive GUIiglu.iglu_shiny()iglu::iglu_shiny()All Plots❌✅Example Dataiglu.example_data_X_subjectiglu.example_meals_halliglu.example_data_halliglu::example_data_X_subjectiglu::example_meals_halliglu::example_data_hallX=1,5MetricsPythonRCommentCGMS2DayByDay❌iglu::CGMS2DayByDay()Above %iglu.above_percent()iglu::above_percent()Active %iglu.active_percent()iglu::active_percent()ADRRiglu.adrr()iglu::adrr()AGPiglu.agp()iglu::agp()AGP Metricsiglu.agp_metrics()iglu::agp_metrics()All Metricsiglu.all_metrics()iglu::all_metricsAUCiglu.auc()iglu::auc()Below %iglu.below_percent()iglu::below_percent()Calculate Sleep Wake❌iglu::calculate_sleep_wake()COGIiglu.cogi()iglu::cogi()CONGAiglu.conga()iglu::conga()Coefficient of Variation (CV)iglu.cv_glu()iglu::cv_glu()Coefficient of Variation subtypesiglu.cv_measures()iglu::cv_measures()eA1Ciglu.ea1c()iglu::ea1c()Episode Calculation Profileiglu.epicalc_profile()iglu::epicalc_profile()Episode Calculationiglu.episode_calculation()iglu::episode_calculation()GMIiglu.gmi()iglu::gmi()GRADEiglu.grade()iglu::grade()Grade Euglyiglu.grade_eugly()iglu::grade_eugly()Grade Hyperiglu.grade_hyper()iglu::grade_hyper()Grade Hypoiglu.grade_hypo()iglu::grade_hypo()GRIiglu.gri()iglu::gri()GVPiglu.gvp()iglu::gvp()HBGIiglu.hbgi()iglu::hbgi()Hyperglucemia Indexiglu.hyper_index()iglu::hyper_index()Hypoglycemia Indexiglu.hypo_index()iglu::hypo_index()Index of Glycemic Controliglu.igc()iglu::igc()% in target rangeiglu.in_range_percent()iglu::in_range_percent()IQRiglu.iqr_glu()iglu::iqr_glu()J-Indexiglu.j_index()iglu::j_index()LBGIiglu.lbgi()iglu::lbgi()M-Valueiglu.m_value()iglu::m_value()MADiglu.mad_glu()iglu::mad_glu()MAGiglu.mag()iglu::mag()MAGEiglu.mage()iglu::mage()Meal Metricsiglu.()iglu::meal_metrics()Meaniglu.mean_glu()iglu::mean_glu()Medianiglu.median_glu()iglu::median_glu()Metrics Heatmap❌iglu::metrics_heatmap()MODDiglu.modd()iglu::modd()PGS❌iglu::pgs()Process Dataiglu.process_data()iglu::process_data()Quantileiglu.quantile_glu()iglu::quantile_glu()Rangeiglu.range_glu()iglu::range_glu()Read Raw Dataiglu.read_raw_data()iglu::read_raw_data()ROCiglu.roc()iglu::roc()SDiglu.sd_glu()iglu::sd_glu()SD  Measuresiglu.sd_measures()iglu::sd_measures()SD  ROCiglu.sd_roc()iglu::sd_glu()Summaryiglu.summary_glu()iglu::summary_glu()License AgreementsBy using this package, you agree to the license agreement of theR version of iglu, which is GPL-2.By using the data included in this package, you consent to the following User Agreement.Use of the T1D Exchange publicly-available data requires that you include the following attribution and disclaimer in any publication, presentation or communication resulting from use of these data:The source of the data is the T1D Exchange, but the analyses, content and conclusions presented herein are solely the responsibility of the authors and have not been reviewed or approved by the T1D Exchange.In addition, the T1D Exchange should be notified via email (publicdatasetuse@t1dexchange.org) when a manuscript (send title) or abstract (send title and name of meeting) reports T1D Exchange data or analyses of the data. Please provide notification at the time of submission and again at time of acceptance.