getAffinity {mnem} | R Documentation

## Calculate responsibilities.

### Description

This function calculates the responsibilities of each component for all cells from the expected log distribution of the hidden data.

### Usage

    getAffinity(
      x,
      affinity = 0,
      norm = TRUE,
      logtype = 2,
      mw = NULL,
      data = matrix(0, 2, ncol(x)),
      complete = FALSE
    )

### Arguments

`x` | log odds for l cells and k components as a kxl matrix
`affinity` | 0 for standard soft clustering, 1 for hard clustering during inference (not recommended)
`norm` | if TRUE normalises to probabilities (recommended)
`logtype` | logarithm type of the data (e.g. 2 for log2 data or exp(1) for natural)
`mw` | mixture weights of the components
`data` | data in log odds
`complete` | if TRUE, complete data log likelihood is considered (for very large data sets, e.g. 1000 cells and 1000 E-genes)

### Value

responsibilities as a kxl matrix (k components, l cells)

### Author(s)

Martin Pirkl

### Examples

    sim <- simData(Sgenes = 3, Egenes = 2, Nems = 2, mw = c(0.4,0.6))
    data <- (sim$data - 0.5)/0.5
    data <- data + rnorm(length(data), 0, 1)
    result <- mnem(data, k = 2, starts = 1)
    resp <- getAffinity(result$probs, mw = result$mw, data = data)

[Package mnem version 1.8.0 Index]