Package: cenroc
censoredROCCensoredROC allows the computation of the time-dependent ROC curve for right censored survival data using the cumulative sensitivity and dynamic specificity definitions. The ROC curves can be either empirical (non-smoothed) or smoothed with/wtihout boundary correction. It also calculates the time-dependent area under the ROC curve (AUC), the Youden index and can define an optimal cutoff for an independent continuous variables based on the Youden idex.This package is based on the cenROC package that exists for R. The main idea was to allow Python users to apply the same tools.Getting StartedThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.Prerequisitescenrocrequires following packages to be installed['numpy', 'pandas', 'matplotlib', 'scipy','statsmodels']if you don't have them installedcenrocwill install the latest versions of these packages on your machineInstallingUse the following command to install thecenrocpackage from PyPipip install cenrocMain classThe main class of this package iscenROCIn order to use the methods you have to intialise this classcenROC(Y, M, censor, t, U = NULL, h = NULL, bw = "NR", method = "tra",
ktype = "normal", ktype1 = "normal", B = 0, alpha = 0.05, plot = "TRUE")ArgumentsYThe numeric vector of event-times or observed times.MThe numeric vector of marker values for which the time-dependent ROC curves is computed.censorThe censoring indicator, 1 if event, 0 otherwise.tA scaler time point at which the time-dependent ROC curve is computed.UThe vector of grid points where the ROC curve is estimated. The default is a sequence of 151 numbers between 0 and 1.hA scaler for the bandwidth of Beran's weight calculaions. The defualt is the value obtained by using the method of Sheather and Jones (1991).bwA character string specifying the bandwidth estimation method for the ROC itself. The default is the "NR" normal reference method. The user can also introduce a numerical value.methodThe method of ROC curve estimation. The possible options are "emp" emperical metod; "untra" smooth without boundary correction and "tra" is smooth ROC curve estimation with boundary correction. The default is the "tra" smooth ROC curve estimate with boundary correction.ktypeA character string giving the type kernel distribution to be used for smoothing the ROC curve: "normal", "epanechnikov", "biweight", or "triweight". By default, the "normal" kernel is used.ktype1A character string specifying the desired kernel needed for Beran weight calculation. The possible options are "normal", "epanechnikov", "tricube", "boxcar", "triangular", or "quartic". The defaults is "normal" kernel density.this one is not used currentlyBThe number of bootstrap samples to be used for variance estimation. The default is 0, no variance estimation.alphaThe significance level. The default is 0.05.MethodsROC()Produces a numpy array with ROC estimationsAUC()Produces a float showing AUC estimateplot()Plots the bootstrapped plot of ROCExampleInstall the lifelines package to import the datasetpip install lifelinesImport the datasets from the lifelines package along withcenrocpackageimport lifelines.datasets as data
from cenroc import cenROC

df_test = data.load_panel_test()

cenROC_test1 = cenROC(Y=df_test['t'], M=df_test['var2'], censor=df_test['E'],
                     t=3, U=None, h=None, bw='NR', method="tra",
                     ktype="normal", ktype1="normal", B=3, alpha=0.05)

print(cenROC_test1.ROC())Output0.110795
0.180722
0.212862
0.235690
0.253942
0.269407
0.282974
0.295154
0.306269
0.316538
0.326117
...cenROC_test2 = cenROC(Y=df_test['t'], M=df_test['var1'], censor=df_test['E'],
                                    t=2, U=None, h=None, bw=0.1, method="untra",
                                    ktype="epanechnikov", ktype1="normal", B=2, alpha=0.05)

print(cenROC_test2.AUC())Output0.6742424242424243Due to the stochastic nature of bootstraping the graphs will be different each time.
We can set seed to produce the same result for demonstartion purposes.import numpy as np
np.random.seed(3)
cenROC_test1.plot()Output!ContributingPlease readCONTRIBUTING.mdfor details on our code of conduct, and the process for submitting pull requests to us.VersioningWe useSemVerfor versioning. For the versions available, see thetags on this repository.AuthorsThis package was developed byplaindata.aiYury Moskaltsov-Initial programming and package building-YuryMoskaltsovMiguel Pereira-Mathematical analysis and implementation, project oversight-miguelmspereiraLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for detailsAcknowledgmentsKassu Mehari Beyene, Catholic University of Louvain.kasu.beyene@uclouvain.be- author of the cenROC R PackageAnouar El Ghouch, Catholic University of Louvain.anouar.elghouch@uclouvain.be- author of the cenROC R PackageReferencesBeyene KM, El Ghouch A. Time-dependent ROC curve estimation for interval-censored data. Biom J. 2022 May 6. doi: 10.1002/bimj.202000382. PMID: 35523738.cenROC R package: . FYI the package is no longer on CRAN (according to the repo:Archived on 2022-04-25 as email to the maintainer was undeliverable.). The archived versions can be downloaded here:https://cran.r-project.org/src/contrib/Archive/cenROC/Improvements to be made/Planned additional featuresThere is a slight discrepancy in the optimal cutpoint metric based on the Youden index obtained here and the one obtained using the cenROC package in R. This is due to a discrepancy in the interpolation functions scipy.interpolate.interp1d() in Python and approx() in R. This should be tested more thoroughly to achieve identical results. The other metrics were compared with the R output and there are no differences.Add a function that calculates the optimal cutpoint for a continuous variables based on the log-rank test (akin to the survminer::survcutpoint function that exists in R).Let us know of other functions that would be useful additions.