Package 'SlaPMEG'

Title: Pathway Testing for Longitudinal Omics
Description: A self-contained hypothesis is tested for a given pathway of longitudinal omics. 'SlaPMEG' is a two-step procedure. First, a shared latent process mixed model is fitted over the longitudinal measures of omics in a pathway. This shared model allows deviation from the shared process at subject level (a random intercept, slope, or both per subject) and also at omic level (a random effect per omic). These random effects summarize the longitudinal trend of the observations which can be used to test for group differences using 'Globaltest' in the second step. If the pathway is large or the shared effect is small, the package fits a series of pairwise models and estimates the shared random effects based on them.
Authors: Mitra Ebrahimpoor
Maintainer: Mitra Ebrahimpoor <[email protected]>
License: GPL (>= 2)
Version: 1.0.1
Built: 2024-11-23 06:05:09 UTC
Source: https://github.com/mitra-ep/slapmeg

Help Index


Testing multiple pathways using SLaPMEG (shared latent process mixed effects model and Globaltest) for longitudinal Omics data

Description

Run slapmeg simultaneously for several pathways. For each pathway a p-value is calculated based on SLaPMEG prodcedure as in multslapmeg. Then the p-values are adjusted for multiple comparisons based on the selected procedure.

Usage

multslapmeg(pathlist, fixed, random, grouping, subject, method = "BH", data)

Arguments

pathlist

A list of pathways to be tested.

fixed

A one-sided linear formula object for specifying the fixed-effects in the linear mixed model at the latent process level that starts with the ~ sign.

random

A one-sided formula for the random-effects in the latent process mixed model and starts with the ~ sign. At least one random effect should be included. Covariates with a random-effect are separated by +.

grouping

name of the covariate representing the grouping structure.

subject

name of the covariate representing the repeated measures structure such as subject IDs.

method

Correction method for p-values, the default is "BH". For more methods see?p.adjust.

data

data frame containing the variables named in list of pathlist, fixed, random, grouping and subject.

Value

A datafram including the name of pathways and corresponding adjusted p-values.

Author(s)

Mitra Ebrahimpoor

[email protected]

References

Ebrahimpoor, Mitra, Pietro Spitali, Jelle J. Goeman, and Roula Tsonaka. "Pathway testing for longitudinal metabolomics." Statistics in Medicine (2021).

See Also

slapmeg, pairslapmeg, plotslapmeg

Examples

# simulate data with 20 omics
testdata<-simslapmeg(nY=20, ntime=5, nsubj = 30, seed=123)
head(testdata)

# creat a list of 3 random pathways of different sizes
pathlist<-list(path1=sample(colnames(testdata)[-c(1:3)],5),
              path2=sample(colnames(testdata)[-c(1:3)],11),
              path3=sample(colnames(testdata)[-c(1:3)],9) )


#use mult slampmeg to get test for the differential expression of all pathways
#and get adjusted p-values
mfit<- multslapmeg(pathlist, ~time, ~1+time, grouping="group", subject="ID", data=testdata)
summary(mfit)

Estimating initial values for paired slapmeg based on seperate lme models

Description

A seperate lme model is fited per omic in the pathway and the estimates are combined based on the indexes of pairs to create initial values for the pairslapmeg function.

Usage

pairsetinval(index, fixed, random, subject, data)

Arguments

index

Indexes of pairs used for replacing the parameters in the jopint model

fixed

A two-sided linear formula object for specifying the fixed-effects in the linear mixed model at the latent process level. Names of omics in the pathway are separated by + on the left of ~ and the covariates are separated by + on the right of the ~. For identifiability purposes, the intercept should always be present in the model.

random

A one-sided formula for the random-effects in the latent process mixed model and starts with the ~ sign. At least one random effect should be included. Covariates with a random-effect are separated by +.

subject

name of the covariate representing the repeated measures structure such as subject IDs.

data

data frame containing the variables named in fixed, random, grouping and subject.

Value

A list of vectors, each including vector of initial values corresponding to pairs based on the index file. These vectors will be used as input for multlcmm function of each paired model.

Author(s)

Mitra Ebrahimpoor [email protected]


Testing pathways using SLaPMEG (shared latent process mixed effects model and Globaltest) for longitudinal Omics data based on pairwise estimation approach (a computational solution for latrge pathways)

