Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running doIMRMC on Viper data set #190

Open
marshhar opened this issue Nov 23, 2024 · 3 comments
Open

Error when running doIMRMC on Viper data set #190

marshhar opened this issue Nov 23, 2024 · 3 comments

Comments

@marshhar
Copy link

Hi, I'm interested in using the iMRMC R package to analyze data for a non-inferiority trial I'm running. As a first step, I have been trying to replicate the analysis here: https://github.com/DIDSR/iMRMC/wiki/Non-inferiority-by-iMRMC.

However, when I execute this line of code:

results <- doIMRMC(dfMRMC_AI)

I get this error:
Error in if (covAUC < 0) { : missing value where TRUE/FALSE needed

I also tried my own dataset and got the same exception. Do you have any thoughts on what I could be doing wrong? Apologies if this answer is obvious, but I'm new to R.

@marshhar
Copy link
Author

marshhar commented Nov 24, 2024

I've done a bit of digging and this is the best I've come up with so far.

The error occurs in the doAUCmrmcCov function. Specifically, in the lines of code below, all values in both numer1234 and denom1234 are set to 0:

numer1234 <- colSums(perReaderPair.1[index.TF, c("numer1", "numer2", "numer3", "numer4")])

denom1234 <- colSums(perReaderPair.1[index.TF, c("denom1", "denom2", "denom3", "denom4")])

Later, the former is divided by the latter:

m.biased <- numer/denom

Which results in NaN for the first four values of m.biased. This eventually propagates to covAUC, also set to NaN.

covAUC <- sum(m.coeff * m)

This is later used in a conditional statement:

if (covAUC < 0)

Which throws the exception.

I'm afraid I am not familiar enough with this field to know what is supposed to be occurring. Should the first 4 entries of m.biased be 0 instead of NaN? Any help would be greatly appreciated!

@brandon-gallas
Copy link
Member

I believe you have a problem formatting your data. Without the data, I am unable to diagnose your problem. I am also just checking in today and will be on leave. Additional responses will be delayed.

@marshhar
Copy link
Author

marshhar commented Nov 25, 2024

Thanks for your response, and for the heads up re: delayed responses going forward.

Regarding data, it came from installing this package (viperData 1.0.2): https://github.com/DIDSR/viperData/releases/download/1.0.2/viperData_1.0.2.tar.gz

I'm using iMRMC 2.1.0

The code was copied and pasted from https://github.com/DIDSR/iMRMC/wiki/Non-inferiority-by-iMRMC. For convenience, I've included it all below:

#Load iMRMC package
library(iMRMC)

#Load Viper data 
library(viperData)
viperObs <- viperData::viperObs

#Choose one sub-study => screeningHighP
screeningHighP <- viperObs[viperObs$subStudyLabel == "screeningHighP", , drop = FALSE]
screeningHighP$caseID <- as.character(screeningHighP$caseID)

#Create iMRMC dataframe
dfMRMC <- createIMRMCdf(screeningHighP, 
                        keyColumns = list(readerID = "readerID",
                                          caseID = "caseID",
                                          modalityID = "modalityID",
                                          score = "score",
                                          truth = "cancerStatus455"),
                        truePositiveFactor = "1")

#Subset FFDM reads from all readers
dfMRMC_onlyFFDM <- subset(dfMRMC, modalityID == "FFDM")

#Subset SFM reads from all readers
dfMRMC_onlySFM <- subset(dfMRMC, modalityID == "SFM")

#Subset truth reads from all readers
dfMRMC_onlyTruth <- subset(dfMRMC, modalityID == "truth")

#Create a dataframe for AI simulated reads from FFDM modality
dfMRMC_AImod <- data.frame()

#Loop through all cases in caseID and isolate each case from the chosen readers just once
for(i in unique(dfMRMC_onlyFFDM$readerID)) { 
  remainingCases <- dfMRMC_onlyFFDM[!dfMRMC_onlyFFDM$caseID %in% 
                                      dfMRMC_AImod$caseID, , drop = FALSE]
  dfMRMC_AImod <- rbind(dfMRMC_AImod, subset(remainingCases, readerID == i))
}

#Change modalityID to "AI" for all cases
dfMRMC_AImod$modalityID <- "AI"

#Change readerID to "AI.1" for all cases
dfMRMC_AImod$readerID <- "AI.1"

#Duplicate those cases and rename with readerID "AI.2" 
dfMRMC_AImod2 <- dfMRMC_AImod
dfMRMC_AImod2$readerID <- "AI.2"

#Bind dataframe with 2 AI "readers" with duplicate scores on all cases
dfMRMC_AImod <- rbind(dfMRMC_AImod, dfMRMC_AImod2)

#Bind full dataframe with only SFM, truth and AI rows 
dfMRMC_AI <- rbind(dfMRMC_onlyTruth, dfMRMC_onlySFM, dfMRMC_AImod)

#Run iMRMC analysis function
results <- doIMRMC(dfMRMC_AI)

#Isolate data frame of reader-averaged U-stats based performance results
uStat <- results[['Ustat']] 

#Capture degrees of freedom
#The third row we are calling here assesses the accuracy of modA against modB
dfBDG <- uStat[3, 'dfBDG']

#Capture variance of the difference between modalities, ie. the total variance
varAUCAminusAUCB <- uStat[3, 'varAUCAminusAUCB']

#Define all variables used in the t-statistic calculation 
marginParam = 0.05
aucA = uStat[3, 'AUCA'] 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants