MHEdge: mhEdge

Description Usage Arguments Value References Examples

Description

The main function for the Metropolis-Hastings algorithm. It returns the posterior distribution of the edge directions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mhEdge(
  data,
  adjMatrix,
  prior = c(0.05, 0.05, 0.9),
  nCPh = 0,
  nGV = 0,
  pmr = FALSE,
  burnIn = 0.2,
  iterations = 1000,
  thinTo = 200,
  progress = TRUE
)

Arguments

data

A matrix with the variables across the columns and the observations down the rows. If there are genetic variants in the data these variables must come before the remaining variables. If there are clinical phenotypes in the data these variables must come after all other variables. For example, if there is a data set with one genetic variant variable, three gene expression variables, and one clinical phenotype variable the first column in the data matrix must contain the genetic variant data, the next three columns will contain the gene expression data, and the last column will contain the clinical phenotype data.

adjMatrix

An adjacency matrix indicating the edges that will be considered by the Metropolis-Hastings algorithm. An adjacency matrix is a matrix of zeros and ones. The ones represent an edge and its direction between two nodes.

prior

A vector containing the prior probability for the three edge states.

nCPh

The number of clinical phenotypes in the graph.

nGV

The number of genetic variants in the graph.

pmr

Logical. If true the Metropolis-Hastings algorithm will use the Principle of Mendelian Randomization (PMR). This prevents the direction of an edge pointing from a gene expression or a clinical phenotype node to a genetic variant node.

burnIn

A number between 0 and 1 indicating the percentage of the sample that will be discarded.

iterations

An integer for the number of iterations to run the MH algorithm.

thinTo

An integer indicating the number of observations the chain should be thinned to.

progress

Logical. If TRUE the runtime in seconds for the cycle finder and log likelihood functions and a progress bar will be printed.

Value

An object of class baycn containing 9 elements:

References

Martin, E. A. and Fu, A. Q. (2019). A Bayesian approach to directed acyclic graphs with a candidate graph. arXiv preprint arXiv:1909.10678.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Generate data under topology m1_gv.
# Use ?simdata for a description and graph of m1_gv.
data_m1 <- simdata(b0 = 0,
                   N = 200,
                   s = 1,
                   graph = 'm1_gv',
                   ss = 1,
                   q = 0.27)

# Create an adjacency matrix with the true edges.
am_m1 <- matrix(c(0, 1, 0,
                  0, 0, 1,
                  0, 0, 0),
                byrow = TRUE,
                nrow = 3)

# Run the Metropolis-Hastings algorithm on the data from m1_gv using the
# Principle of Mendelian Randomization (PMR) and the true edges as the input.
mh_m1_pmr <- mhEdge(data = data_m1,
                    adjMatrix = am_m1,
                    prior = c(0.05,
                              0.05,
                              0.9),
                    nCPh = 0,
                    nGV = 1,
                    pmr = TRUE,
                    burnIn = 0.2,
                    iterations = 1000,
                    thinTo = 200,
                    progress = FALSE)

summary(mh_m1_pmr)

# Generate data under topology gn4.
# Use ?simdata for a description and graph of gn4.
data_gn4 <- simdata(b0 = 0,
                    N = 200,
                    s = 1,
                    graph = 'gn4',
                    ss = 1)

# Create an adjacency matrix with the true edges.
am_gn4 <- matrix(c(0, 1, 1, 0,
                   0, 0, 0, 1,
                   0, 0, 0, 0,
                   0, 0, 1, 0),
                 byrow = TRUE,
                 nrow = 4)

# Run the Metropolis-Hastings algorithm on the data from gn4 with the true
# edges as the input.
mh_gn4 <- mhEdge(data = data_gn4,
                 adjMatrix = am_gn4,
                 prior = c(0.05,
                           0.05,
                           0.9),
                 nCPh = 0,
                 nGV = 0,
                 pmr = FALSE,
                 burnIn = 0.2,
                 iterations = 1000,
                 thinTo = 200,
                 progress = FALSE)

summary(mh_gn4)

Evatar/baycn documentation built on Aug. 1, 2020, 6:31 p.m.