Description

This function performs pathway testing for longitudinal omics within a two-step framework just as in slapmeg but instead of using a joint shared latent model in the first step, it uses a pairwise approach and runs much faste for larger pathways. After estimating the random effects of the joint model using pairwise fitting, the random effects are used within globaltest to compare the two groups at a pathway level.

Usage

pairslapmeg(fixed, random, grouping, subject, data)

Arguments

fixed

A two-sided linear formula object for specifying the fixed-effects in the linear mixed model at the latent process level. Names of omics in the pathway are separated by + on the left of ~ and the covariates are separated by + on the right of the ~. For identifiability purposes, the intercept should always be present in the model.

random

A one-sided formula for the random-effects in the latent process mixed model and starts with the ~ sign. At least one random effect should be included. Covariates with a random-effect are separated by +.

grouping

name of the covariate representing grouping by the phenotype

subject

name of the covariate representing the repeated measures structure such as subject IDs.

data

data frame containing the variables named in fixed, random, grouping and subject.

Value

A list is returned including:

call

the matched call

nfix

Number of fixed effect terms in the model, excluding the mandatory intercept

nrand

Number of random effect terms in the model

nsubj

Number of subjects in the sataset

nrep

Table of repeated measures, and number of subjects with the specified number of repeated measures

tgroup

Table of grouping, and number of subjects in each group

Ynames

Name of the Omics in the pathway

slapconv

Status of convergence: For joint method(=1 if the convergence criteria were satisfied, =2 if the maximum number of iterations was reached, =4 or 5 if a problem occured during optimisation); for the pairwise method, proportion of successfully converged pairs is reported

fixedform

Names of Fixed effect terms

randform

Names of random effect terms

slapmethod

The method which is "joint" if the original slapmeg approach is adopted and pairwise for the pairwise method

SLaP.par

Fitted values for the parameters in the joint class mixed model in the first step

Globaltest

The output from Globaltest at the second step

EB_pred

Empirical bayes estimates for the random effects from the joint model

Author(s)

Mitra Ebrahimpoor

[email protected]

References

Ebrahimpoor, Mitra, Pietro Spitali, Jelle J. Goeman, and Roula Tsonaka. "Pathway testing for longitudinal metabolomics." Statistics in Medicine (2021).

See Also

slapmeg, multslapmeg, plotslapmeg

Examples

# simulate data with 15 omics
testdata<-simslapmeg(nY=25, ntime=3, nsubj = 30, seed=123)
head(testdata)

#fit slapmeg to test for the differential expression of a pathway of size 15
slapmegfit<- pairslapmeg(Y1+Y2+Y6+Y7+Y8~time, ~1, grouping="group", subject="ID", data=testdata)
slapmegfit
summary(slapmegfit)

Plot the estimated random effects from SLaPMEG seperated for the study groups

Description

This plot can provide a graphical insight into the source of effect (i.e. diffrential expression) in relevent pathway.

Usage

plotslapmeg(obj, ...)

Arguments

obj

An slapmeg object which is the output from slapmeg or pairslapmeg. Note that the fullreturn=TRUE) must have been used.

...

optional graphical parameters can be added with an + based on ggplot2 structure.

Value

returns NULL

Author(s)

Mitra Ebrahimpoor

[email protected]

References

Ebrahimpoor, Mitra, Pietro Spitali, Jelle J. Goeman, and Roula Tsonaka. "Pathway testing for longitudinal metabolomics." Statistics in Medicine (2021).

See Also

slapmeg, multslapmeg, pairslapmeg

Examples

# simulate data with 8 omics
testdata<-simslapmeg(nY=8, ntime=5, nsubj = 30, seed=123)
head(testdata)

#fit slapmeg to test for the differential expression of a pathway of size 5
fit<- slapmeg(Y1+Y2+Y6+Y7+Y8~time, ~1, grouping="group", subject="ID", data=testdata)

#Density plots for the estimated random effects
plotslapmeg(fit)

Print objects from multslapmeg

Description

Provides an overview of mSLaPMEG results for each pathway through multslapmeg object.

Usage

## S3 method for class 'mslapmeg'
print(x, ...)

Arguments

x

an object inheriting from class multslapmeg

...

further arguments to be passed to or from other methods, which will be ignored in this function.

