| Title: | Risk Score Plot for Cox Regression | 
| Version: | 1.3 | 
| Description: | The risk plot may be one of the most commonly used figures in tumor genetic data analysis. We can conclude the following two points: Comparing the prediction results of the model with the real survival situation to see whether the survival rate of the high-risk group is lower than that of the low-level group, and whether the survival time of the high-risk group is shorter than that of the low-risk group. The other is to compare the heat map and scatter plot to see the correlation between the predictors and the outcome. | 
| License: | GPL-2 | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.1.1 | 
| Depends: | R (≥ 2.10) | 
| Imports: | ggplot2, survival, egg, do, set, cutoff, grid, rms, nomogramFormula, reshape2 | 
| URL: | https://github.com/yikeshu0611/ggrisk | 
| BugReports: | https://github.com/yikeshu0611/ggrisk/issues | 
| NeedsCompilation: | no | 
| Packaged: | 2021-08-07 14:40:20 UTC; asus | 
| Author: | Jing Zhang [aut, cre], Zhi Jin [aut] | 
| Maintainer: | Jing Zhang <zj391120@163.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2021-08-09 07:40:06 UTC | 
ICGC Liver Data from Japan
Description
This data is a liver cancer data from Japan Data released in ICGC database (Link). It cantains time, event and four genes.
Usage
data(LIRI)
Format
An object of class data.frame with 232 rows and 6 columns.
Examples
data(LIRI)
Risk Score Plot for Cox Regression
Description
Risk Score Plot for Cox Regression
Usage
ggrisk(
  fit,
  heatmap.genes = NULL,
  new.data = NULL,
  code.0 = "Alive",
  code.1 = "Dead",
  code.highrisk = "High",
  code.lowrisk = "Low",
  cutoff.show = TRUE,
  cutoff.value = "median",
  cutoff.x = NULL,
  cutoff.y = NULL,
  cutoff.label = NULL,
  title.A.ylab = "Risk Score",
  title.B.ylab = "Survival Time",
  title.A.legend = "Risk Group",
  title.B.legend = "Status",
  title.C.legend = "Expression",
  size.ABC = 1.5,
  size.ylab.title = 14,
  size.Atext = 11,
  size.Btext = 11,
  size.Ctext = 11,
  size.yticks = 0.5,
  size.yline = 0.5,
  size.points = 2,
  size.dashline = 1,
  size.cutoff = 5,
  size.legendtitle = 13,
  size.legendtext = 12,
  color.A = c(low = "blue", high = "red"),
  color.B = c(code.0 = "blue", code.1 = "red"),
  color.C = c(low = "blue", median = "white", high = "red"),
  vjust.A.ylab = 1,
  vjust.B.ylab = 2,
  family = "sans",
  expand.x = 3,
  relative_heights = c(0.1, 0.1, 0.01, 0.15)
)
Arguments
fit | 
 cox regression results of coxph() from 'survival' package or cph() from 'rms' package  | 
heatmap.genes | 
 (optional) numeric variables. Name for genes  | 
new.data | 
 new data for validation  | 
code.0 | 
 string. Code for event 0. Default is 'Alive'  | 
code.1 | 
 string. Code for event 1. Default is 'Dead'  | 
code.highrisk | 
 string. Code for highrisk in risk score. Default is 'High'  | 
code.lowrisk | 
 string. Code for lowrisk in risk score. Default is 'Low'  | 
cutoff.show | 
 logical, whether to show text for cutoff in figure A. Default is TRUE  | 
cutoff.value | 
 string, which can be 'median', 'roc' or 'cutoff'. Even you can define it by yourself  | 
cutoff.x | 
 numeric (optional), ordination x for cutoff text  | 
cutoff.y | 
 numeric (optional), ordination y for cutoff text  | 
cutoff.label | 
 (should be) string. Define cutoff label by yourself  | 
title.A.ylab | 
 string, y-lab title for figure A. Default is 'Risk Score'  | 
title.B.ylab | 
 string, y-lab title for figure B. Default is 'Survival Time'  | 
title.A.legend | 
 string, legend title for figure A. Default is 'Risk Group'  | 
title.B.legend | 
 string, legend title for figure B. Default is 'Status'  | 
title.C.legend | 
 string, legend title for figure C. Default is 'Expression'  | 
size.ABC | 
 numeric, size for ABC. Default is 1.5  | 
size.ylab.title | 
 numeric, size for y-axis label title. Default is 14  | 
size.Atext | 
 numeric, size for y-axis text in figure A. Default is 11  | 
