Description Usage Arguments Value Examples
project_to_pcs() projects archetypes (arc_data
) and data points (arc_data
) to PC space. Archetypes are projected into PC space of data, e.i. archetypes do not affect PCA and are just projected afterwards.
project_from_pc() projects archetypes and data points to original space provided SVD decomposition results. Optionally do the reverse of log2 transformation to obtain normalised expression space.
1 2 3 4 5 6 |
arc_data |
objects of class "pch_fit", "b_pch_fit" storing the position of archetypes and other data produced by |
data |
matrix of data used in archetypal analysis, dim(variables/dimentions, examples) |
n_dim |
number of principal component dimensions |
s |
list 's' containing SVD decomposition results (U, d, Vt), standard deviation and mean of genes used for decomposition (sd, means) |
pc_method |
method to use for finding PCs: |
log2 |
log2-transform before to z-scoring and PC-projection |
offset |
log2 transformation offset (e.g. |
zscore |
standardise (substract the mean and divide by standard deviation) prior to PC-projection |
undo_zscore |
undo z-scoring by multiplying by standard deviation and adding the mean? Undo z-scoring precedes exponentiation. |
undo_log2 |
undo log2-transformation by exponentiating and substracting pseudocount? |
project_to_pcs(): list with projected $data, archetypes ($arc_data) and $s list of decomposition matrices, sds and means
project_from_pc(): archetypes projected to data space
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Random data that fits into the triangle
set.seed(4355)
arc_data = generate_arc(arc_coord = list(c(5, 0), c(-10, 15), c(-30, -20)),
mean = 0, sd = 1)
data = generate_data(arc_data$XC, N_examples = 1e4, jiiter = 0.04, size = 0.9)
# Plot
plot_arc(arc_data = arc_data, data = data,
which_dimensions = 1:2, data_alpha = 0.5) +
ggplot2::theme_bw()
# Project to PCs (in this case just rotate to align x-axis with
# the axis of most variation because the data is already 2D)
pcs = project_to_pcs(arc_data, data, n_dim = 2, pc_method = c("svd", "irlba")[1])
# Plot in PC coordinates
plot_arc(arc_data = pcs$arc_data, data = pcs$data,
which_dimensions = 1:2, data_alpha = 0.5) +
ggplot2::theme_bw()
# Project from PCs back to expression
projected = project_from_pc(pcs$arc_data, pcs$s,
undo_zscore = FALSE, undo_log2 = FALSE)
# Plot plot in projected coordinates
plot_arc(arc_data = projected, data = data,
which_dimensions = 1:2, data_alpha = 0.5) +
ggplot2::theme_bw()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.