View source: R/convertPCsToSCE.R
convertPCsToSCE | R Documentation |
Convert low-dimensional corrected PCs to a SingleCellExperiment containing corrected expression values. This is a low-level function and most users should not need to call it.
convertPCsToSCE(
corrected.df,
pc.info,
assay.name = "reconstructed",
dimred.name = "corrected"
)
corrected.df |
A DataFrame containing a nested matrix of low-dimensional |
pc.info |
A list containing PCA statistics, in particular a |
assay.name |
String specifying the name of the assay to use to store the corrected expression values. |
dimred.name |
String containing the name fo the |
The corrected expression values are obtained by simply taking the crossproduct of the corrected PCs with the rotation matrix. This reverses the original projection to PC space while retaining the effect of the correction. These values are best used for visualization; the low-dimensional corrected coordinates are more efficient for per-cell operations like clustering, while the original uncorrected expression values are safer to interpret for per-gene analyses.
A SingleCellExperiment containing a LowRankMatrix with the corrected per-gene expression values.
The colData
contains the batch identities, the rowData
contains the rotation matrix,
and the reducedDims
contains the low-dimensional corrected values (if dimred.name
is not NULL
).
All additional metadata from corrected.df
and pc.info
is stored in metadata
.
Aaron Lun
reducedMNN
, to compute corrected.df
; and multiBatchPCA
, to compute pc.info
.
fastMNN
, which uses this function to obtain low-rank corrected values.
B1 <- matrix(rnorm(10000), nrow=50) # Batch 1
B2 <- matrix(rnorm(10000), nrow=50) # Batch 2
# Equivalent to fastMNN().
cB1 <- cosineNorm(B1)
cB2 <- cosineNorm(B2)
pcs <- multiBatchPCA(cB1, cB2)
mnn.out <- reducedMNN(pcs[[1]], pcs[[2]])
sce <- convertPCsToSCE(mnn.out, metadata(pcs))
sce
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.