View source: R/reWeightEmbedding.R
| reWeightEmbedding | R Documentation |
Re-weights embedding according to given weights for each reference dataset. This gives more or less weighting to each contributing dataset and method (PCA or LDA),
reWeightEmbedding(embedding, weights = NULL, factor = 1e+06)
embedding |
Joint embedding as output from stabMap. |
weights |
(optional) named numeric vector giving relative weights for each reference dataset. |
factor |
numeric multiplicative value to offset near-zero values. |
matrix of same dimensions as 'embedding'.
set.seed(2021)
assay_list = mockMosaicData()
lapply(assay_list, dim)
# specify which datasets to use as reference coordinates
reference_list = c("D1", "D3")
# specify some sample labels to distinguish using linear discriminant
# analysis (LDA)
labels_list = list(
D1 = rep(letters[1:5], length.out = ncol(assay_list[["D1"]]))
)
# stabMap
out = stabMap(assay_list,
reference_list = reference_list,
labels_list = labels_list,
ncomponentsReference = 20,
ncomponentsSubset = 20)
# look at the scale of each component and discriminant
boxplot(out, las = 2, outline = FALSE)
# re-weight embedding for less contribution from LDs and equal contribution
# from PCs of both references
out_reweighted = reWeightEmbedding(out, weights = c("D1_LD" = 0.5, "D1_PC" = 1, "D3_PC" = 1))
# look at the new scale of each component and discriminant
boxplot(out_reweighted, las = 2, outline = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.