Package 'T2DFitTailor'

Title: Tailor the Exercise Plans and Visualize the Outcome for T2D Patients
Description: A system for personalized exercise plan recommendations for T2D (Type 2 Diabetes) patients based on the primary outcome of HbA1c (Glycated Hemoglobin). You provide the individual's information, and 'T2DFitTailor' details the exercise plan and predicts the intervention's effectiveness.
Authors: Cheng Liu [aut, cre], Xinyu Hou [aut], Bingxiang Xu [aut], Tiemin Liu [aut], Ru Wang [aut]
Maintainer: Cheng Liu <[email protected]>
License: MIT + file LICENSE
Version: 3.0.0
Built: 2024-11-13 04:28:05 UTC
Source: https://github.com/cran/T2DFitTailor

Help Index


Calculate PCS (Physical Component Summary) Scores

Description

This function calculates the Physical Component Summary (PCS) scores based on a set of specific questionnaire items related to physical and mental health domains. It requires a dataframe containing the required columns with valid answer ranges, and outputs a dataframe with PCS scores.

Usage

PCS_Calculation(df)

Arguments

df

A dataframe containing the questionnaire items with answers. The dataframe should have specific columns:

  • EVGFP_rating: In general, would you say your health is. Reference answers: 1=Excellent, 2=Very good, 3=Good, 4=Fair, 5=Poor.

  • Moderate_activities: Moderate activities, such as moving a table, pushing a vacuum cleaner, bowling, or playing golf. Reference answers: 1=Yes, Limited A Lot, 2=Yes, Limited A Little, 3=No, Not Limited At All.

  • Climb_several_flights: Climbing several flights of stairs. Reference answers: 1=Yes, Limited A Lot, 2=Yes, Limited A Little, 3=No, Not Limited At All.

  • Accomplished_less_physically: Accomplished less than you would like as a result of your physical health. Reference answers: 1=YES, 2=NO.

  • Limited_in_kind_physically: Were limited in the kind of work or other activities as a result of your physical health. Reference answers: 1=YES, 2=NO.

  • Accomplished_less_mentally: Accomplished less than you would like as a result of any emotional problems (such as feeling depressed or anxious). Reference answers: 1=YES, 2=NO.

  • Not_careful_mentally: Didn't do work or other activities as carefully as usual as a result of any emotional problems (such as feeling depressed or anxious). Reference answers: 1=YES, 2=NO.

  • Pain_interfere: During the past 4 weeks, how much did pain interfere with your normal work (including both work outside the home and housework)? Reference answers: 1=Not at all, 2=A little bit, 3=Moderately, 4=Quite a bit, 5=Extremely.

  • Calm: During the past 4 weeks, have you felt calm and peaceful? Reference answers: 1=All of the Time, 2=Most of the Time, 3=A Good Bit of the Time, 4=Some of the Time, 5=A Little of the Time, 6=None of the Time.

  • Energy: During the past 4 weeks, did you have a lot of energy? Reference answers: 1=All of the Time, 2=Most of the Time, 3=A Good Bit of the Time, 4=Some of the Time, 5=A Little of the Time, 6=None of the Time.

  • Felt_down: During the past 4 weeks, have you felt downhearted and blue? Reference answers: 1=All of the Time, 2=Most of the Time, 3=A Good Bit of the Time, 4=Some of the Time, 5=A Little of the Time, 6=None of the Time.

  • Social_time: During the past 4 weeks, how much of the time has your physical health or emotional problems interfered with your social activities (like visiting with friends, relatives, etc)? Reference answers: 1=All of the Time, 2=Most of the Time, 3=Some of the Time, 4=A Little of the Time, 5=None of the Time.

Value

A dataframe containing the calculated PCS scores.

References

Tucker G, Adams R, Wilson D. New Australian population scoring coefficients for the old version of the SF-36 and SF-12 health status questionnaires. Qual Life Res. 2010 Sep;19(7):1069-76. doi: 10.1007/s11136-010-9658-9. Epub 2010 May 4. Erratum in: Qual Life Res. 2010 Sep;19(7):1077. PMID: 20440565.

Examples

set.seed(123)

sample_names <- c("xiaoming", "xiaohong", "xiaohua")