Value

Returns result summary of mSLAPMEG approach

Author(s)

Mitra Ebrahimpoor

See Also

multslapmeg,slapmeg, pairslapmeg


Print objects from slapmeg

Description

Provides an overview of SLaPMEG approach through slapmeg and pairslapmeg objects.

Usage

## S3 method for class 'slapmeg'
print(x, ...)

Arguments

x

an object inheriting from class slapmeg

...

further arguments to be passed to or from other methods, which will be ignored in this function.

Value

Returns result summaries of SLAPMEG approach

Author(s)

Mitra Ebrahimpoor

See Also

slapmeg, pairslapmeg


Estimating initial values for slapmeg based on seperate lme models

Description

A seperate lme model is fited per omic in the pathway and the estimates are combined to create initial values for the slapmeg function.

Usage

setinval(fixed, random, subject, data)

Arguments

fixed

A two-sided linear formula object for specifying the fixed-effects in the linear mixed model at the latent process level. Names of omics in the pathway are separated by + on the left of ~ and the covariates are separated by + on the right of the ~. For identifiability purposes, the intercept should always be present in the model.

random

A one-sided formula for the random-effects in the latent process mixed model and starts with the ~ sign. At least one random effect should be included. Covariates with a random-effect are separated by +.

subject

name of the covariate representing the repeated measures structure such as subject IDs.

data

data frame containing the variables named in fixed, random, grouping and subject.

Value

A vector of initial values to be used as input for multlcmm function

Author(s)

Mitra Ebrahimpoor

[email protected]


Simulate longitudinal data based on a shared latent process mixed effects model (SlaPMEG)

Description

This is a simple function to simulate longitudinal data from a shared latent process mixed effects model the data provides a good example for application of slapmeg and pairslapmeg and pairslapmeg objects.

Usage

simslapmeg(
  nY,
  ntime,
  nsubj,
  pDif = 1/3,
  fixed = ~1 + time,
  random = ~1 + time,
  fixedbeta = c(0, 2),
  randbeta = c(0, 2),
  group,
  groupbeta = 2,
  sigma.b,
  sigma.u,
  seed = as.integer(runif(1, 0, .Machine$integer.max)),
  returnpar = FALSE
)

Arguments

nY

number of omics in the data

ntime

number of repeated measures

nsubj

number of subjects

pDif

proportion of differentially expressed omics in the data (the default is 1/3)

fixed

A one-sided formula for the fixed-effects excluding the group variable, the default includes an intercept and time

random

A one-sided formula for the random-effects, the default includes an intercept and time

fixedbeta

effect size of fixed terms in formula, the length should match the fixed formula, the default is 0 (intercept) and 2 (time)

randbeta

effect size of random terms in formula, the length should match the random formula, the default is 0 (intercept) and 2 (time)

group

Vector indicating group membership, the length should match the number of subjects, The default is random allocation of half of subjects to each group. If use with slapmeg is intended, the group variable should have only two groups

groupbeta

effect size of group variable, the default is 2

sigma.b

variance of the omic- / subject- specific random effects, the length should math nY. If not specified, nY values from normal distribution will be randomly assigned.

sigma.u

Variance of the subject-specific random effects, the length should math the random effects defined in random formula. If not specified, 2 values from normal distribution will be randomly assigned.

seed

Value of seed, if not specified a random integer will be assigned

returnpar

logical if TRUE, all simulation parameters will be returned along with the simulated data.

Value

Returns a dataframe where the rows represent the observations and the columns represent the subject Id, time and group variable followed by the omics in pathway; if returnpar is TRUE, a list with both data and parametrs is returned

Author(s)

Mitra Ebrahimpoor

See Also

slapmeg, pairslapmeg


Run step II via globaltest package

Description

Globaltest is used to test the association between phenotype variable and estimated random effects from step I.

Usage

slapGT(EBS, data_inf, rand_nam, Ynames, grouping, Emethod)

Arguments

EBS

Estimated random effects by either joint or pairwise approach

data_inf

Dataframe with variables required for the test

rand_nam

Names of random effects defined in model

Ynames

Name of omics in pathway

grouping

Name of the covariate representing the grouping by the phenotype

Emethod

Estimation method for the random effects which is either joint or pairwise

Value

A GT object containing globaltest results

Author(s)

