# NOT RUN {
W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
colnames(W) <- c("sig1", "sig2")
W <- apply(W, 2, function(x) x / sum(x))
H <- matrix(c(2, 5, 3, 6, 1, 9, 1, 2), ncol = 4)
colnames(H) <- paste0("samp", 1:4)
V <- W %*% H
V
if (requireNamespace("quadprog", quietly = TRUE)) {
H_infer <- sig_fit(V, W, method = "QP")
H_infer
H
H_dt <- sig_fit(V, W, method = "QP", return_class = "data.table")
H_dt
## Show results
show_sig_fit(H_infer)
show_sig_fit(H_dt)
## Get clusters/groups
H_dt_rel <- sig_fit(V, W, return_class = "data.table", type = "relative")
z <- get_groups(H_dt_rel, method = "k-means")
show_groups(z)
}
if (requireNamespace("GenSA", quietly = TRUE)) {
H_infer <- sig_fit(V, W, method = "SA")
H_infer
H
H_dt <- sig_fit(V, W, method = "SA", return_class = "data.table")
H_dt
## Modify arguments to method
sig_fit(V, W, method = "SA", maxit = 10, temperature = 100)
## Show results
show_sig_fit(H_infer)
show_sig_fit(H_dt)
}
# }
Run the code above in your browser using DataLab