df <- data.frame(
  row.names = sample_names,
  EVGFP_rating = sample(1:5, 3, replace = TRUE),
  Moderate_activities = sample(1:3, 3, replace = TRUE),
  Climb_several_flights = sample(1:3, 3, replace = TRUE),
  Accomplished_less_physically = sample(1:2, 3, replace = TRUE),
  Limited_in_kind_physically = sample(1:2, 3, replace = TRUE),
  Accomplished_less_mentally = sample(1:2, 3, replace = TRUE),
  Not_careful_mentally = sample(1:2, 3, replace = TRUE),
  Pain_interfere = sample(1:5, 3, replace = TRUE),
  Calm = sample(1:6, 3, replace = TRUE),
  Energy = sample(1:6, 3, replace = TRUE),
  Felt_down = sample(1:6, 3, replace = TRUE),
  Social_time = sample(1:5, 3, replace = TRUE)
)

PCS_output <- PCS_Calculation(df)
PCS_output

Visualize Tailored Exercise Plan for T2D Patients

Description

This function visualizes the exercise plan recommendations for Type 2 Diabetes (T2D) patients by generating radar charts.

Arguments

demo_result

A list containing two data frames (⁠$RecommendedExercisePlan⁠ and ⁠$AllExercisePlan⁠) as returned by the TailorExercisePlan function.

sample_selection

Specifies which patient samples to visualize, accepting three types of inputs:

  • "all": Visualizes all samples.

  • Given names (character vector): Names of specific patients for visualization.

  • Numeric value: A numeric index indicating the number of samples to visualize.

sort_by

Determines the sorting orientation for the visualization, affecting which samples are prioritized:

  • "head": Prioritizes samples towards the beginning of the selection.

  • "tail": Prioritizes samples towards the end of the selection.

exercise_type

Specifies the type(s) of exercises to include in the visualization. Accepts multiple input types:

  • "all": Includes all types of exercises.

  • "best": Selects the exercise(s) with the highest predicted reduction in HbA1c.

  • Given types (character vector): Specific exercises, including "Taiji", "Qigong", "Stretching", "Rugby", "Cycling", and "Walking".

nrow

The number of rows in the visualization grid, which can be:

  • "auto": Automatically calculates the number of rows based on the number of samples and other parameters.

  • Numeric value: Specifies the exact number of rows for the layout.

ncol

The number of columns in the visualization grid, which can be:

  • "auto": Automatically calculates the number of columns based on the number of samples, the specified number of rows, and other parameters.

  • Numeric value: Specifies the exact number of columns for the layout.

show_legend

A logical value indicating whether to display a legend in the plots. TRUE or FALSE.

Value

The function does not return a data structure, but rather invisibly produces radar charts. These charts visualize the expected HbA1c decrease value and other relevant details for each recommended exercise plan for T2D patients.

Examples

#Create a demo dataframe
set.seed(5)
df <- data.frame(
  Age = sample(39:77, 8, replace = TRUE),
  Sex = sample(0:1, 8, replace = TRUE),
  BMI = sample(18:31, 8, replace = TRUE),
  WHtR = sample(0.4:0.6, 8, replace = TRUE),
  PCS = sample(27:54, 8, replace = TRUE),
  Duration_T2D = sample(1:26, 8, replace = TRUE),
  Total_cholesterol = sample(7.4:14.1, 8, replace = TRUE),
  HDL = sample(1:1.7, 8, replace = TRUE),
  LDL = sample(2.2:4.7, 8, replace = TRUE),
  VO2_Max = sample(13:45, 8, replace = TRUE),
  Lung_capacity = sample(1900:4600, 8, replace = TRUE),
  Back_Scratch_Test = sample(-30:8, 8, replace = TRUE))

names(df) <- c('Age', 'Sex', 'BMI', 'WHtR', 'PCS', 'Duration_T2D (year)',
              'Total cholesterol (mmol/L)', 'HDL (mmol/L)', 'LDL (mmol/L)',
              'VO2_Max (ml/kg/min)', 'Lung_capacity (ml)', 'Back_Scratch_Test (cm)')
rownames(df) <- c('Sample1', 'Sample2', 'Sample3', 'Sample4',
                  'Sample5', 'Sample6', 'Sample7', 'Sample8')

# Run the TailorExercisePlan function
demo_result <- TailorExercisePlan(df)