Mitra Ebrahimpoor

[email protected]


Testing pathways using SLaPMEG (shared latent process mixed effects model and Globaltest) for longitudinal Omics data

Description

A two-step procedure is adopted, first a joint latent process mixed effects model is fitted and on the longitudinal data to summarize the temporal trend in terms of several random effects. For computational efficacy, if the size of pathway is larger than 10 a paired approah is used to estimate the random effects with the pairslapmeg function. The random effects are the input for globaltest which is used to compare the two groups at a pathway level.

Usage

slapmeg(fixed, random, grouping, subject, data, nlimit = 10)

Arguments

fixed

A two-sided linear formula object for specifying the fixed-effects in the linear mixed model at the latent process level. Names of omics in the pathway are separated by + on the left of ~ and the covariates are separated by + on the right of the ~. For identifiability purposes, the intercept should always be present in the model.

random

A one-sided formula for the random-effects in the latent process mixed model and starts with the ~ sign. At least one random effect should be included. Covariates with a random-effect are separated by +.

grouping

name of the covariate representing grouping by the phenotype

subject

name of the covariate representing the repeated measures structure such as subject IDs.

data

data frame containing the variables named in fixed, random, grouping and subject.

nlimit

A controling arguments telling slapmeg to use pairwise approach for pathways larger than this value, default is 10. Note: fitting the joint model may take long for pathways larger than 20 omics.

Value

A list is returned including:

call

the matched call

nfix

Number of fixed effect terms in the model, excluding the mandatory intercept

nrand

Number of random effect terms in the model

nsubj

Number of subjects in the sataset

nrep

Table of repeated measures, and number of subjects with the specified number of repeated measures

tgroup

Table of grouping, and number of subjects in each group

Ynames

Name of the Omics in the pathway

slapconv

Status of convergence: For joint method(=1 if the convergence criteria were satisfied, =2 if the maximum number of iterations was reached, =4 or 5 if a problem occured during optimisation); for the pairwise method, proportion of successfully converged pairs is reported

fixedform

Names of Fixed effect terms

randform

Names of random effect terms

slapmethod

The method which is "joint" if the original slapmeg approach is adopted and pairwise for the pairwise method

SLaP.par

Fitted values for the parameters in the joint class mixed model in the first step

Globaltest

The output from Globaltest at the second step

EB_pred

Empirical bayes estimates for the random effects from the joint model

Author(s)

Mitra Ebrahimpoor

[email protected]

References

Ebrahimpoor, Mitra, Pietro Spitali, Jelle J. Goeman, and Roula Tsonaka. "Pathway testing for longitudinal metabolomics." Statistics in Medicine (2021).

See Also

multslapmeg, pairslapmeg, plotslapmeg

Examples

# simulate data with 8 omics
testdata<-simslapmeg(nY=8, ntime=5, nsubj = 30, seed=123)
head(testdata)

#fit slapmeg to test for the differential expression of a pathway of size 5
fit<- slapmeg(Y1+Y2+Y6+Y7+Y8~time, ~1, grouping="group", subject="ID", data=testdata)
fit
summary(fit)

Summary of slapmeg objects

Description

Provides a table of sorted p-values for the output of multSLaPMEG approach within multslapmeg objects.

Usage

## S3 method for class 'mslapmeg'
summary(object, n = 5, ...)

Arguments

object

an object inheriting from classes multslapmeg

n

an integer indicating number of pathways to be printed the default is 5

...

further arguments to be passed to or from other methods, which will be ignored in this function.

Value

'Returns the fixed effect estimates and random effects variances from the model in step 1 and the details of Globaltest along with p-value from step 2.

Author(s)

Mitra Ebrahimpoor

See Also

multslapmeg, pairslapmeg,


Summary of slapmeg objects

Description

Provides a summary of values estimated with SLaPMEG approach within slapmeg and pairslapmeg objects.

Usage

## S3 method for class 'slapmeg'
summary(object, ...)

Arguments

object

an object inheriting from classes slapmeg

...

further arguments to be passed to or from other methods, which will be ignored in this function.

Value

'Returns the fixed effect estimates and random effects variances from the model in step 1 and the details of Globaltest along with p-value from step 2.

Author(s)

Mitra Ebrahimpoor

See Also

slapmeg, pairslapmeg,