knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(bodycompref)
bodycompref aims to provide a fast, batch-compatible way to calculate different versions of reference values of CT-assessed skeletal muscle and adipose tissue.
Briefly, the underlying LMSP models model the distribution of a body composition metric (e.g. cross-sectional skeletal muscle area at the T5 vertebral level) based on age. Separate models are available for females and males. For more information about the underlying research and a visual representation please visit https://bodycomp-metrics.mgh.harvard.edu
If you use this package, please make sure you credit us with a citation:
citation("bodycompref")
To install the package from CRAN use the usual installation:
install.packages("bodycompref")
Alternatively, install directly from github:
install.packages("devtools") devtools::install_github("p-mq/bodycompref")
Since CRAN has strict limits on file size, the reference LMSP models for the reference values are stored in their own data repositories. Install these using the following commands:
# Models for adipose tissue, ~60Mb install.packages("adiposerefdata", repos="https://p-mq.github.io/drat") # Models for skeletal muscle, ~45Mb install.packages("musclerefdata", repos="https://p-mq.github.io/drat")
Note that this option might require installation of the drat package.
Alternatively, version 1.0.0 and 1.1.0 still contain all the models inside the main package are still available on GitHub
You can use a dedicated method to calculate each of the four possible transformations:
Alternatively, you can use the wrapper bodycomp_reference, which wraps all four of these functions, and specify the desired return.
Input parameters are mostly equal among all functions. Data inputs can be passed as vectors to use batch-processing. Naturally, vectors need to be of equal length:
reference_values replaces the input 'measurement' with one of the following: + percentile: A numeric (vector), percentile to return value for. If both percentile and z_score are given, only percentile is evaluated + z_score numeric (vector), z score to return value for. If both percentile and z_score are given, only percentile is evaluated
In a practical setting, batch-calculation of percent of predicted value for cross-sectional fat area of a 40-yo Female and a 60-yo male might look like this:
# Creating example data metric <- c("CSFA", "CSFA") sex <- c("Female", "Male") level <- c("T5", "T8") age <- c(40, 60) measurement <- c(109, 220) # Actual calculation bodycompref::percent_predicted(metric, sex, level, age, measurement)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.