Adam Lang
Based on ComBatHarmonization and neuroHarmonize
ComGamHarm estimates and removes site-effect for each feature while preserving biological variance. If Empirical Bayes is specified, ComGamHarm can pool information across features and estimate site effect with more accuracy. ComGamHarm utilizes gam models to allow for preservation of non-linear biological variance. This is often important in AD biomarker data as there is a known non-linear relationship between AD biomarkers and age.
ComGamHarm requires cross sectional data in order to estimate site
effect. If a user wants to harmonize longitudinal data, they can first
run ComGamHarm on the cross sectional data and use
ApplyHarm to then harmonize their longitudinal data. Both
the longitudinal data and cross sectional data must have the same batch
labels. This also works with any new data containing the same batch
labels
If you are using this package please cite the follwing papers:
| Cite | Link | |
|---|---|---|
| ComBat for multi-site DTI data | Jean-Philippe Fortin, Drew Parker, Birkan Tunc, Takanori Watanabe, Mark A Elliott, Kosha Ruparel, David R Roalf, Theodore D Satterthwaite, Ruben C Gur, Raquel E Gur, Robert T Schultz, Ragini Verma, Russell T Shinohara. Harmonization Of Multi-Site Diffusion Tensor Imaging Data. NeuroImage, 161, 149-170, 2017 | Here |
| ComBat for multi-site cortical thickness measurements | Jean-Philippe Fortin, Nicholas Cullen, Yvette I. Sheline, Warren D. Taylor, Irem Aselcioglu, Philip A. Cook, Phil Adams, Crystal Cooper, Maurizio Fava, Patrick J. McGrath, Melvin McInnis, Mary L. Phillips, Madhukar H. Trivedi, Myrna M. Weissman, Russell T. Shinohara. Harmonization of cortical thickness measurements across scanners and sites. NeuroImage, 167, 104-120, 2018 | Here |
| Original ComBat paper for gene expression array | W. Evan Johnson and Cheng Li, Adjusting batch effects in microarray expression data using empirical Bayes methods. Biostatistics, 8(1):118-127, 2007. | Here |
| Harmonization of large MRI datasets for the analysis of brain imaging patterns throughout the lifespan | Pomponio, R., Shou, H., Davatzikos, C., et al., (2019). “Harmonization of large MRI datasets for the analysis of brain imaging patterns throughout the lifespan.” Neuroimage 208. | Here |
Both ComGamHarmFunction.R and ComGamHarmFunctionHelpers.R must be downloaded. The following packages must be installed:
install.packages("ggplot2")
install.packages("mgcv")
install.packages("dplyr")
install.packages("reshape2")
install.packages("matrixStats")
install.packages("ebbr")
install.packages("BiocParallel")
install.packages("furniture")ComGamHarm requires the following arguments:
-
feature.data
data.framedata.frame with features for harmonization -
covar.data
data.framedata.frame with covariates for harmonization. All covariates included incovar.datawill be preserved during harmonization.covar.datamust contain a columnSTUDYcorresponding to batch -
eb
logicalwhether or not to perform Empirical Bayesion estimation of site effect.TRUE/FALSEdefaults FALSE -
parametric
logicalparametric EB adjustmentsdefaults TRUE -
smooth.terms
charactervector of non-linear covariates for harmonization Ex:c(“Age”) -
k.val
numericvector of smooth parameters for non-linear covariates for harmonization. Must be ordered in respect tosmooth.terms -
verbose
logicalprint model fit progressdefaults TRUE -
model.diagnostics
logicalreturn gam fit diagnosticsdefaults FALSE
#data generated in DataSimulation.R
#not real medical data.
#first 5 subjects in each Site
knitr::kable(full.simulated.data.cs[c(1:5, 301:306, 601:606),])| ROI1 | ROI2 | ROI3 | ROI4 | Age | Sex | ApoE | Education | STUDY | id |
|---|---|---|---|---|---|---|---|---|---|
| 6560.067 | 1031.1221 | 36833.68 | 15209.550 | 72.19762 | 2 | 1 | 18.47753 | A | 1 |
| 5845.162 | 1044.4538 | 35690.31 | 12440.928 | 73.84911 | 1 | 1 | 17.81281 | A | 2 |
| 4601.741 | 1009.8177 | 33542.62 | 12279.165 | 82.79354 | 2 | 2 | 16.75394 | A | 3 |
| 6633.555 | 1210.9749 | 33618.14 | 11469.827 | 75.35254 | 2 | 2 | 17.23873 | A | 4 |
| 4696.089 | 1412.6101 | 33241.65 | 12656.505 | 75.64644 | 2 | 1 | 17.58859 | A | 5 |
| 5340.044 | 1507.8670 | 39532.46 | 15977.043 | 72.19762 | 2 | 1 | 18.47753 | B | 301 |
| 7050.704 | 1477.6788 | 32607.81 | 16950.297 | 73.84911 | 1 | 1 | 17.81281 | B | 302 |
| 4768.223 | 1367.9741 | 33102.17 | 15598.596 | 82.79354 | 2 | 2 | 16.75394 | B | 303 |
| 5027.141 | 1409.2130 | 34729.24 | 16162.799 | 75.35254 | 2 | 2 | 17.23873 | B | 304 |
| 5470.245 | 1299.2436 | 31844.18 | 15610.725 | 75.64644 | 2 | 1 | 17.58859 | B | 305 |
| 5004.993 | 1345.2858 | 29191.05 | 13891.303 | 83.57532 | 1 | 1 | 11.39115 | B | 306 |
| 4927.961 | 1112.7856 | 33460.39 | 11613.298 | 72.19762 | 2 | 1 | 18.47753 | C | 601 |
| 5268.513 | 1183.4759 | 32266.08 | 13217.589 | 73.84911 | 1 | 1 | 17.81281 | C | 602 |
| 3887.168 | 1079.3900 | 29715.05 | 9979.098 | 82.79354 | 2 | 2 | 16.75394 | C | 603 |
| 5162.835 | 1049.1165 | 35851.78 | 12106.939 | 75.35254 | 2 | 2 | 17.23873 | C | 604 |
| 4852.780 | 1208.9107 | 33630.76 | 11994.121 | 75.64644 | 2 | 1 | 17.58859 | C | 605 |
| 3818.349 | 893.1338 | 31108.71 | 10500.881 | 83.57532 | 1 | 1 | 11.39115 | C | 606 |
#Feature Data
feature.data <- full.simulated.data.cs[,c("ROI1", "ROI2", "ROI3", "ROI4")]
#Covariate Data
covariate.data <- full.simulated.data.cs[,c("Age","Sex", "ApoE", "Education", "STUDY")]
#Harmonize
harmfeats <- ComGamHarm(feature.data = feature.data,
covar.data = covariate.data,
eb = TRUE,
parametric = TRUE,
smooth.terms = c("Age"),
k.val = 5,
verbose = FALSE)Harmonized features are contained in
harmfeats[[“harm.results”]]. They are in matrix format
with dimension n_features X n_observations and must be
transposed to match the original dimensons.
harmonized.features <- as.data.frame(t(harmfeats$harm.results))We can then recombine our new harmonized features with the rest of our data
harm.data <- cbind(harmonized.features, covariate.data)Using ApplyHarm we can apply pre-trained harmonization
models to new data under the condition the new data comes from the same
sites.
ApplyHarm requires the following arguments:
-
feature.data
data.framedata.frame with features for harmonization -
covar.data
data.framedata.frame with covariates for harmonization. All covariates included incovar.datawill be preserved during harmonization.covar.datamust contain a columnSTUDYcorresponding to batch -
comgam.out
listoutput fromComGamHarmfunction
harm.longitudinal <- ApplyHarm(feature.data = feature.data.long,
covariate.data = covariate.data.long,
comgam.out = harmfeats)
harm.longitudinal <- as.data.frame(t(harm.longitudinal))
harm.longitudinal <- cbind(harm.longitudinal, covariate.data.long)