size.Btext | 
 numeric, size for y-axis text in figure B. Default is 11  | 
size.Ctext | 
 numeric, size for y-axis text in figure C. Default is 11  | 
size.yticks | 
 numeric, size for y-axis ticks. Default is 0.5  | 
size.yline | 
 numeric, size for y-axis line. Default is 0.5  | 
size.points | 
 numeric, size for scatter points. Default is 2  | 
size.dashline | 
 numeric, size for dashline. Default is 1  | 
size.cutoff | 
 numeric, size for cutoff text. Default is 5  | 
size.legendtitle | 
 numeric, size for legend title. Default is 13  | 
size.legendtext | 
 numeric, size for legend text. Default is 12  | 
color.A | 
 color for figure A. Default is low = 'blue', high = 'red'  | 
color.B | 
 color for figure B. Default is code.0 = 'blue', code.1 = 'red'  | 
color.C | 
 color for figure C. Default is low = 'blue', median = 'white', high = 'red'  | 
vjust.A.ylab | 
 numeric, vertical just for y-label in figure A. Default is 1  | 
vjust.B.ylab | 
 numeric, vertical just for y-label in figure B. Default is 2  | 
family | 
 family, default is sans  | 
expand.x | 
 numeric, expand for x-axis  | 
relative_heights | 
 numeric, relative heights for figure A, B, colored side bar and heatmap. Default is 0.1 0.1 0.01 and 0.15  | 
Value
A risk score picture
Examples
library(rms)
library(ggrisk)
fit <- cph(Surv(time,status)~ANLN+CENPA+GPR182+BCO2,LIRI)
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8)
#more detailed example
#plot
ggrisk(fit)
#heatmap.genes
ggrisk(fit,
       heatmap.genes=c('GPR182','CENPA','BCO2'))
#cutoff
ggrisk(fit,
       cutoff.value='median') #default
ggrisk(fit,
       cutoff.value='roc')
ggrisk(fit,
       cutoff.value='cutoff')
ggrisk(fit,
       cutoff.value=-1)
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8)
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       cutoff.label='This is cutoff')
#code for 0 and 1
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead')
#code for high and low risk group
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk')
#title
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk',
       title.A.ylab='Risk Score',
       title.B.ylab='Survival Time(year)',
       title.A.legend='Risk Group',
       title.B.legend='Status',
       title.C.legend='Expression')
#size
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk',
       title.A.ylab='Risk Score',
       title.B.ylab='Survival Time(year)',
       title.A.legend='Risk Group',
       title.B.legend='Status',
       title.C.legend='Expression',
       size.ABC=1.5,
       size.ylab.title=14,
       size.Atext=11,
       size.Btext=11,
       size.Ctext=11,
       size.yticks=0.5,
       size.yline=0.5,
       size.points=2,
       size.dashline=1,
       size.cutoff=5,
       size.legendtitle=13,
       size.legendtext=12)
#color
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk',
       title.A.ylab='Risk Score',
       title.B.ylab='Survival Time(year)',
       title.A.legend='Risk Group',
       title.B.legend='Status',
       title.C.legend='Expression',
       size.ABC=1.5,
       size.ylab.title=14,
       size.Atext=11,
       size.Btext=11,
       size.Ctext=11,
       size.yticks=0.5,
       size.yline=0.5,
       size.points=2,
       size.dashline=1,
       size.cutoff=5,
       size.legendtitle=13,
       size.legendtext=12,
       color.A=c(low='blue',high='red'),
       color.B=c(code.0='blue',code.1='red'),
       color.C=c(low='blue',median='white',high='red'))
#vjust
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk',
       title.A.ylab='Risk Score',
       title.B.ylab='Survival Time(year)',
       title.A.legend='Risk Group',
       title.B.legend='Status',
       title.C.legend='Expression',
       size.ABC=1.5,
       size.ylab.title=14,
       size.Atext=11,
       size.Btext=11,
       size.Ctext=11,
       size.yticks=0.5,
       size.yline=0.5,
       size.points=2,
       size.dashline=1,
       size.cutoff=5,
       size.legendtitle=13,
       size.legendtext=12,
       color.A=c(low='blue',high='red'),
       color.B=c(code.0='blue',code.1='red'),
       color.C=c(low='blue',median='white',high='red'),
       vjust.A.ylab=1,
       vjust.B.ylab=2)
