Description Usage Arguments Value See Also Examples

View source: R/generate_null.R

This function runs `locus`

on data with permuted response sample
labels. A common use is for estimatimation of data-driven false discovery
rates of given thresholds on the posterior probabilities of inclusion.

1 2 3 4 |

`n_perm` |
Number of permuted datasets on which |

`Y` |
Response data matrix (without permuted sample indices) of size n x d, where n is the number of observations and d is the number of response variables. |

`X` |
Input matrix of size n x p, where p is the number of candidate
predictors. |

`p0_av` |
Prior average number of predictors expected to be included in
the model (if |

`Z` |
Covariate matrix of size n x q, where q is the number of
covariates. |

`link` |
Response link. Must be " |

`ind_bin` |
If |

`list_hyper` |
An object of class " |

`list_init` |
An object of class " |

`list_blocks` |
An object of class " |

`user_seed` |
Seed set for reproducible default choices of hyperparameters
(if |

`tol` |
Tolerance for the stopping criterion. |

`maxit` |
Maximum number of iterations allowed. |

`verbose` |
If |

`results_dir` |
Path where the output of each of the |

`n_cpus` |
Number of CPUs to be used. If large, one should ensure that enough RAM will be available for parallel execution. Set to 1 for serial execution. |

If `results_dir`

is `NULL`

, list of length `n_perm`

with each element corresponding to the output of `locus`

on one
permuted dataset. Each contains:

`ind_perm` |
Vector of length n containing the permuted response sample labels. |

`gam_vb` |
Posterior inclusion probability matrix of size p x d. Entry (s, t) corresponds to the posterior probability of association between predictor s and response t. |

`om_vb` |
Vector of length p containing the posterior mean of omega. Entry s controls the proportion of responses associated with candidate predictor s. |

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 | ```
seed <- 123; set.seed(seed)
###################
## Simulate data ##
###################
## Example using small problem sizes:
##
n <- 200; p <- 250; p0 <- 20; d <- 25; d0 <- 20
## Candidate predictors (subject to selection)
##
# Here we simulate common genetic variants (but any type of candidate
# predictors can be supplied).
# 0 = homozygous, major allele, 1 = heterozygous, 2 = homozygous, minor allele
#
X_act <- matrix(rbinom(n * p0, size = 2, p = 0.25), nrow = n)
X_inact <- matrix(rbinom(n * (p - p0), size = 2, p = 0.25), nrow = n)
shuff_x_ind <- sample(p)
X <- cbind(X_act, X_inact)[, shuff_x_ind]
bool_x_act <- shuff_x_ind <= p0
pat_act <- beta <- matrix(0, nrow = p0, ncol = d0)
pat_act[sample(p0*d0, floor(p0*d0/5))] <- 1
beta[as.logical(pat_act)] <- rnorm(sum(pat_act))
## Gaussian responses
##
Y_act <- matrix(rnorm(n * d0, mean = X_act %*% beta, sd = 0.5), nrow = n)
Y_inact <- matrix(rnorm(n * (d - d0), sd = 0.5), nrow = n)
shuff_y_ind <- sample(d)
Y <- cbind(Y_act, Y_inact)[, shuff_y_ind]
########################
## Infer associations ##
########################
list_perm <- generate_null(n_perm = 10, Y, X, p0_av = p0, link = "identity",
user_seed = seed, verbose = FALSE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.