Chapter 2 Preliminery settings
2.1 Installing the package
MetaHD can be download via CRAN as follows:
Alternatively, the development version can be downloaded using GitHub. To install this version, the user needs to make sure that Rtools has been installed and integrated prior.
Along with MetaHD, we will also load the following packages required for the analyses described here.
#To load MetaHD package
library(MetaHD)
#If not installed already, first install the following packages
#install.packages(c("ggplot2","corpcor", "dplyr", "MASS", "Matrix", "matrixcalc", "metafor", "tidyr"))
library(ggplot2)
library(corpcor)
library(dplyr)
library(MASS)
library(Matrix)
library(matrixcalc)
library(metafor)
library(tidyr)
2.2 Preparing the data
There are two ways of preparing the data.
2.2.1 Using summary estimates of the data
To carry out meta-analysis using MetaHD, the user needs to have
- observed effect sizes of the outcomes in the form of a \(K \times N\) matrix, where \(K\) is the number of studies and \(N\) is the number of metabolites, and
- a \(K\)-dimensional list of \(N \times N\) matrices representing within-study covariances in each study. If within-study correlations are not available, the variances can be entered in the form of a \(K \times N\) matrix.
The user can enter these summary estimates directly in the aforementioned format.
2.2.2 Using individual-level data
When individual data are available, the user can use `MetaHDInput’ function in the package to obtain the summary estimates in the above format. To do this, individual data must be in the following data frame format with study and group names as factors in the first and second columns respectively. To demostrate the required format, we have prepared the following dataset (described in section 3.1 in detail) as an R object within the MetaHD package and can be loaded using the following command.
## # A tibble: 6 × 16
## Study Group met1 met2 met3 met4 met5 met6 met7 met8 met9 met10
## <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 GC GroupA 946. 312766 2.49e3 14786 515534 89032 43965 3715 36790 3.38e5
## 2 GC GroupA 4717 351637 1.14e3 19534 849373 146551 57531 4165 47936 5.11e5
## 3 GC GroupA 792. 378899 2.56e5 22832 979930 141221 65416 4342 54750 5.80e5
## 4 GC GroupB 1696. 495334 1.41e5 18590 454416 177805 53282 2120. 31380 2.71e5
## 5 GC GroupB 3842 511079 2.01e5 20856 607470 265593 70361 13680 41824 2.30e5
## 6 GC GroupB 174. 320974 1.01e5 14159 414228 118339 37396 1645. 26373 3.13e5
## # ℹ 4 more variables: met11 <dbl>, met12 <dbl>, met13 <dbl>, met14 <dbl>
Using the above input data format, `MetaHDInput’ function can then calculate the log Ratio of Means (ROM) effect size measures and their within-study covariance matrices as shown below.
## met1 met2 met3 met4 met5 met6
## GC -0.12216161 0.2408217 0.532996014 -0.06407204 -0.46280293 0.39930861
## LC 0.08730353 0.1074026 -0.002691788 -0.06451353 -0.02644625 0.08896313
## met7 met8 met9 met10 met11 met12 met13
## GC -0.03582016 0.3558101 -0.33696133 -0.5623149 0.3591404 0.6540438 0.5257092
## LC 0.08684274 -0.1067551 -0.07022999 0.6563386 0.8378621 0.4823036 0.6567706
## met14
## GC -0.6275364
## LC 0.5955336
## met1 met2 met3 met4 met5
## met1 0.66816536 0.0342995006 -0.13023460 0.042994441 0.0410169309
## met2 0.03429950 0.0219976435 0.04471369 0.007700712 -0.0003259779
## met3 -0.13023460 0.0447136868 0.99714813 0.028561626 -0.0153806902
## met4 0.04299444 0.0077007122 0.02856163 0.027139572 0.0142878276
## met5 0.04101693 -0.0003259779 -0.01538069 0.014287828 0.0456121062
## met6 0.06753777 0.0191195280 0.07398638 0.015472822 0.0042490167
## met6 met7 met8 met9 met10 met11
## met1 0.067537772 0.06644299 0.19414892 0.042673455 -0.001689788 0.047069456
## met2 0.019119528 0.01098242 0.02419960 0.001167182 -0.006991485 0.022944009
## met3 0.073986377 0.02910402 0.02191034 -0.013459772 -0.029697299 0.142481398
## met4 0.015472822 0.01730561 0.03445267 0.012254275 0.005002414 0.022998932
## met5 0.004249017 0.01644365 0.03498665 0.019199078 0.015381516 0.009998191
## met6 0.073516461 0.02205751 0.05878542 0.005020851 -0.010286200 0.044605360
## met12 met13 met14
## met1 -0.0200050944 0.005789995 0.07014588
## met2 0.0075920184 0.011643333 0.01405622
## met3 0.0777879265 0.080134515 0.08293142
## met4 -0.0003712348 0.006499256 0.03996221
## met5 -0.0099810545 -0.003704279 0.04585254
## met6 0.0151338588 0.021938095 0.01626860
## met1 met2 met3 met4 met5
## met1 9.760340e-04 0.001812946 0.001196608 -3.123434e-05 0.0004706615
## met2 1.812946e-03 0.011895588 0.007145803 2.365619e-03 0.0039408463
## met3 1.196608e-03 0.007145803 0.012252935 3.726777e-03 0.0050094004
## met4 -3.123434e-05 0.002365619 0.003726777 4.317303e-03 0.0030995727
## met5 4.706615e-04 0.003940846 0.005009400 3.099573e-03 0.0056326964
## met6 1.807128e-03 0.007574407 0.007296970 2.777669e-03 0.0043877345
## met6 met7 met8 met9 met10
## met1 0.001807128 0.001676030 -0.0003892004 -4.995402e-05 0.009328585
## met2 0.007574407 0.007038615 0.0008048589 2.285953e-03 0.033840530
## met3 0.007296970 0.006681977 0.0021742618 3.692210e-03 0.029804410
## met4 0.002777669 0.002484183 0.0020911477 2.766641e-03 0.008500386
## met5 0.004387734 0.003950886 0.0019668889 2.973791e-03 0.016885650
## met6 0.012068748 0.007401765 0.0010282640 2.644378e-03 0.033995340
## met11 met12 met13 met14
## met1 0.0038770580 0.006042901 0.0016242217 0.004513836
## met2 0.0106508074 0.021850123 0.0038966834 0.014419483
## met3 0.0057550080 0.018648155 0.0014382841 0.010107237
## met4 -0.0008921785 0.005920697 -0.0007960355 0.001814299
## met5 0.0019458596 0.011246777 0.0003337746 0.005426655
## met6 0.0098994407 0.022358561 0.0036476832 0.014163491