Andrea Rodriguez Martinez, Rafael Ayala, Yacine Debbabi, Lara Selles Vidal
Jun 16, 2018
Motivation: Diet and nutrition play a key role in the development, prevention and treatment of noncommunicable diseases (NCD), such as type 2 diabetes, obesity or cardiovascular diseases [@lachat2013]. For example, inadequate intake of fruits and vegetables contributes to 2.7 million NCD-related deaths per year[@hall2009]. Food and nutrient databases provide the basic infrastructure for the assessment of diet quality and for the development of food-based dietary guidelines [@ahuja2012; @elmadfa2010].
NutrienTrackeR is a tool set for food information and
dietary assessment. It uses food composition data from several reference databases,
including: USDA (US), CIQUAL (France), and BEDCA (Spain). NutrienTrackeR calculates
the intake levels for both macronutrients and micronutrients, and compares them
with the recommended dietary allowances. It also includes a number of visualization
tools, such as time series plots of nutrient intake, or pie-charts showing the main foods
contributing to the intake levels of a given nutrient.
Before installing NutrienTrackeR, please make sure you
have the latest version of R is installed. To install NutrienTrackeR,
start R and enter:
Once installed, the package can be loaded as shown below:
NutrienTrackeR includes three different food composition
tables, which provide information on the average nutritional value of foods consumed
in the United States (USDA standard reference database), France (CIQUAL database) and
Spain (BEDCA database). All nutritional values are provided per 100 grams of food.
# USDA dataset USDA_dataset <- food_composition_data$USDA # CIQUAL dataset CIQUAL_dataset <- food_composition_data$CIQUAL # BEDCA dataset BEDCA_dataset <- food_composition_data$BEDCA
NutrienTrackeR includes a series of functionalities
to facilitate the manipulation of these datasets. For example, the function
getNutrientNames() gets the names of all the nutrients included in a given
food composition table.
# Get nutrients included in the USDA dataset nutrients_USDA <- getNutrientNames(food_database = "USDA") print(head(nutrients_USDA), 4)
##  "Water (g)" "Energy (kcal)" ##  "Protein (g)" "Total lipid (fat) (g)" ##  "Ash (g)" "Carbohydrate, by difference (g)"
The function subsetFoodRichIn() selects the foods with
the highest content of a nutrient of interest.
# Top 2 high-protein CIQUAL foods subsetFoodRichIn(nutrient_name = "Protein (g)", food_database = "CIQUAL", n = 2)[, "food_name"]
## 11007 22004 ## "Gelatine, dried" "Egg white, powder"
# Top 3 high-protein BEDCA foods within "Fruits and fruit products" subsetFoodRichIn(nutrient_name = "Protein (g)", food_database = "BEDCA", food_group = "Fruits and fruit products", n = 3)[, "food_name"]
## 908 946 909 ## "Coconut, dried" "Peach, dried" "Coconut, raw"
The function findFoodName() searches for food names
based on query keywords.
# Find the USDA food name "Tomatoes, green, raw" findFoodName(keywords = c("Tomato", "raw"), food_database = "USDA")
## 11527 ## "Tomatoes, green, raw" ## 11529 ## "Tomatoes, red, ripe, raw, year round average" ## 11695 ## "Tomatoes, orange, raw" ## 11696 ## "Tomatoes, yellow, raw"
NutrienTrackeR allows assessing the dietary intake
of an individual, based on the food composition database of choice (i.e. USDA,
CIQUAL or BEDCA). For this, the user needs to provide a matrix or a list of matrices,
where each matrix reports all the foods eaten in a given day. The matrix must have
two columns: 1) “food”, reporting food names; and 2) “units”, reporting
the number of units eaten (1 unit = 100 grams of food). The dataset sample_diet_USDA
is an example of a one-week diet, using foods from the USDA database.
# Foods eaten in day 1 head(sample_diet_USDA[])
## food units ## [1,] "Cereals, QUAKER, Quick Oats, Dry" "1" ## [2,] "Oranges, raw, California, valencias" "0.75" ## [3,] "Kiwifruit, green, raw" "0.5" ## [4,] "Yogurt, plain, low fat" "1" ## [5,] "Tomatoes, green, raw" "0.75" ## [6,] "Lettuce, iceberg (includes crisphead types), raw" "0.5"
The function dietBalance() calculates the daily nutrient
intake of an individual and compares it with the NIH recommendations (recommended
dietary allowances (RDA) and tolerable upper intake levels (TUIL)). The nutrient
requirements are dependent on age and gender, and therefore these parameters
need to be specified when using the function dietBalance(). In this example,
we will calculate the nutrient intake from the dataset sample_diet_USDA, assuming
that this data was provided by a 27-year old women.
# Calculate nutrient intake daily_intake <- dietBalance(my_daily_food = sample_diet_USDA, food_database = "USDA", age = 27, gender = "female")
## The results correspond to an average of 7 days
## Total energy intake (kcal): 1795
## The intake level of the following nutrients is below the RDA:
## nutrient proportion(%RDA) group ## 1 Water (g) 30.97156 macronutrient ## 2 Calcium, Ca (mg) 58.25710 mineral ## 3 Sodium, Na (mg) 59.84527 mineral ## 4 Potassium, K (mg) 67.10106 mineral ## 5 Iron, Fe (mg) 99.56111 mineral ## 6 Vitamin D (D2 + D3) (ug) 11.28667 vitamin ## 7 Vitamin E (alpha-tocopherol) (mg) 31.04000 vitamin ## 8 Vitamin A, RAE (ug) 45.67343 vitamin ## 9 Choline, total (mg) 85.32682 vitamin ## 10 Folate, DFE (ug) 96.62500 vitamin
## The intake level of the following nutrients is above the TUIL:
## nutrient proportion(%RDA) group ## 1 Magnesium, Mg (mg) 223.7326 mineral ## 2 Manganese, Mn (mg) 643.8333 mineral
The output of dietBalance() can be visualized
with several functions. For instance, nutrientIntakePlot() generates a
barplot of nutrient intake levels.
The function nutrientPiePlot() generates a pie-chart
showing the relative contribution of each food to the total intake of a given nutrient.
#Load ggplott2 library(ggplot2) ## Generate plot q <- nutrientPiePlot(daily_intake, nutrient_name = "Magnesium, Mg (mg)") ## Adjust font size q + theme(axis.title = element_text(size = 29), axis.text = element_text(size = 29), legend.title = element_text(size = 22),legend.text = element_text(size = 20))
The function nutrientsTimeTrend() allows visualizing
time trends of nutrient intake levels.
# Generate plot p <- nutrientsTimeTrend(my_daily_food = sample_diet_USDA, food_database = "USDA", nutrients = c("Calcium, Ca (mg)", "Iron, Fe (mg)")) # Adjust font size p + theme(axis.title = element_text(size = 18), axis.text = element_text(size = 16), legend.title = element_text(size = 18),legend.text = element_text(size = 18))
A shiny app is available, which can be run locally
by executing NutrienTrackeRapp(). Alternatively, the app can be accessed