R/annotate_foods.R
annotate_foods.Rd
This function provides a text mining pipeline to map nutritional free text to Food-Biomarker Ontology. This pipeline is composed of five sequential layers to map food items to FOBI with the maximum accuracy as possible.
annotate_foods(foods, similarity = 0.85, reference = fobitools::foods)
A two column data frame. First column must contain the ID (should be unique) and the second column must contain food items (it can be a word or a string).
Numeric between 0 (low) and 1 (high). This value indicates the semantic similarity cutoff used at the last layer of the text mining pipeline. 1 = exact match; 0 = very poor match. Values below 0.85 are not recommended.
FOBI foods table obtained with `parse_fobi(terms = "FOBI:0001", get = "des")`. If this value is set to NULL, the last version of FOBI will be downloaded from GitHub.
A list containing two tibble objects: annotated and unannotated food items.
Pol Castellano-Escuder, Raúl González-Domínguez, David S Wishart, Cristina Andrés-Lacueva, Alex Sánchez-Pla, FOBI: an ontology to represent food intake data and associate it with metabolomic data, Database, Volume 2020, 2020, baaa033, https://doi.org/10.1093/databa/baaa033.
# Free text annotation in FOBI
free_text <- data.frame(id = c(101, 102, 103, 104),
text = c("Yesterday I ate eggs and bacon with a butter toast and black tea",
"Crisp bread and rice crackers with wholegrain",
"Beef and veal, one apple", "pizza without meat"))
annotate_foods(free_text)
#> 100% annotated
#> 0.075 sec elapsed
#> $annotated
#> # A tibble: 16 × 4
#> FOOD_ID FOOD_NAME FOBI_ID FOBI_NAME
#> <chr> <chr> <chr> <chr>
#> 1 101 Yesterday I ate eggs and bacon with a butter toast… FOODON… bacon fo…
#> 2 101 Yesterday I ate eggs and bacon with a butter toast… FOODON… butter
#> 3 101 Yesterday I ate eggs and bacon with a butter toast… FOODON… tea base…
#> 4 101 Yesterday I ate eggs and bacon with a butter toast… FOODON… tea food…
#> 5 101 Yesterday I ate eggs and bacon with a butter toast… FOODON… toast
#> 6 101 Yesterday I ate eggs and bacon with a butter toast… FOBI:0… whole to…
#> 7 102 Crisp bread and rice crackers with wholegrain FOODON… bread fo…
#> 8 102 Crisp bread and rice crackers with wholegrain FOBI:0… crisp
#> 9 102 Crisp bread and rice crackers with wholegrain FOODON… rice gra…
#> 10 102 Crisp bread and rice crackers with wholegrain FOBI:0… whole br…
#> 11 102 Crisp bread and rice crackers with wholegrain FOBI:0… wholegra…
#> 12 103 Beef and veal, one apple FOODON… apple (w…
#> 13 103 Beef and veal, one apple FOODON… beef foo…
#> 14 103 Beef and veal, one apple FOODON… veal
#> 15 104 pizza without meat FOODON… pizza fo…
#> 16 104 pizza without meat FOBI:0… vegetari…
#>
#> $unannotated
#> # A tibble: 0 × 2
#> # ℹ 2 variables: FOOD_ID <dbl>, FOOD_NAME <chr>
#>