---
title: "Export Data"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Export Data}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
`Omiprep` can export data to various formats.
## Setup
### load the omiprep library
```{r}
library(omiprep)
```
### Read in the data and make a Omiprep object
Create a `Omiprep` object as described in the [Getting Started](index.html) vignette.
```{r setup, results='hide'}
# read in the metabolon data as a list object
datain <- read_metabolon(system.file("extdata", "metabolon_v1.1_example.xlsx", package = "omiprep"),
sheet="OrigScale",
return_Omiprep = FALSE)
# build the Omiprep class object
mydata <- Omiprep(data = datain$data, samples = datain$samples, features = datain$features)
```
## Run the quality control
```{r, warnngs=FALSE}
## Adding suppressWarnings() to avoid deparse() error when rendering vignette with S7 method warnings
mydata <- suppressWarnings( quality_control(mydata, cores = 1) )
```
## Export Omiprep
```{r export_omiprep}
# where to put the files
output_dir <- file.path(getwd(), "output")
# run export
export(mydata, directory = output_dir, format = "omiprep")
# view output directory files
files <- list.files(output_dir, full.names = TRUE, recursive = TRUE)
unname(sapply(files, function(path) {
parts <- strsplit(path, .Platform$file.sep)[[1]]
paste(tail(parts, 4), collapse = .Platform$file.sep)
}))
```