#family, expand, relative height
ggrisk(fit,
       cutoff.value='median',
       cutoff.x = 145,
       cutoff.y = -0.8,
       code.0 = 'Still Alive',
       code.1 = 'Already Dead',
       code.highrisk = 'High Risk',
       code.lowrisk = 'Low Risk',
       title.A.ylab='Risk Score',
       title.B.ylab='Survival Time(year)',
       title.A.legend='Risk Group',
       title.B.legend='Status',
       title.C.legend='Expression',
       size.ABC=1.5,
       size.ylab.title=14,
       size.Atext=11,
       size.Btext=11,
       size.Ctext=11,
       size.yticks=0.5,
       size.yline=0.5,
       size.points=2,
       size.dashline=1,
       size.cutoff=5,
       size.legendtitle=13,
       size.legendtext=12,
       color.A=c(low='blue',high='red'),
       color.B=c(code.0='blue',code.1='red'),
       color.C=c(low='blue',median='white',high='red'),
       vjust.A.ylab=1,
       vjust.B.ylab=2,
       family='sans',
       expand.x=3,
       relative_heights=c(0.1,0.1,0.01,0.15))
Two Scatter Plot Plot for Cox Regression
Description
Two Scatter Plot Plot for Cox Regression
Usage
two_scatter(
  fit,
  new.data = NULL,
  code.0 = "Alive",
  code.1 = "Dead",
  code.highrisk = "High",
  code.lowrisk = "Low",
  cutoff.show = TRUE,
  cutoff.value = "median",
  cutoff.x,
  cutoff.y,
  cutoff.label,
  title.A.ylab = "Risk Score",
  title.B.ylab = "Survival Time",
  title.xlab = "Rank",
  title.A.legend = "Risk Group",
  title.B.legend = "Status",
  size.AB = 1.5,
  size.ylab.title = 14,
  size.xlab.title = 14,
  size.Atext = 11,
  size.Btext = 11,
  size.xtext = 11,
  size.xyticks = 0.5,
  size.xyline = 0.5,
  size.points = 2,
  size.dashline = 1,
  size.cutoff = 5,
  size.legendtitle = 13,
  size.legendtext = 12,
  color.A = c(low = "blue", high = "red"),
  color.B = c(code.0 = "blue", code.1 = "red"),
  vjust.A.ylab = 1,
  vjust.B.ylab = 2,
  family = "sans",
  expand.x = 3
)
Arguments
fit | 
 cox regression results of coxph() from 'survival' package or cph() from 'rms' package  | 
new.data | 
 new data for validation  | 
code.0 | 
 string. Code for event 0. Default is 'Alive'  | 
code.1 | 
 string. Code for event 1. Default is 'Dead'  | 
code.highrisk | 
 string. Code for highrisk in risk score. Default is 'High'  | 
code.lowrisk | 
 string. Code for lowrisk in risk score. Default is 'Low'  | 
cutoff.show | 
 logical, whether to show text for cutoff in figure A. Default is TRUE  | 
cutoff.value | 
 string, which can be 'median', 'roc' or 'cutoff'. Even you can define it by yourself  | 
cutoff.x | 
 numeric (optional), ordination x for cutoff text  | 
cutoff.y | 
 numeric (optional), ordination y for cutoff text  | 
cutoff.label | 
 (should be) string. Define cutoff label by yourself  | 
title.A.ylab | 
 string, y-lab title for figure A. Default is 'Riskscore'  | 
title.B.ylab | 
 string, y-lab title for figure B. Default is 'Survival Time'  | 
title.xlab | 
 string, x-lab title for figure B. Default is 'Rank'  | 
title.A.legend | 
 string, legend title for figure A. Default is 'Risk Group'  | 
title.B.legend | 
 string, legend title for figure B. Default is 'Status'  | 
size.AB | 
 numeric, size for ABC. Default is 1.5  | 
size.ylab.title | 
 numeric, size for y-axis label title. Default is 14  | 
size.xlab.title | 
 numeric, size for x-axis lab title. Default is 11  | 
size.Atext | 
 numeric, size for y-axis text in figure A. Default is 11  | 
size.Btext | 
 numeric, size for y-axis text in figure B. Default is 11  | 
size.xtext | 
 numeric, size for x-axis text. Default is 11  | 
size.xyticks | 
 numeric, size for y-axis ticks. Default is 0.5  | 
size.xyline | 
 numeric, size for y-axis line. Default is 0.5  | 
size.points | 
 numeric, size for scatter points. Default is 2  | 
size.dashline | 
 numeric, size for dashline. Default is 1  | 
size.cutoff | 
 numeric, size for cutoff text. Default is 5  | 
