spectraPaths_and_metadata_UI_helper: UI data import helper - prepare file paths and metadata

Description Usage Arguments Value Examples

View source: R/GUI_utils.R

Description

Return spectraPaths and spectraMetadata from a .csv file (if available). If reading from the spectraMetadata file, the spectraPaths are taken from the 'filepath' column

Usage

1
2
3
4
spectraPaths_and_metadata_UI_helper(
    spectraPaths = NULL,
    spectraMetadataPath = NULL
)

Arguments

spectraPaths

NULL or character vector of spectra file paths, to set samples to process

spectraMetadataPath

NULL or path to a csv of spectra metadata, with spectra as row and metadata as columns. (spectraPaths in column 'filepath')

Value

spectraPaths (str) and spectraMetadata (DataFrame or NULL) read from the CSV file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Input data
# spectraPath
input_spectraPaths    <- c('./path/file1', './path/file2', './path/file3')

# spectraMetadata
input_spectraMetadata <- data.frame(matrix(data=c(input_spectraPaths,
                            c('a','b','c')), nrow=3, ncol=2,
                            dimnames=list(c(),c('filepath', 'testcol')),
                            byrow=FALSE), stringsAsFactors=FALSE)

# temporary file location
spectraMetaPath <- tempfile(pattern="file", tmpdir=tempdir(), fileext='.csv')
# save csv
utils::write.csv(input_spectraMetadata,
                    file=spectraMetaPath,
                    row.names=FALSE)

# load data from CSV
spectraPaths_and_metadata_UI_helper(spectraPaths = NULL,
                                    spectraMetadataPath = spectraMetaPath)

peakPantheR documentation built on Nov. 8, 2020, 6:38 p.m.