orderSimilarityMatrix: Order columns and rows of a similarity matrix according to...

View source: R/similarity.R

orderSimilarityMatrixR Documentation

Order columns and rows of a similarity matrix according to m/z, retention time and clustering

Description

Internal function for shiny application. May also be used outside of shiny to reconstruct figures.

Usage

orderSimilarityMatrix(
  similarityMatrix,
  sps,
  type = c("retentionTime", "mz", "clustering"),
  group = FALSE
)

Arguments

similarityMatrix

matrix, similarityMatrix contains pair-wise similarity coefficients which give information about the similarity between precursors

sps

Spectra object containing spectra that are compared in similarityMatrix

type

character(1), one of "retentionTime", "mz", or "clustering"

group

logical(1), if TRUE group separated by "_" will be cleaved from rownames/colnames of similarityMatrix and matched against names of sps (sps$name), if FALSE rownames/colnames of similarityMatrix are taken as are and matched against names of sps (sps$name)

Details

orderSimilarityMatrix takes a similarity matrix, Spectra object (sps, containing information on m/z and retention time), and a character vector as arguments. It will then reorder rows and columns of the similarityMatrix object such, that it orders rows and columns of similarityMatrix according to m/z, retention time or clustering in each group.

orderSimilarityMatrix is employed in the shinyCircos function to create similarityMatrix objects which will allow to switch between different types of ordering in between groups (sectors) in the circos plot. It may be used as well externally, to reproduce plots outside of the reactive environment (see vignette for a workflow).

Value

matrix, orderSimilarityMatrix returns a similarity matrix with ordered rownames according to the character vector type

Author(s)

Thomas Naake, thomasnaake@googlemail.com

Examples

data("spectra", package = "MetCirc")
similarityMat <- Spectra::compareSpectra(sps_tissue[1:10], 
    FUN = MsCoreUtils::ndotproduct, ppm = 10)
rownames(similarityMat) <- colnames(similarityMat) <- sps_tissue$name[1:10]

## order according to retention time 
orderSimilarityMatrix(similarityMatrix = similarityMat, 
    sps = sps_tissue, type = "retentionTime", group = FALSE)
    

tnaake/MetCirc documentation built on Nov. 3, 2024, 11:16 a.m.