size.legendtitle | 
 numeric, size for legend title. Default is 13  | 
size.legendtext | 
 numeric, size for legend text. Default is 12  | 
color.A | 
 color for figure A. Default is low = 'blue', high = 'red'  | 
color.B | 
 color for figure B. Default is code.0 = 'blue', code.1 = 'red'  | 
vjust.A.ylab | 
 numeric, vertical just for y-label in figure A. Default is 1  | 
vjust.B.ylab | 
 numeric, vertical just for y-label in figure B. Default is 2  | 
family | 
 family, default is sans  | 
expand.x | 
 numeric, expand for x-axis  | 
Value
A riskscore picture
Examples
library(rms)
fit <- cph(Surv(time,status)~ANLN+CENPA+GPR182+BCO2,LIRI)
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5)
#more detailed example
library(ggrisk)
#plot
two_scatter(fit)
#regulate cutoff
##hidden cutoff
two_scatter(fit,
            cutoff.show = FALSE)
two_scatter(fit,
            cutoff.value = 'median')
two_scatter(fit,
            cutoff.value = 'roc')
two_scatter(fit,
            cutoff.value = 'cutoff')
two_scatter(fit,
            cutoff.value = -1)
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5)
#code for 0 and 1
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead')
#code for high and low risk group
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group')
#title for legend, x and y lab
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group',
            title.A.legend = 'Riskscore',
            title.B.legend = 'Event Status',
            title.A.ylab = 'Riskscore',
            title.B.ylab = 'Survival Time(year)',
            title.xlab = 'This is rank')
#vertical just for y-axis lab
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group',
            title.A.legend = 'Riskscore',
            title.B.legend = 'Event Status',
            title.A.ylab = 'Riskscore',
            title.B.ylab = 'Survival Time(year)',
            title.xlab = 'This is rank',
            vjust.A.ylab = 1,
            vjust.B.ylab = 3)
#size
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group',
            title.A.legend = 'Riskscore',
            title.B.legend = 'Event Status',
            title.A.ylab = 'Riskscore',
            title.B.ylab = 'Survival Time(year)',
            title.xlab = 'This is rank',
            vjust.A.ylab = 1,
            vjust.B.ylab = 3,
            size.AB = 2,
            size.ylab.title = 14,
            size.xlab.title = 14,
            size.Atext = 12,
            size.Btext = 12,
            size.xtext = 12,
            size.xyticks = 0.5,
            size.xyline = 0.5,
            size.dashline = 1.5,
            size.points = 1,
            size.cutoff = 5,
            size.legendtitle = 14,
            size.legendtext = 13)
#color
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group',
            title.A.legend = 'Riskscore',
            title.B.legend = 'Event Status',
            title.A.ylab = 'Riskscore',
            title.B.ylab = 'Survival Time(year)',
            title.xlab = 'This is rank',
            vjust.A.ylab = 1,
            vjust.B.ylab = 3,
            size.AB = 2,
            size.ylab.title = 14,
            size.xlab.title = 14,
            size.Atext = 12,
            size.Btext = 12,
            size.xtext = 12,
            size.xyticks = 0.5,
            size.xyline = 0.5,
            size.dashline = 1.5,
            size.points = 1,
            size.cutoff = 5,
            size.legendtitle = 14,
            size.legendtext = 13,
            color.A = c(low='green',high='red'),
            color.B = c(code.0='green',code.1='red'))
#famli and expand
two_scatter(fit,
            cutoff.value = 'median',
            cutoff.x = 142,
            cutoff.y = -0.5,
            code.0 = 'Still Alive',
            code.1 = 'Dead',
            code.highrisk = 'High Group',
            code.lowrisk = 'Low Group',
            title.A.legend = 'Riskscore',
            title.B.legend = 'Event Status',
            title.A.ylab = 'Riskscore',
            title.B.ylab = 'Survival Time(year)',
            title.xlab = 'This is rank',
            vjust.A.ylab = 1,
            vjust.B.ylab = 3,
            size.AB = 2,
            size.ylab.title = 14,
            size.xlab.title = 14,
            size.Atext = 12,
            size.Btext = 12,
            size.xtext = 12,
            size.xyticks = 0.5,
            size.xyline = 0.5,
            size.dashline = 1.5,
            size.points = 1,
            size.cutoff = 5,
            size.legendtitle = 14,
            size.legendtext = 13,
            color.A = c(low='green',high='red'),
            color.B = c(code.0='green',code.1='red'),
            family = 'sans', # sans for Arail, serif for Times New Roman
            expand.x=10)