Learn R Programming

PredictABEL (version 1.2-4)

plotRiskscorePredrisk: Function to plot predicted risks against risk scores.

Description

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

Usage

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.

Value

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

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.

See Also

riskScore, predRisk

Examples

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataLab