Author: Sufyan Suleman
Date: 2024-04-03

# Insulin Sensitivity Indices Calculator

#### Sufyan Suleman

#### 2024-04-03

# Insulin Sensitivity Indices Calculator

The ‘isi_calculator’ function is a comprehensive tool designed to calculate a wide array of surrogate insulin sensitivity indices. This vignette provides a detailed guide on installing the package, understanding its usage, and interpreting the output effectively.

## Installation

Before using ‘isi_calculator’function from the ’InsuSensCalc’ package, ensure that the necessary dependencies are installed and loaded into your R session for example: dplyr, magrittr and tibble.

Additionally, you need to install the ‘InsuSensCalc’ package itself. If It is available on CRAN, install it using:

install.packages(“InsuSensCalc”)

Or, if it’s not on CRAN, you can install it directly from its repository, for example, GitHub: using devtools::install_github(“sufyansuleman/InsuSensCalc”)

## Usage

The ‘isi_calculator’ function is designed to be flexible, accommodating various types of input data related to insulin sensitivity calculations:

- Fasting: Requires fasting glucose and insulin levels.
- OGTT: Requires glucose and insulin levels at multiple time points post-glucose load (e.g., 30 and 120 minutes).
- Adipose Tissue (adipo): Requires measurements related to adipose tissue, such as triglycerides and HDL cholesterol.
- Tracer and DXA (tracer_dxa): Includes specialized indices involving tracer measurements and dual-energy X-ray absorptiometry (DXA).

### Preparing Your Data

Your input dataframe should include columns corresponding to the required measurements for your chosen calculation categories. The column names should match the expected names exactly.

### Function Parameters

- `data`: The input dataframe.
- `category`: A character vector specifying which indices to calculate. Available options: `"fasting"`, `"ogtt"`, `"adipo"`, and `"tracer_dxa"`.

### Advanced Details

The function includes automatic unit conversions for relevant variables and handles missing data gracefully, either skipping calculations for missing variables or setting indices to NA when applicable.

### Example Usage

    # Load the package
    library(InsuSensCalc)

    # Load your data
    # example_data <- read.csv("path/to/your/data.csv")

    # Sample usage of the function
    result_fasting <- isi_calculator(example_data, category = "fasting")
    #> Calculating fasting indices...
    result_ogtt <- isi_calculator(example_data, category = "ogtt")
    #> Calculating ogtt indices...
    result_adipo <- isi_calculator(example_data, category = "adipo")
    #> Calculating adipo indices...
    result_combined <- isi_calculator(example_data, category = c("fasting", "ogtt", "adipo", "tracer_dxa"))
    #> Calculating fasting indices...
    #> Calculating ogtt indices...
    #> Calculating adipo indices...
    #> Calculating tracer daxa indices...

    # Print a result to view
    print(result_fasting)
    #> # A tibble: 3 × 27
    #>     age   sex weight    G0    I0  G120  I120   G30   I30   bmi waist    TG HDL_c
    #>   <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    #> 1    30     1     70   5     7     7.8    50   6      25    25    90   1.8  1.2
    #> 2    40     2     60   5.5   8     8.1    45   6.5    30    30    85   2    1.1
    #> 3    35     1     65   6     7.5   8      48   6.2    28    27    88   1.9  1.15
    #> # ℹ 14 more variables: FFA <dbl>, fat_mass <dbl>, rate_glycerol <dbl>,
    #> #   rate_palmitate <dbl>, Fasting_inv <dbl>, Raynaud <dbl>, Homa_IR_inv <dbl>,
    #> #   Firi <dbl>, Quicki <dbl>, Belfiore_basal <dbl>, Ig_ratio_basal <dbl>,
    #> #   Isi_basal <dbl>, Bennett <dbl>, HOMA_IR_rev_inv <dbl>

## Output Interpretation

The output of ‘isi_calculator’ is a dataframe containing the calculated indices for each specified category. These values are provided without normalization or transformation. It is advisable to normalize these values according to your analysis needs, especially when planning to conduct statistical testing or visualization.

## Conclusion

The ‘InsuSensCalc’ package and its ‘isi_calculator’ function offer a robust solution for calculating insulin sensitivity indices from a variety of data types. By following the guidelines in this vignette, you can effectively utilize this tool for your research or clinical assessments related to insulin sensitivity and metabolic health.