calculateJSD: Calculate the Jensen-Shannon Divergence

calculateJSDR Documentation

Calculate the Jensen-Shannon Divergence

Description

This function calculates the Jensen-Shannon Divergence (JSD) in a SummarizedExperiment object.

Usage

## S4 method for signature 'ANY'
calculateJSD(x, ...)

## S4 method for signature 'SummarizedExperiment'
calculateJSD(
  x,
  assay.type = assay_name,
  assay_name = exprs_values,
  exprs_values = "counts",
  transposed = FALSE,
  ...
)

runJSD(x, BPPARAM = SerialParam(), chunkSize = nrow(x))

Arguments

x

a numeric matrix or a SummarizedExperiment.

...

optional arguments not used.

assay.type

a single character value for specifying which assay to use for calculation.

assay_name

a single character value for specifying which assay to use for calculation. (Please use assay.type instead. At some point assay_name will be disabled.)

exprs_values

a single character value for specifying which assay to use for calculation. (Please use assay.type instead.)

transposed

Logical scalar, is x transposed with cells in rows?

BPPARAM

A BiocParallelParam object specifying whether the JSD calculation should be parallelized.

chunkSize

an integer scalar, defining the size of data send to the individual worker. Only has an effect, if BPPARAM defines more than one worker. (default: chunkSize = nrow(x))

Value

a sample-by-sample distance matrix, suitable for NMDS, etc.

Author(s)

Susan Holmes susan@stat.stanford.edu. Adapted for phyloseq by Paul J. McMurdie. Adapted for mia by Felix G.M. Ernst

References

Jensen-Shannon Divergence and Hilbert space embedding. Bent Fuglede and Flemming Topsoe University of Copenhagen, Department of Mathematics http://www.math.ku.dk/~topsoe/ISIT2004JSD.pdf

See Also

http://en.wikipedia.org/wiki/Jensen-Shannon_divergence

Examples

data(enterotype)
library(scater)


jsd <- calculateJSD(enterotype)
class(jsd)
head(jsd)

enterotype <- runMDS(enterotype, FUN = calculateJSD, name = "JSD",
                     exprs_values = "counts")
head(reducedDim(enterotype))
head(attr(reducedDim(enterotype),"eig"))
attr(reducedDim(enterotype),"GOF")

microbiome/mia documentation built on April 27, 2024, 4:04 a.m.