Continuous metrics
incremental_r2(true_val, pred_val, covariates=None, return_all_r2=False)
¶
Compute the incremental prediction R^2 (proportion of phenotypic variance explained by the PRS). This metric is computed by taking the R^2 of a model with covariates+PRS and subtracting from it the R^2 of a model with covariates alone covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required | |
covariates
|
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
|
return_all_r2
|
If True, return the R^2 values for the null and full models as well. |
False
|
Returns:
Type | Description |
---|---|
The incremental R^2 value |
Source code in viprs/eval/continuous_metrics.py
mse(true_val, pred_val)
¶
Compute the mean squared error (MSE) between
the predictions or PRS pred_val
and the phenotype true_val
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required |
Returns:
Type | Description |
---|---|
The mean squared error |
Source code in viprs/eval/continuous_metrics.py
partial_correlation(true_val, pred_val, covariates)
¶
Compute the partial correlation between the phenotype true_val
and the PRS pred_val
by conditioning on a set of covariates. This metric is computed by first residualizing the
phenotype and the PRS on a set of covariates and then computing the correlation coefficient
between the residuals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required | |
covariates
|
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
required |
Returns:
Type | Description |
---|---|
The partial correlation coefficient |
Source code in viprs/eval/continuous_metrics.py
pearson_r(true_val, pred_val)
¶
Compute the pearson correlation coefficient between
the predictions or PRS pred_val
and the phenotype true_val
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required |
Returns:
Type | Description |
---|---|
The pearson correlation coefficient |
Source code in viprs/eval/continuous_metrics.py
r2(true_val, pred_val)
¶
Compute the R^2 (proportion of variance explained) between
the predictions or PRS pred_val
and the phenotype true_val
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required |
Returns:
Type | Description |
---|---|
The R^2 value |
Source code in viprs/eval/continuous_metrics.py
r2_residualized_target(true_val, pred_val, covariates)
¶
Compute the R^2 (proportion of variance explained) between
the predictions or PRS pred_val
and the phenotype true_val
after residualizing the phenotype on a set of covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required | |
covariates
|
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
required |
Returns:
Type | Description |
---|---|
The residualized R^2 value |
Source code in viprs/eval/continuous_metrics.py
spearman_r(true_val, pred_val)
¶
Compute the spearman correlation between the predictions or PRS pred_val
and the phenotype true_val
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val
|
The response value or phenotype (a numpy vector) |
required | |
pred_val
|
The predicted value or PRS (a numpy vector) |
required |
Returns:
Type | Description |
---|---|
The spearman correlation |