find_best_reconstruction_QP {mSigTools}R Documentation

Find "best" reconstruction of a target signature or spectrum from a set of signatures.

Description

Find "best" reconstruction of a target signature or spectrum from a set of signatures.

Usage

find_best_reconstruction_QP(
  target.sig,
  sig.universe,
  max.subset.size = NULL,
  method = "cosine",
  trim.less.than = 1e-10
)

Arguments

target.sig

The signature or spectrum to reconstruct; a non-negative numeric vector or 1-column matrix-like object.

sig.universe

The universe of signatures from which to reconstruct target.sig; a non-negative numeric matrix-like object with nrow(sig.universe) == length(target.sig). The sums of each column must be 1. Must not contain duplicate columns or have other non-unique quadratic programming solutions (not checked, but will generate an error from solve.QP in package quadprog).

max.subset.size

Maximum number of signatures to use to reconstruct target.sig.

method

As in dist_one_one in package philentropy, and used only to find the final "best" reconstruction. The optimized exposures from which to selected the "best" reconstruction are calculated using optimize_exposure_QP, which uses solve.QP in package quadprog.

trim.less.than

After optimizing exposures with optimize_exposure_QP, remove exposures less than trim.less.than and then re-optimize.

Details

This function should be fast if you do not specify max.subset.size, but it will be combinatorially slow if max.subset.size is large and trim.less.than is small or negative. So do not do that. If max.subset.size is NULL, then the function just uses optimize_exposure_QP. and then excludes exposures < trim.less.than, and then re-runs optimize_exposure_QP. Otherwise, after excluding exposures < trim.less.than, then the function runs optimize_exposure_QP on subsets of signatures of size <= max.subset.size, removes exposures < trim.less.than, reruns optimize_exposure_QP, calculates the reconstruction and similarity between the reconstruction and the target.sig and returns the information for the exposures that have the greatest similarity.

Value

A list with elements:

Examples

set.seed(888)
sig.u <-
  do.call(
    cbind,
    lapply(1:6, function(x) {
      col <- runif(n = 96)
      col / sum(col)
    })
  )
rr <- find_best_reconstruction_QP(
  target.sig = sig.u[, 1, drop = FALSE],
  sig.universe = sig.u[, 2:6]
)
names(rr)
rr$optimized.exposure
rr$similarity
rr <- find_best_reconstruction_QP(
  target.sig = sig.u[, 1, drop = FALSE],
  sig.universe = sig.u[, 2:6],
  max.subset.size = 3
)
rr$optimized.exposure
rr$similarity


[Package mSigTools version 1.0.7 Index]