Process a dir of files to generate normalised data and reports
Source:R/process-dir.R
process_dir.Rd
The output files will be created alongside their corresponding input files, preserving
the directory structure of the input directory unless the flatten_output_dir
parameter is set to TRUE
.
Usage
process_dir(
input_dir,
output_dir = NULL,
recurse = FALSE,
flatten_output_dir = FALSE,
layout_filepath = NULL,
format = NULL,
normalisation_types = c("RAU", "nMFI"),
generate_reports = FALSE,
merge_outputs = FALSE,
column_collision_strategy = "intersection",
return_plates = FALSE,
dry_run = FALSE,
verbose = TRUE,
...
)
Arguments
- input_dir
(
character(1)
) The directory containing the input files. It may be nested.- output_dir
(
character(1)
) Optional overwrite directory where the output files should be saved. The default isNULL
. By default, the output directory is the same as the input directory.- recurse
(
logical(1)
) IfTRUE
, the function will search for files recursively in the input directory. The default isFALSE
.- flatten_output_dir
(
logical(1)
) IfTRUE
, the output files will be saved in the output directory directly. The default isFALSE
.- layout_filepath
(
character(1)
) The path to the layout file. The default isNULL
, and the layout file will have to be determined automatically based on the file name.- format
(
character(1)
) The format of the Luminex data. The default isNULL
, and the format will have to be determined automatically based on the file name. Available options arexPONENT
andINTELLIFLEX
.- normalisation_types
(
character()
) A vector of normalisation types to use. The default isc("RAU", "nMFI")
.- generate_reports
(
logical(1)
) IfTRUE
, generate quality control reports for each file. The default isFALSE
.- merge_outputs
(
logical(1)
) IfTRUE
, merge the outputs of all plates into a single CSV file for each normalisation type. The resulting file will be saved in the output directory with the namemerged_{normalisation_type}_{timestamp}.csv
. Example:merged_nMFI_20250115_230735.csv
.- column_collision_strategy
(
character(1)
) A method for handling missing or additional columns when merging outputs. Possible options areunion
andintersection
. The default isintersection
.- return_plates
(
logical(1)
) IfTRUE
, return a list of processed plates. The default isFALSE
.- dry_run
(
logical(1)
) IfTRUE
, the function will not process any files but will print the information about the files that would be processed. The default isFALSE
.- verbose
(
logical(1)
) Print additional information. The default isTRUE
.- ...
Additional arguments to for the
process_file
function.
Value
If the return_plates
parameter is set to TRUE
the function returns a list of plates
sorted by the plate_datetime
(The time of the experiment noted in the csv file) in increasing order (oldest plates first).
If the return_plates
parameters is set to FALSE
the function returns NULL
.
Examples
# Select input directory to process
dir <- system.file("extdata", "multiplate_lite", package = "PvSTATEM", mustWork = TRUE)
# Select output directory
output_dir <- tempdir(check = TRUE)
# Process input directory and return plates
plates <- process_dir(dir, return_plates = TRUE, output_dir = output_dir)
#> Reading Luminex data from: /home/runner/work/_temp/Library/PvSTATEM/extdata/multiplate_lite/CovidOISExPONTENT.csv
#> using format xPONENT
#>
#> New plate object has been created with name: CovidOISExPONTENT!
#>
#> Processing plate 'CovidOISExPONTENT'
#> Fitting the models and predicting RAU for each analyte
#> Warning: High dose hook detected.
#> Removing samples with dilutions above the high dose threshold.
#> Adding the raw MFI values to the output dataframe
#> Saving the computed RAU values to a CSV file located in: '/tmp/RtmpFPTjFr/CovidOISExPONTENT_RAU.csv'
#> Computing nMFI values for each analyte
#> Adding the raw MFI values to the output dataframe
#> Saving the computed nMFI values to a CSV file located in: '/tmp/RtmpFPTjFr/CovidOISExPONTENT_nMFI.csv'