find_best_reconstruction_QP {mSigTools} | R Documentation |
Find "best" reconstruction of a target signature or spectrum from a set of signatures.
find_best_reconstruction_QP(
target.sig,
sig.universe,
max.subset.size = NULL,
method = "cosine",
trim.less.than = 1e-10
)
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
|
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.
A list with elements:
optimized.exposure
A numerical vector of the exposures that
give the "best" reconstruction. This vector is empty if there is
an error.
similarity
The similarity between the reconstruction
(see below) and target.sig
according to the distance
or similarity provided by the method
argument.
method
The value specified for the method
argument,
or an error message if optimize.exposure
is empty.
reconstruction
The reconstruction of target.sig
according to
optimized.exposure
.
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