# Visualize the outcome from 'TailorExercisePlan' function
VisualizeTailoredExercisePlan(demo_result,sample_selection="all",sort_by="head",
                              exercise_type="best",nrow="auto",ncol="auto",show_legend=TRUE)

VisualizeTailoredExercisePlan(demo_result,sample_selection="Sample1",sort_by="head",
                              exercise_type="all",nrow="auto",ncol="auto",show_legend=TRUE)

Tailor Exercise Plan for T2D Patients

Description

This function generates a tailored exercise plan for T2D (Type 2 Diabetes)

Arguments

input_df

A data frame containing patient data necessary for generating a tailored exercise plan. Each column in the dataframe should be as follows (All data must be numeric.):

Age

Patient's age in years.

Sex

Patient's sex, where 0 might denote female and 1 denotes male.

BMI

Body Mass Index, a measure of body fat based on height and weight.

WHtR

Patient's ratio of waist and height.

PCS

Patient's Physical Component Summary (PCS) score, a metric derived from the SF-12 (Short Form Health Survey) which measures health-related quality of life. The PCS score is calculated based on responses to questions in the SF-12 survey, reflecting physical functioning, bodily pain, general health perceptions, and physical roles. A higher score indicates better physical health. Users can refer to the PCS_Calculation function within this package for detailed calculations based on SF-12 survey responses.

Duration_T2D (year)

Duration of Type 2 Diabetes Mellitus in years. It reflects how long the patient has been living with Type 2 diabetes.

Total cholesterol (mmol/L)

Total cholesterol levels in mmol/L. This measurement includes LDL, HDL, and other lipid components. Higher overall cholesterol levels can increase the risk of cardiovascular disease, although the balance of different types of lipids (HDL, LDL, others) also plays a critical role.

HDL (mmol/L)

High-Density Lipoprotein cholesterol levels in mmol/L. HDL is considered the "good" cholesterol, and higher levels are often associated with a lower risk of heart disease.

LDL (mmol/L)

Low-Density Lipoprotein cholesterol levels in mmol/L. LDL is often referred to as the "bad" cholesterol because high levels can lead to plaque buildup in arteries and increase the risk of heart disease.

VO2_Max

Patient's maximum oxygen uptake.

Lung_capacity

Patient's lung volume or capacity.

BACK_Scratch_Test

Assessment of the patient's upper limb flexibility and shoulder range of motion.

Note: It is crucial that the data for each of these columns is correctly formatted and accurately represents the patient's health information for the exercise plan to be effectively tailored.

Value

A list containing two data frames: ⁠$RecommendedExercisePlan⁠: This data frame includes exercise plans that are recommended based on the criterion that the intervention leads to a positive reduction in HbA1c levels, and ⁠$AllExercisePlan⁠ which includes all received plans.

Examples

#Create a demo dataframe
set.seed(5)
df <- data.frame(
  Age = sample(39:77, 8, replace = TRUE),
  Sex = sample(0:1, 8, replace = TRUE),
  BMI = sample(18:31, 8, replace = TRUE),
  WHtR = sample(0.4:0.6, 8, replace = TRUE),
  PCS = sample(27:54, 8, replace = TRUE),
  Duration_T2D = sample(1:26, 8, replace = TRUE),
  Total_cholesterol = sample(7.4:14.1, 8, replace = TRUE),
  HDL = sample(1:1.7, 8, replace = TRUE),
  LDL = sample(2.2:4.7, 8, replace = TRUE),
  VO2_Max = sample(13:45, 8, replace = TRUE),
  Lung_capacity = sample(1900:4600, 8, replace = TRUE),
  Back_Scratch_Test = sample(-30:8, 8, replace = TRUE))

names(df) <- c('Age', 'Sex', 'BMI', 'WHtR', 'PCS', 'Duration_T2D (year)',
               'Total cholesterol (mmol/L)', 'HDL (mmol/L)', 'LDL (mmol/L)',
               'VO2_Max (ml/kg/min)', 'Lung_capacity (ml)', 'Back_Scratch_Test (cm)')
rownames(df) <- c('Sample1', 'Sample2', 'Sample3', 'Sample4',
                  'Sample5', 'Sample6', 'Sample7', 'Sample8')

# Run the TailorExercisePlan function
demo_result <- TailorExercisePlan(df)
# View the structure of the returned list
str(demo_result)