View source: R/scaledColRanks.R
scaledColRanks | R Documentation |
Compute scaled column ranks from each cell's expression profile for distance calculations based on rank correlations.
scaledColRanks(
x,
subset.row = NULL,
min.mean = NULL,
transposed = FALSE,
as.sparse = FALSE,
withDimnames = TRUE,
BPPARAM = SerialParam()
)
x |
A numeric matrix-like object containing cells in columns and features in the rows. |
subset.row |
A logical, integer or character scalar indicating the rows of |
min.mean |
A numeric scalar specifying the filter to be applied on the average normalized count for each feature prior to computing ranks.
Disabled by setting to |
transposed |
A logical scalar specifying whether the output should be transposed. |
as.sparse |
A logical scalar indicating whether the output should be sparse. |
withDimnames |
A logical scalar specifying whether the output should contain the dimnames of |
BPPARAM |
A BiocParallelParam object specifying whether and how parallelization should be performed.
Currently only used for filtering if |
Euclidean distances computed based on the output rank matrix are equivalent to distances computed from Spearman's rank correlation.
This can be used in clustering, nearest-neighbour searches, etc. as a robust alternative to Euclidean distances computed directly from x
.
If as.sparse=TRUE
, the most common average rank is set to zero in the output.
This can be useful for highly sparse input data where zeroes have the same rank and are themselves returned as zeroes.
Obviously, this means that the ranks are not centred, so this will have to be done manually prior to any downstream distance calculations.
A matrix of the same dimensions as x
, where each column contains the centred and scaled ranks of the expression values for each cell.
If transposed=TRUE
, this matrix is transposed so that rows correspond to cells.
If as.sparse
, the columns are not centered to preserve sparsity.
Aaron Lun
quickCluster
, where this function is used.
library(scuttle)
sce <- mockSCE()
rout <- scaledColRanks(counts(sce), transposed=TRUE)
# For use in clustering:
d <- dist(rout)
table(cutree(hclust(d), 4))
g <- buildSNNGraph(rout, transposed=TRUE)
table(igraph::cluster_walktrap(g)$membership)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.