Package 'nmrdata'

Title: Example 1d NMR Data for Metabolic Profiling
Description: Provides example one-dimensional proton NMR spectra of murine urine samples collected before and after bariatric or sham surgery (Roux-en-Y gastric bypass). The data are adapted from Jia V Li et al. (2011), "Metabolic surgery profoundly influences gut microbial-host metabolic cross-talk", Gut, 60(9), 1214–1223. <doi:10.1136/gut.2010.234708>. This package serves as example data for metabolomics analysis and teaching purposes.
Authors: Torben Kimhofer [aut, cre] (ORCID: <https://orcid.org/0000-0001-7158-9930>)
Maintainer: Torben Kimhofer <[email protected]>
License: MIT + file LICENSE
Version: 1.2.0
Built: 2026-10-10 11:20:05 UTC
Source: https://github.com/bioc/nmrdata

Help Index


Unpack and return path to raw NMR experiment directory

Description

Retrieves the raw NMR experiment archive (tar.gz) from ExperimentHub and ensures it is unpacked once into a cache directory. If the unpacked directory already exists and contains files, it is reused; otherwise the tarball is extracted. Optionally, an existing unpack can be forced to be replaced.

Usage

getRawExpDir(quiet = FALSE, reuntar = FALSE, tar_override = NULL)

Arguments

quiet

Logical; suppress progress messages (default FALSE).

reuntar

Logical; force re-extraction even if the directory already exists and is populated (default FALSE).

tar_override

Character path to a local .tar.gz file to use instead of ExperimentHub (for examples/tests; default NULL).

Details

This helper is idempotent: repeated calls return the same normalized path without re-downloading or re-unpacking, unless explicitly instructed.

  • The function always uses the same internal ExperimentHub ID (EH9906 by default in this package).

  • The tarball is retrieved via ExperimentHub::ExperimentHub().

  • The directory is created next to the cached tarball inside the EH cache.

  • If the archive contains exactly one top-level folder, that name is reused. Otherwise a default folder name ("nmrdata") is created.

Value

A character scalar: normalized absolute path to the unpacked dataset directory inside the local ExperimentHub cache.

See Also

ExperimentHub::ExperimentHub(), utils::untar()

Examples

td <- tempfile(); dir.create(td)
dir.create(file.path(td, "tinydata"))
cat("ex data\n", file = file.path(td, "tinydata", "a.txt"))
tarfile <- file.path(td, "tinydata.tar.gz")
utils::tar(tarfile, files = "tinydata", compression = "gzip", tar = "internal")

p <- getRawExpDir(tar_override = tarfile, quiet = TRUE)
basename(p)              # "tinydata"
list.files(p)            # "a.txt"

## Not run: 
exp_dir <- getRawExpDir()
list.files(exp_dir, recursive = TRUE)[1:5]

# Force re-unpack if you think the folder is corrupted
exp_dir <- getRawExpDir(reuntar = TRUE)

## End(Not run)