Create submission package for analysis

Copies scripts, datasets or NLME models with related datasets into folder structure as required by FDA for submission. Define files are copied or created if possible, and a reviewer's guides is prepared in terms of rmd/docx file. The structure of the created package is 'm5/datasets/analysisname/analysis/legacy' with subfolders 'programs' and 'datasets'. The datasets folder will contain all copied datasets and one define file. The programs folder will contain Reviewer's guide describing scripts and model files that have been copied. For NLME models, the NONMEM control and output file or mlxtran, Monolix model file and output file will be copied to programs and the modeling dataset to 'datasets'. The modeling datasets are . For scripts, it will be attempted to parse the description of the file from the file header if not given by the user to add The reviewer's guide and the define file for data sets need to be manually opened, potentially adjusted, and stored as PDF. A logfile is giving an overview on files that were copied and potential actions that need to be done.

createSubmissionPack(
  specification,
  analysisname,
  pathroot = ".",
  programExtension = ".txt",
  extensionChange = c("_lower", "_", "-lower", "-", "none"),
  allowedProgExt = c(".txt", ".lua", ".sas", ".r", ".ctl"),
  fullpathData = FALSE,
  logfile = "logfile.txt",
  substituteUpper = TRUE,
  substituteUnderscore = FALSE,
  allowSubfolder = FALSE,
  overwrite = FALSE,
  calcMD5 = FALSE,
  copyAttributes = FALSE,
  stop_at_missing = TRUE
)

Arguments

specification

Data frame with one row per mode, data set, or script that should be copied. The following columns need to be defined in the specification:.

COLUMN DESCRIPTION =========== ===============================================================
Source Path to dataset, script, or model project folder SubFolder Optional subfolder to 'programs' folder to which the script/model should be copied or prefix that is added to the filename(s) of copied files. Use "." or "" to not use the subfolder option.
Name Name of which is used for filenames of the copied program, model, or data files. Renaming might be required in case datasets and models with same filenames exist. If not given, the model folder name is used for model files and the original file names for datasets (including the modeling data sets). If the given name does not contain an extension, the original will be used and adjusted as required. Type Either 'model', 'dataset', or 'program'. Datasets and datasets of the model are copied to 'datasets' folder, programs and model files to 'programs'
Description Short describtion of model, dataset, or program used in define file or reviewer's guide. defineRMD Path to rmd of define file if not existing with same filename in same location as the dataset. NA otherwise. This argument is ignored for programs.

Note that helper functions, i.e., getProgramSpecification and getModelSpecification exist to create the specification data frame.

analysisname

Name of the analysis folder

pathroot

Path where submission package is created

programExtension

Extention to be used for program and model files that do not already have allowed file extension. Defaults to '.txt'.

extensionChange

Option how the current program and model file extensions are modified before adding new extension.

      * "_lower": Dot substituted with underscore (_) and all letters converted to lower case (default)
      * "_": Dot substituted with underscore (_)
      * "-lower": Dot substituted with hyphen (-) and all letters converted to lower case
      * "-": Dot substituted with hyphen (-)
      * "none": No change

allowedProgExt

Program and model file extension that are kept as is.

fullpathData

Flag whether full path of dataset should be given in define file

logfile

File with notes on manual post-processing information.

substituteUpper

Flag whether letters of file names should be converted to lower case

substituteUnderscore

Flag whether underscores in file names should be substituted with '-'

allowSubfolder

Flag whether to allow subfolder in programs (default FALSE)

overwrite

Flag whether to allow overwriting existing analyis folder in submission package

calcMD5

Flag whether to calculate the MD5 checksum for copied files. If true, checksums will be written to 'checksums.csv' in the 'pathroot' folder

copyAttributes

Flag whether to copy attribute files to programs/Resources (default FALSE)

stop_at_missing

Flag whether to stop if a required file does not exist. Defaults to TRUE. Switching to FALSE could be handy when developing the submission package as the log file tracks missing files and other issues.

Value

None. Datasets and programs are copied to the submission package folder structure and a log file with postprocessing information written.

Author

Anne Kuemmel

Examples

if (FALSE) {
### Example1: NLME models
# Specify models to include in submission package
  specificationModels <- tribble(
    ~Source                                         , ~SubFolder  , ~Name , ~Type      , ~Description       , ~defineRMD,
    "../Models/01_NONMEM"                           , "."         , "nm"  , "model"    , "nonmem model"     , NA        ,
    "../Models/02_MLX"                              , "."         , "mlx" , "model"    , "monolix model"    , NA
  ) %>% as.data.frame()

# Create analysis path with model input/output files and the used datasets
  createSubmissionPack(
    specification = specificationModels,
    analysisname = "PKmodel",
    pathroot = "../../package/",
    logfile = "../../package/logModels.txt",
    overwrite = TRUE,
    substituteUpper = FALSE
  )

### Example 2: datasets and programs
# Specify dataset and scripts to include in submission package
  specificationScripts <- tribble(
    ~Source                                         , ~SubFolder  , ~Name , ~Type      , ~Description       , ~defineRMD,
    "SCRIPT_40_ExposureMetrics_Individuals.R"       , "."         , NA    , "program"  , NA                 , NA        ,
    "SCRIPT_50_Visualize_IGGBASEdistribution.R"     , "."         , NA    , "program"  , "done for fun"     , NA        ,
    "Resources/model2cpt_IVSCIG_IGGBASE_IOV_AUC.txt", "Resources" , NA    , "program"  , "structural model" , NA        ,
    "Resources/dataExp.csv"                         , ""          , NA    , "dataset"  , "ER data"          , NA
  ) %>% as.data.frame()

# Create analysis path with model input/output files and the used datasets
createSubmissionPack(
    specification = specificationScripts,
    analysisname = "ERanalysis",
    pathroot = "../../package/",
    logfile = "../../package/logScripts.txt",
    overwrite = TRUE
  )


### Example 3: combination
  specification <- bind_rows(specificationModels, specificationScripts)
  createSubmissionPack(
    specification = specification,
    analysisname = "all",
    pathroot = "../../package/",
    logfile = "../../package/logAll.txt"
  )
}