HyperparameterGrid
HyperparameterGrid
¶
Bases: object
A utility class to facilitate generating grids for the
hyperparameters of the standard VIPRS
models. It is designed to
interface with models that operate on grids of hyperparameters,
such as VIPRSGridSeach
and VIPRSBMA
. The hyperparameters for
the standard VIPRS model are:
sigma_epsilon
: The residual variance for the phenotype.tau_beta
: The precision (inverse variance) of the prior for the effect sizes.pi
: The proportion of non-zero effect sizes (polygenicity).
Attributes:
Name | Type | Description |
---|---|---|
sigma_epsilon |
A grid of values for the residual variance hyperparameter. |
|
tau_beta |
A grid of values for the precision of the prior for the effect sizes. |
|
pi |
A grid of values for the proportion of non-zero effect sizes. |
|
h2_est |
An estimate of the heritability for the trait under consideration. |
|
h2_se |
The standard error of the heritability estimate. |
|
n_snps |
The number of common variants that may be relevant for this analysis. |
Source code in viprs/model/gridsearch/HyperparameterGrid.py
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
__init__(sigma_epsilon_grid=None, sigma_epsilon_steps=None, tau_beta_grid=None, tau_beta_steps=None, pi_grid=None, pi_steps=None, h2_est=None, h2_se=None, n_snps=1000000.0)
¶
Create a hyperparameter grid for the standard VIPRS model with the spike-and-slab prior. The hyperparameters for this model are:
sigma_epsilon
: The residual variancetau_beta
: The precision (inverse variance) of the prior for the effect sizespi
: The proportion of non-zero effect sizes
For each of these hyperparameters, we can provide a grid of values to search over. If the heritability estimate and standard error (from e.g. LDSC) are provided, we can generate grids for sigma_epsilon and tau_beta that are informed by these estimates.
For each hyperparameter to be included in the grid, user must specify either the grid itself, or the number of steps to use to generate the grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sigma_epsilon_grid |
An array containing a grid of values for the sigma_epsilon hyperparameter. |
None
|
|
sigma_epsilon_steps |
The number of steps for the sigma_epsilon grid |
None
|
|
tau_beta_grid |
An array containing a grid of values for the tau_beta hyperparameter. |
None
|
|
tau_beta_steps |
The number of steps for the tau_beta grid |
None
|
|
pi_grid |
An array containing a grid of values for the pi hyperparameter |
None
|
|
pi_steps |
The number of steps for the pi grid |
None
|
|
h2_est |
An estimate of the heritability for the trait under consideration. If provided, we can generate grids for some of the hyperparameters that are consistent with this estimate. |
None
|
|
h2_se |
The standard error of the heritability estimate. If provided, we can generate grids for some of the hyperparameters that are consistent with this estimate. |
None
|
|
n_snps |
Number of common variants that may be relevant for this analysis. This estimate can be used to generate grids that are based on this number. |
1000000.0
|
Source code in viprs/model/gridsearch/HyperparameterGrid.py
combine_grids()
¶
Weave together the different hyperparameter grids and return a list of dictionaries where the key is the hyperparameter name and the value is value for that hyperparameter.
Returns:
Type | Description |
---|---|
A list of dictionaries containing the hyperparameter values. |
Raises:
Type | Description |
---|---|
ValueError
|
If all the grids are empty. |
Source code in viprs/model/gridsearch/HyperparameterGrid.py
generate_pi_grid(steps=5)
¶
Generate a grid of values for the pi
(proportion of non-zero effect sizes) hyperparameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps |
The number of steps for the |
5
|
Source code in viprs/model/gridsearch/HyperparameterGrid.py
generate_sigma_epsilon_grid(steps=5)
¶
Generate a grid of values for the sigma_epsilon
(residual variance) hyperparameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps |
The number of steps for the sigma_epsilon grid. |
5
|
Source code in viprs/model/gridsearch/HyperparameterGrid.py
generate_tau_beta_grid(steps=5)
¶
Generate a grid of values for the tau_beta
(precision of the prior for the effect sizes) hyperparameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps |
The number of steps for the |
5
|
Source code in viprs/model/gridsearch/HyperparameterGrid.py
to_table()
¶
Returns:
Type | Description |
---|---|
The hyperparameter grid as a pandas |