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 package to run the analyses described here.
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.
## Study Group met1 met2 met3 met4 met5 met6 met7 met8 met9 met10
## 1 study1 Group2 6799 7786 2094 5015 94588 29059 59943 10766 57238 53146
## 2 study1 Group2 17473 15277 1229 2336 183357 42891 87805 9667 132990 76963
## 3 study1 Group2 38267 7794 1021 1509 189323 54100 92716 11704 75001 129903
## 4 study1 Group2 12027 9810 2840 4757 158568 61752 67235 13161 97882 88858
## 5 study1 Group2 19565 12725 1946 6757 109405 53814 105437 10540 91196 108946
## 6 study1 Group2 20174 18446 3155 13223 125119 51873 78343 12801 123272 96326
## met11 met12 met13 met14
## 1 18014 12783 44527 24969
## 2 34100 19631 8522 80978
## 3 25723 22843 7347 94906
## 4 33773 19223 13057 94041
## 5 27941 35500 14638 92369
## 6 35185 28896 13847 82009
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.
input_data <- MetaHDInput(example_data)
#To obtain effect sizes of the two studies
Y <- input_data$Y
Y
## met1 met2 met3 met4 met5 met6
## study1 -0.08509765 0.0693374 0.21205246 0.1555140 -0.07131115 -0.010729262
## study2 -0.19103975 0.1985993 0.05266387 0.3042082 -0.08507508 -0.002200277
## met7 met8 met9 met10 met11 met12
## study1 -0.06351313 0.07239534 -0.02854481 -0.1874413 0.07670815 -0.04170964
## study2 -0.02427915 -0.08497286 -0.10315078 -0.1196099 0.07105905 0.21213759
## met13 met14
## study1 0.3378766 -0.20944830
## study2 0.2136121 -0.03345043
## met1 met2 met3 met4 met5
## met1 0.0194438538 0.0005017922 -0.0025219163 -0.002766591 0.004992537
## met2 0.0005017922 0.0161291933 0.0042058671 0.019843118 0.002535913
## met3 -0.0025219163 0.0042058671 0.0078052190 0.007030307 -0.001285968
## met4 -0.0027665912 0.0198431182 0.0070303073 0.074406890 -0.003247293
## met5 0.0049925375 0.0025359133 -0.0012859676 -0.003247293 0.007725915
## met6 0.0036952818 0.0035899796 0.0007582538 0.004244171 0.003155352
## met6 met7 met8 met9 met10
## met1 0.0036952818 0.0036649961 0.0014738763 0.002466527 0.006057970
## met2 0.0035899796 0.0023004763 0.0009291760 0.003908964 0.001622693
## met3 0.0007582538 -0.0002967142 0.0010746462 0.001839553 -0.002939468
## met4 0.0042441714 0.0033677211 0.0053704235 0.004464203 -0.001121570
## met5 0.0031553517 0.0026034856 -0.0006582206 0.002925312 0.005845677
## met6 0.0035383608 0.0025416742 0.0003542152 0.003045991 0.003098343
## met11 met12 met13 met14
## met1 0.003742686 0.0058389366 -0.017656900 0.006189749
## met2 0.006128897 0.0057661483 -0.015584915 0.002615291
## met3 0.002551313 0.0003375944 0.001663327 -0.001850528
## met4 0.005545238 0.0033374745 -0.012707585 0.001019416
## met5 0.004305489 0.0060072612 -0.020351263 0.004988612
## met6 0.003080440 0.0039539767 -0.012411644 0.003099160
## met1 met2 met3 met4 met5
## met1 0.0109767710 -0.0033067379 -0.0012616785 -0.0083336759 0.0003922567
## met2 -0.0033067379 0.0146428884 0.0037077689 0.0159669413 -0.0003152230
## met3 -0.0012616785 0.0037077689 0.0056022748 0.0053436283 0.0002016495
## met4 -0.0083336759 0.0159669413 0.0053436283 0.0622328293 -0.0055739904
## met5 0.0003922567 -0.0003152230 0.0002016495 -0.0055739904 0.0058255205
## met6 -0.0001745795 -0.0003574126 0.0001652289 0.0001864308 -0.0005042725
## met6 met7 met8 met9 met10
## met1 -0.0001745795 0.0006382287 7.832299e-04 0.0003470474 0.0020580008
## met2 -0.0003574126 -0.0007568195 1.738323e-04 0.0007167777 -0.0013939525
## met3 0.0001652289 0.0005244583 1.013833e-03 0.0012836425 -0.0020003745
## met4 0.0001864308 0.0022826581 3.107372e-03 -0.0013166970 -0.0049094301
## met5 -0.0005042725 -0.0001647809 6.540804e-04 0.0002988824 0.0019182789
## met6 0.0005793504 0.0003004147 -4.307803e-05 -0.0002222715 -0.0002523751
## met11 met12 met13 met14
## met1 -0.0010302778 0.0003585147 -9.433404e-05 0.0014432093
## met2 0.0022314227 0.0008032427 -2.013680e-04 -0.0001315375
## met3 0.0036313545 0.0013803512 -6.784827e-04 -0.0009400033
## met4 0.0023315513 0.0002988431 -3.343779e-03 -0.0017646934
## met5 0.0014421682 0.0004770191 -2.735012e-03 0.0013558693
## met6 -0.0001936851 -0.0002078362 1.382371e-04 -0.0001396999