Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sampleDist

Compute the Distances Between Samples in a Spectra or Spectra2D Object


Description

Compute the distances between samples in a Spectra or Spectra2D object. This is a means to quantify the similarity between samples. A heat map style plot is an option.

Usage

sampleDist(spectra, method = "pearson", plot = TRUE, ...)

Arguments

spectra

An object of S3 class Spectra or Spectra2D.

method

Character. A string giving the distance method. See rowDist for options.

plot

Logical. Shall a level plot (heat map) be made?

...

Arguments to be passed to the plotting function.

Value

A numeric matrix giving the distances between the samples.

Author(s)

Bryan A. Hanson, DePauw University.

See Also

For Spectra objects, see plotSpectraDist which compares all spectra to a single reference spectrum.

Examples

if (checkForPackageWithVersion("ChemoSpec", "5.1")) {
  library("ChemoSpec")
  library("lattice")
  data(SrE.IR)

  SrE.dmatrix <- sampleDist(SrE.IR, # cosine distance bounded on [0...2]
    method = "cosine",
    main = "SrE.IR Cosine Distance Between Samples"
  )
  SrE.dmatrix <- sampleDist(SrE.IR, # abspearson distance bounded on [0...1]
    method = "abspearson",
    main = "SrE.IR Absolute Pearson Distance Between Samples"
  )
  SrE.dmatrix <- sampleDist(SrE.IR, # euclidean distance unbounded
    method = "euclidean",
    main = "SrE.IR Euclidean Distance Between Samples"
  )
}

if (checkForPackageWithVersion("ChemoSpec2D", "0.3")) {
  library("ChemoSpec2D")
  library("lattice")
  data(MUD1)

  MUD1.dmatrix <- sampleDist(MUD1,
    method = "cosine",
    main = "MUD1 Cosine Distance Between Samples"
  )
}

ChemoSpecUtils

Functions Supporting Packages ChemoSpec and ChemoSpec2D

v0.4.96
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>)
Initial release
2021-03-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.