Predict the principal components for new trajectories
output of compute_optimal_encoding function.
data.frame containing id
, id of the trajectory, time
, time at which a change occurs and
state
, associated state. All individuals must begin at the same time T0 and end at the same time Tmax
(use cut_data
).
computation method: "parallel" or "precompute": precompute all integrals (efficient when the number of unique time values is low)
if TRUE print some information
number of cores used for parallelization (only if method == "parallel"). Default is half the cores.
parameters for integrate
function (see details).
principal components for the individuals
Other encoding functions:
compute_optimal_encoding()
,
get_encoding()
,
plot.fmca()
,
plotComponent()
,
plotEigenvalues()
,
print.fmca()
,
summary.fmca()
# Simulate the Jukes-Cantor model of nucleotide replacement
K <- 4
Tmax <- 6
PJK <- matrix(1 / 3, nrow = K, ncol = K) - diag(rep(1 / 3, K))
lambda_PJK <- c(1, 1, 1, 1)
d_JK <- generate_Markov(
n = 10, K = K, P = PJK, lambda = lambda_PJK, Tmax = Tmax,
labels = c("A", "C", "G", "T")
)
d_JK2 <- cut_data(d_JK, Tmax)
# create basis object
m <- 6
b <- create.bspline.basis(c(0, Tmax), nbasis = m, norder = 4)
# \donttest{
# compute encoding
encoding <- compute_optimal_encoding(d_JK2, b, computeCI = FALSE, nCores = 1)
#> ######### Compute encoding #########
#> Number of individuals: 10
#> Number of states: 4
#> Basis type: bspline
#> Number of basis functions: 6
#> Number of cores: 1
#>
| | 0 % elapsed=00s
|========= | 17% elapsed=00s, remaining~00s
|================= | 33% elapsed=00s, remaining~00s
|========================= | 50% elapsed=00s, remaining~00s
|================================== | 67% elapsed=00s, remaining~00s
|========================================== | 83% elapsed=00s, remaining~00s
|==================================================| 100% elapsed=00s, remaining~00s
#>
#> DONE in 0.17s
#> ---- Compute U matrix:
#>
| | 0 % elapsed=00s
|=== | 5 % elapsed=00s, remaining~01s
|===== | 10% elapsed=00s, remaining~01s
|======== | 14% elapsed=00s, remaining~01s
|========== | 19% elapsed=00s, remaining~01s
|============ | 24% elapsed=00s, remaining~01s
|=============== | 29% elapsed=00s, remaining~01s
|================= | 33% elapsed=00s, remaining~01s
|==================== | 38% elapsed=00s, remaining~00s
|====================== | 43% elapsed=00s, remaining~00s
|======================== | 48% elapsed=00s, remaining~00s
|=========================== | 52% elapsed=00s, remaining~00s
|============================= | 57% elapsed=00s, remaining~00s
|=============================== | 62% elapsed=00s, remaining~00s
|================================== | 67% elapsed=01s, remaining~00s
|==================================== | 71% elapsed=01s, remaining~00s
|======================================= | 76% elapsed=01s, remaining~00s
|========================================= | 81% elapsed=01s, remaining~00s
|=========================================== | 86% elapsed=01s, remaining~00s
|============================================== | 90% elapsed=01s, remaining~00s
|================================================ | 95% elapsed=01s, remaining~00s
|==================================================| 100% elapsed=01s, remaining~00s
#>
#> DONE in 0.9s
#> ---- Compute encoding:
#> DONE in 0s
#> Run Time: 1.08s
# predict principal components
d_JK_predict <- generate_Markov(
n = 5, K = K, P = PJK, lambda = lambda_PJK, Tmax = Tmax,
labels = c("A", "C", "G", "T")
)
d_JK_predict2 <- cut_data(d_JK, Tmax)
pc <- predict(encoding, d_JK_predict2, nCores = 1)
#> ######### Predict Principal Components #########
#>
| | 0 % elapsed=00s
|========= | 17% elapsed=00s, remaining~00s
|================= | 33% elapsed=00s, remaining~00s
|========================= | 50% elapsed=00s, remaining~00s
|================================== | 67% elapsed=00s, remaining~00s
|========================================== | 83% elapsed=00s, remaining~00s
|==================================================| 100% elapsed=00s, remaining~00s
#>
#> DONE in 0.14s
# }