OHDSI Home | Forums | Wiki | Github

Atlas population estimation R script error

In export.R script under the study package for population estimation:

reference <- readRDS(file.path(outputFolder, "cmOutput", "outcomeModelReference.rds"))
getCovariateAnalyses <- function(cmAnalysis) {
    cmDataFolder <- reference$cohortMethodDataFolder[reference$analysisId == cmAnalysis$analysisId][1]
    cmData <- CohortMethod::loadCohortMethodData(file.path(outputFolder, "cmOutput", cmDataFolder), readOnly = TRUE)
  1. The reference table does not have ‘cohortMethodDataFolder’ column.

    names(reference)
    [1] “analysisId” “targetId” “comparatorId” “outcomeId”
    [5] “includedCovariateConceptIds” “excludedCovariateConceptIds” “outcomeOfInterest” “cohortMethodDataFile”
    [9] “studyPopFile” “sharedPsFile” “psFile” “strataFile”
    [13] “prefilteredCovariatesFile” “outcomeModelFile”

  2. CohortMethod::loadCohortMethodData does not accept the argument ‘readOnly = TRUE’

This error is caused by the fact that the version of CohortMethod is not compatible with the version of the estimation script. Make sure you install the version defined in the script (see the README file for instructions).

Hi Martijn,

Thank you! I originally installed the versions specified in the README file, but got errors. Can you help? Thanks!

Here is the error message:

Executing SQL took 5.41 secs
Fetching data from server
Registered S3 methods overwritten by 'ffbase':
  method   from
  [.ff     ff  
  [.ffdf   ff  
  [<-.ff   ff  
  [<-.ffdf ff  
Fetching data took 8.58 secs
Fetching outcomes from server
Fetching outcomes took 2.43 secs
Error in setwd(dfile) : cannot change working directory
In addition: Warning messages:
1: In dir.create(outputFolder, recursive = TRUE) :
  '.\result4' already exists
2: In execute(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSchema,  :
  fftempdir './tmp4/' not found. Attempting to create folder
3: In dir.create(getOption("fftempdir"), recursive = TRUE) :
  '.\tmp4' already exists
Warning: Error 'cannot open the connection' when writing log to file './result4//log.txt. Removing file appender from logger.
Warning: Could not find logger DEFAULT

and the version info:

install_github("ohdsi/ParallelLogger", ref = "v1.1.1")
install_github("ohdsi/SqlRender", ref = "v1.6.3")
install_github("ohdsi/DatabaseConnector", ref = "v2.4.1")
install_github("ohdsi/OhdsiSharing", ref = "v0.1.3")
install_github("ohdsi/FeatureExtraction", ref = "v2.2.5")
install_github("ohdsi/CohortMethod", ref = "v3.1.0")
install_github("ohdsi/EmpiricalCalibration", ref = "v2.0.0")
install_github("ohdsi/MethodEvaluation", ref = "v1.1.0")
In execute(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSchema,  :
  fftempdir './tmp4/' not found. Attempting to create folder

I think you’re setting outputfolder or fftempdir as .\result4 and ./tmp4/
Please set the fftempdir as existing directory.
And please use ‘/’ rather than '\ ’ to seperate the directories in R

Thanks! But here is my code, and I don’t even know why the message said ‘\’ instead of ‘/’.

# The folder where the study intermediate and result files will be written:
outputFolder <- "./result4/"

# Specify where the temporary files (used by the ff package) will be created:
options(fftempdir = "./tmp4/")

Could you try setting the fftemp folder to an absolute path? I think that is what is causing this issue.

Thanks! The path error disappeared, but the ‘cohortMethodDataFolder’ error is still there.
I double-checked, ‘cohortMethodDataFolder’ column is missing in outcomeModelReference.rds.

Exporting analyses
- cohort_method_analysis table
- covariate_analysis table
Warning: warning: Unknown or uninitialised column: `cohortMethodDataFolder`.

Error in if (!file.exists(file)) stop("Cannot find file ", file) : 
  argument is of length zero
Warning: Could not find logger DEFAULT

Hello @yupengli, @schuemie I understand that this error is from a very long back ago. I am facing the same issue when running a study package. Any recall how you were able to clear this error.

Thank you in advance

t