Skip to contents

Imports .csv file(s) reprensenting analysis results in a wide format with samples in rows and features in columns. The first column must contain the analysis identifier, subsequent columns can be metadata columns, followed by value of different features. The table format must be in the long format with columns for the raw data file name, feature ID, and the peak intensity and other parameters. Additional information, such as retention time, FWHM, precursor/product MZ, and CE will also be imported and will available from the MidarExperiment object for downstream analyses.

When a path to a folder is provided, all .scv files in that folder will be imported and merged into one raw dataset. This is useful, e.g. when importing datasets that were pre-processed in blocks resulting in different files. Each feature and raw data file pair must only occur once within and across all .csv source data files, duplicated return an error.

Usage

import_data_csv(
  data = NULL,
  path,
  variable_name,
  analysis_id_col = NA,
  import_metadata
)

Arguments

data

MidarExperiment object

path

One or more file names with path, or a folder path, which case all *.csv files in this folder will be read.

variable_name

Variable type representing the values in the table. Must be one of "intensity", "norm_intensity", "conc", "area", "height", "response")

analysis_id_col

Column to be used as analysis_id. NA (default) used 'analysis_id' if present, or the first column if it contains unique values.

import_metadata

Import additional metadata columns (e.g. batch ID, sample type) and add to the MidarExperiment object. Only following metadata column names are supported: "qc_type", "batch_id", "is_quantifier", "is_istd", "run_seq_num", "precursor_mz", "product_mz", "collision_energy"

Value

MidarExperiment object

Examples

file_path <- system.file("extdata", "plain_wide_dataset.csv", package = "midar")

mexp <- MidarExperiment()

mexp <- import_data_csv(
  data = mexp,
  path = file_path,
 variable_name = "conc",
 import_metadata = TRUE)
#>  Imported 87 analyses with 5 features
#>  `feature_conc` selected as default feature intensity. Modify with `set_intensity_var()`.
#>  Analysis metadata associated with 87 analyses.
#>  Feature metadata associated with 5 features.
#>  Analysis order was based on sequence of analysis results, as no timestamps were found.
#> Use `set_analysis_order` to define alternative analysis orders.

print(mexp)
#> 
#> ── MidarExperiment ─────────────────────────────────────────────────────────────
#> Title:
#> 
#> Processing status: Annotated raw CONC values
#> 
#> ── Annotated Raw Data ──
#> 
#> • Analyses: 87
#> • Features: 5
#> • Raw signal used for processing: `feature_conc`
#> 
#> ── Metadata ──
#> 
#> • Analyses/samples: 
#> • Features/analytes: 
#> • Internal standards: 
#> • Response curves: 
#> • Calibrants/QC concentrations: 
#> • Study samples: 
#> 
#> ── Processing Status ──
#> 
#> • Isotope corrected: 
#> • ISTD normalized: 
#> • ISTD quantitated: 
#> • Drift corrected variables: 
#> • Batch corrected variables: 
#> • Feature filtering applied: 
#> 
#> ── Exclusion of Analyses and Features ──
#> 
#> • Analyses manually excluded (`analysis_id`): NA