These functions are accessors for functions implemented in the DirichletMultinomial package

calculateDMN(x, ...)

# S4 method for class 'ANY'
calculateDMN(
  x,
  k = 1,
  BPPARAM = SerialParam(),
  seed = runif(1, 0, .Machine$integer.max),
  ...
)

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

runDMN(x, name = "DMN", ...)

getDMN(x, name = "DMN", ...)

# S4 method for class 'SummarizedExperiment'
getDMN(x, name = "DMN")

bestDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"), ...)

# S4 method for class 'SummarizedExperiment'
bestDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"))

getBestDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"), ...)

# S4 method for class 'SummarizedExperiment'
getBestDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"))

calculateDMNgroup(x, ...)

# S4 method for class 'ANY'
calculateDMNgroup(
  x,
  variable,
  k = 1,
  seed = runif(1, 0, .Machine$integer.max),
  ...
)

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

performDMNgroupCV(x, ...)

# S4 method for class 'ANY'
performDMNgroupCV(
  x,
  variable,
  k = 1,
  seed = runif(1, 0, .Machine$integer.max),
  ...
)

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

Arguments

x

a numeric matrix with samples as rows or a SummarizedExperiment object.

...

optional arguments not used.

k

Numeric scalar. The number of Dirichlet components to fit. See dmn. (Default: 1)

BPPARAM

A BiocParallelParam object specifying whether the calculation should be parallelized.

seed

Numeric scalar. Random number seed. See dmn

assay.type

Character scalar. Specifies the name of the assay used in calculation. (Default: "counts")

assay_name

Deprecated. Use assay.type instead.

exprs_values

Deprecated. Use assay.type instead.

transposed

Logical scalar. Is x transposed with samples in rows? (Default: FALSE)

name

Character scalar. The name to store the result in metadata

type

Character scalar. The type of measure used for the goodness of fit. One of ‘laplace’, ‘AIC’ or ‘BIC’.

variable

Character scalar. A variable from colData to use as a grouping variable. Must be a character of factor.

Value

calculateDMN and getDMN return a list of DMN objects, one element for each value of k provided.

bestDMNFit returns the index for the best fit and getBestDMNFit returns a single DMN object.

calculateDMNgroup returns a DMNGroup object

performDMNgroupCV returns a data.frame

See also

DMN-class, DMNGroup-class, dmn, dmngroup, cvdmngroup , accessors for DMN objects

Examples

fl <- system.file(package="DirichletMultinomial", "extdata", "Twins.csv")
counts <- as.matrix(read.csv(fl, row.names=1))
fl <- system.file(package="DirichletMultinomial", "extdata", "TwinStudy.t")
pheno0 <- scan(fl)
lvls <- c("Lean", "Obese", "Overwt")
pheno <- factor(lvls[pheno0 + 1], levels=lvls)
colData <- DataFrame(pheno = pheno)

tse <- TreeSummarizedExperiment(assays = list(counts = counts),
                                colData = colData)

library(bluster)

# Compute DMM algorithm and store result in metadata
tse <- addCluster(tse, name = "DMM", DmmParam(k = 1:3, type = "laplace"),
               by = "samples", full = TRUE)

# Get the list of DMN objects
metadata(tse)$DMM$dmm
#> [[1]]
#> class: DMN 
#> k: 1 
#> samples x taxa: 278 x 130 
#> Laplace: 39227.38 BIC: 39527.91 AIC: 39292.11 
#> 
#> [[2]]
#> class: DMN 
#> k: 2 
#> samples x taxa: 278 x 130 
#> Laplace: 38872.47 BIC: 39588.93 AIC: 39115.53 
#> 
#> [[3]]
#> class: DMN 
#> k: 3 
#> samples x taxa: 278 x 130 
#> Laplace: 38854.25 BIC: 40001.15 AIC: 39290.14 
#> 

# Get and display which objects fits best
bestFit <- metadata(tse)$DMM$best
bestFit
#> [1] 3

# Get the model that generated the best fit
bestModel <- metadata(tse)$DMM$dmm[[bestFit]]
bestModel
#> class: DMN 
#> k: 3 
#> samples x taxa: 278 x 130 
#> Laplace: 38854.25 BIC: 40001.15 AIC: 39290.14 

# Get the sample-cluster assignment probability matrix
head(metadata(tse)$DMM$prob)
#>                    1            2            3
#> TS1.2   9.999997e-01 2.998576e-07 4.862182e-09
#> TS10.2  9.516067e-01 8.377897e-09 4.839328e-02
#> TS100.2 4.436338e-08 8.562199e-02 9.143780e-01
#> TS100   9.919529e-01 8.046703e-03 4.122699e-07
#> TS101.2 1.352825e-12 4.161738e-07 9.999996e-01
#> TS103.2 9.999977e-01 7.468125e-10 2.313118e-06

# Get the weight of each component for the best model
bestModel@mixture$Weight
#> [1] 0.5655860 0.2227191 0.2116949