Function to plot predicted risks against risk scores.

Share:

Description

This function is used to make a plot of predicted risks against risk scores.

Usage

1
2
plotRiskscorePredrisk(data, riskScore, predRisk, plottitle, xlabel, 
ylabel, rangexaxis, rangeyaxis, filename, fileplot, plottype)

Arguments

data

Data frame or matrix that includes the outcome and predictors variables.

riskScore

Vector of (weighted or unweighted) genetic risk scores.

predRisk

Vector of predicted risks.

plottitle

Title of the plot. Specification of plottitle is optional. Default is "Risk score predicted risk plot".

xlabel

Label of x-axis. Specification of xlabel is optional. Default is "Risk score".

ylabel

Label of y-axis. Specification of ylabel is optional. Default is "Predicted risk".

rangexaxis

Range of the x axis. Specification of rangexaxis is optional.

rangeyaxis

Range of the y axis. Specification of rangeyaxis is optional. Default is c(0,1).

filename

Name of the output file in which risk scores and predicted risks for each individual will be saved. If no directory is specified, the file is saved in the working directory as a txt file. When no filename is specified, the output is not saved.

fileplot

Name of the output file that contains the plot. The file is saved in the working directory in the format specified under plottype. Example: fileplot="plotname". Note that the extension is not specified here. When fileplot is not specified, the plot is not saved.

plottype

The format in which the plot is saved. Available formats are wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps, eps or pdf. For example, plottype="eps" will save the plot in eps format. When plottype is not specified, the plot will be saved in jpg format.

Details

The function creates a plot of predicted risks against risk scores. Predicted risks can be obtained using the functions fitLogRegModel and predRisk or be imported from other methods or packages. The function riskScore can be used to compute unweighted or weighted risk scores.

Value

The function creates a plot of predicted risks against risk scores.

See Also

riskScore, predRisk

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
# specify dataset with outcome and predictor variables
data(ExampleData)

# fit a logistic regression  model
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel <- ExampleModels()$riskModel2

# obtain predicted risks
predRisk <- predRisk(riskmodel)

# specify column numbers of genetic predictors
cGenPred <- c(11:16)

# function to compute unweighted genetic risk scores
riskScore <- riskScore(weights=riskmodel, data=ExampleData, 
cGenPreds=cGenPred, Type="unweighted")

# specify range of x-axis
rangexaxis <- c(0,12)   
# specify range of y-axis
rangeyaxis <- c(0,1)     
# specify label of x-axis
xlabel <- "Risk score"     
# specify label of y-axis
ylabel <- "Predicted risk" 
# specify title for the plot
plottitle <- "Risk score versus predicted risk"

# produce risk score-predicted risk plot
plotRiskscorePredrisk(data=ExampleData, riskScore=riskScore, predRisk=predRisk, 
plottitle=plottitle, xlabel=xlabel, ylabel=ylabel, rangexaxis=rangexaxis, 
rangeyaxis=rangeyaxis, filename="RiskscorePredRisk.txt")