Pipelines: Pipelines

Description Usage Arguments Details Value See Also Examples

Description

Uses nmr_pca_outliers_robust to perform the detection of outliers

Normalize the full spectra to the internal calibrant region, then exclude that region and finally perform PQN normalization.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pipe_load_samples(samples_dir, glob = "*0", output_dir = NULL)

pipe_add_metadata(nmr_dataset_rds, excel_file, output_dir)

pipe_interpolate_1D(nmr_dataset_rds, axis, output_dir)

pipe_exclude_regions(nmr_dataset_rds, exclude, output_dir)

pipe_outlier_detection(nmr_dataset_rds, output_dir)

pipe_filter_samples(nmr_dataset_rds, conditions, output_dir)

pipe_peakdet_align(
  nmr_dataset_rds,
  nDivRange_ppm = 0.1,
  scales = seq(1, 16, 2),
  baselineThresh = 0.01,
  SNR.Th = -1,
  maxShift_ppm = 0.0015,
  acceptLostPeak = FALSE,
  output_dir = NULL
)

pipe_peak_integration(
  nmr_dataset_rds,
  peak_det_align_dir,
  peak_width_ppm,
  output_dir
)

pipe_normalization(
  nmr_dataset_rds,
  internal_calibrant = NULL,
  output_dir = NULL
)

Arguments

samples_dir

The directory where the samples are

glob

A wildcard aka globbing pattern (e.g. *.csv) passed on to grep() to filter paths.

output_dir

The output directory for this pipe element

nmr_dataset_rds

The nmr_dataset.rds file name coming from previous nodes

excel_file

An excel file name. See details for the requirements

The excel file can have one or more sheets. The excel sheets need to be as simple as possible: One header column on the first row and values below.

Each of the sheets contain metadata that has to be integrated. The merge (technically a left join) is done using the first column of each sheet as key.

In practical terms this means that the first sheet of the excel file MUST start with an "NMRExperiment" column, and as many additional columns to add (e.g. FluidXBarcode, SampleCollectionDate, TimePoint and SubjectID).

The second sheet can have as the first column any of the already added columns, for instance the "SubjectID", and any additional columns (e.g. Gender, Age).

The first column on each sheet, named the key column, MUST have unique values. For instance, a sheet starting with "SubjectID" MUST specify each subject ID only once (without repetitions).

axis

The ppm axis range and optionally the ppm step

exclude

A list with regions to be removed Typically: exclude = list(water = c(4.7, 5.0))

conditions

A character vector with conditions to filter metadata. The conditions parameter should be a character vector of valid R logical conditions. Some examples:

  • conditions <- 'Gender == "Female"'

  • conditions <- 'Cohort == "Chuv"'

  • conditions <- 'TimePoint %in% c("T0", "T31")'

  • conditions <- c(Cohort == "Chuv", 'TimePoint %in% c("T0", "T31")')

Only samples fullfilling all the given conditions are kept in further analysis.

nDivRange_ppm

Segment size, in ppms, to divide the spectra and search for peaks.

scales

The parameter of peakDetectionCWT function of MassSpecWavelet package, look it up in the original function.

baselineThresh

It will remove all peaks under an intensity set by baselineThresh. If you set it to 'NULL', nmr_detect_peaks will automatically compute an aproximate value considering baseline between 9.5 and 10.0 ppm (automatically calculation using baselineThresh = NULL will not work if spectra were not interpolated up to 10.0 ppm)

SNR.Th

The parameter of peakDetectionCWT function of MassSpecWavelet package, look it up in the original function. If you set -1, the function will itself re-compute this value.

maxShift_ppm

The maximum shift allowed, in ppm

acceptLostPeak

This is an option for users, TRUE is the default value. If the users believe that all the peaks in the peak list are true positive, change it to FALSE.

peak_det_align_dir

Output directory from pipe_peakdet_align

peak_width_ppm

A peak width in ppm

internal_calibrant

A ppm range where the internal calibrant is, or NULL.

Details

If there is no internal calibrant, only the PQN normalization is done.

Value

This function saves the result to the output directory

This function saves the result to the output directory

This function saves the result to the output directory

This function saves the result to the output directory

This function saves the result to the output directory

Pipeline: Filter samples according to metadata conditions

Pipeline: Peak detection and Alignment

Pipeline: Peak integration

Pipe: Full spectra normalization

See Also

Other import/export functions: files_to_rDolphin(), load_and_save_functions, nmr_data(), nmr_meta_export(), nmr_read_bruker_fid(), nmr_read_samples(), nmr_zip_bruker_samples(), save_files_to_rDolphin(), save_profiling_output(), to_ChemoSpec()

Other metadata functions: nmr_meta_add(), nmr_meta_export(), nmr_meta_get_column(), nmr_meta_get()

Other outlier detection functions: nmr_pca_outliers_filter(), nmr_pca_outliers_plot(), nmr_pca_outliers_robust(), nmr_pca_outliers()

Other peak detection functions: nmr_baseline_threshold(), nmr_identify_regions_blood(), nmr_identify_regions_cell(), nmr_identify_regions_urine(), nmr_integrate_regions(), regions_from_peak_table(), validate_nmr_dataset_peak_table()

Other alignment functions: nmr_align_find_ref(), validate_nmr_dataset_peak_table()

Other peak integration functions: computes_peak_width_ppm(), nmr_identify_regions_blood(), nmr_identify_regions_cell(), nmr_identify_regions_urine(), nmr_integrate_regions(), validate_nmr_dataset_peak_table()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Example of pipeline usage
## There are differet ways of load the dataset
dir_to_demo_dataset <- system.file("dataset-demo", package = "AlpsNMR")
#excel_file <- system.file("dataset-demo", 
#                          "dummy_metadata.xlsx", 
#                          package = "AlpsNMR")
#output_dir <- tempdir()

## Load samples with pipes
#pipe_load_samples(dir_to_demo_dataset,
#                  glob = "*.zip",
#                  output_dir = "../pipe_output")

## Another way to load it
#nmr_dataset <- nmr_read_samples_dir(dir_to_demo_dataset)

## Saving the dataset in a .rds file
#nmr_dataset_rds <- tempfile(fileext = ".rds")
#nmr_dataset_save(nmr_dataset, nmr_dataset_rds)

## Interpolation
#pipe_interpolate_1D(nmr_dataset_rds, 
#                    axis = c(min = -0.5, max = 10, by = 2.3E-4), 
#                    output_dir)
                    
## Get the new path, based in output_dir
#nmr_dataset_rds <- paste(output_dir, "\", "nmr_dataset.rds", sep = "", collapse = NULL)

## Adding metadata to samples
#pipe_add_metadata(nmr_dataset_rds = nmr_dataset_rds, output_dir = output_dir,
#                  excel_file = excel_file)

## Filtering samples
#conditions <- 'SubjectID == "Ana"'
#pipe_filter_samples(nmr_dataset_rds, conditions, output_dir)

## Outlier detection
#pipe_outlier_detection(nmr_dataset_rds, output_dir)

## Exclude regions
#exclude_regions <- list(water = c(5.1, 4.5))
#pipe_exclude_regions(nmr_dataset_rds, exclude_regions, output_dir)

## peak aling
#pipe_peakdet_align(nmr_dataset_rds, output_dir = output_dir)

## peak integration
#pipe_peak_integration(nmr_dataset_rds, 
#                      peak_det_align_dir = output_dir,
#                      peak_width_ppm = 0.006, output_dir)

## Normalization   
#pipe_normalization(nmr_dataset_rds, output_dir = output_dir)

AlpsNMR documentation built on April 1, 2021, 6:02 p.m.