| 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
|
max.subset.size |
Maximum number of signatures to use to
reconstruct |
method |
As in |
trim.less.than |
After optimizing exposures with
|
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:
-
optimized.exposureA numerical vector of the exposures that give the "best" reconstruction. This vector is empty if there is an error. -
similarityThe similarity between thereconstruction(see below) andtarget.sigaccording to the distance or similarity provided by themethodargument. -
methodThe value specified for themethodargument, or an error message ifoptimize.exposureis empty. -
reconstructionThe reconstruction oftarget.sigaccording tooptimized.exposure.
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