View source: R/findFirstSphere.R
findFirstSphere | R Documentation |
Tests whether each hypersphere is not redundant to (i.e., lies more than a threshold distance away from) another hypersphere with a lower p-value.
findFirstSphere(x, pvalues, threshold=1, block=NULL, num.threads=1)
x |
A numeric matrix of hypersphere coordinates (median locations for all markers), where rows correspond to hyperspheres and columns correspond to markers. Alternatively, a CyData object containing median intensities for groups of cells, such as that produced by |
pvalues |
A numeric vector of p-values, one for each row (i.e., hypersphere) of |
threshold |
A numeric scalar specifying the maximum distance between the locations of two redundant hyperspheres. |
block |
A factor specifying which hyperspheres belong to which block, where non-redundant hyperspheres are identified within each block. |
num.threads |
Integer scalar specifying the number of threads to use. |
This function iterates across the set of hyperspheres, typically ordered by decreasing significance.
It will tag a hypersphere as being redundant if its location lies within threshold
of the location of a higher-ranking hypersphere in all dimensions.
In this manner, the set of all DA hyperspheres can be filtered down to a non-redundant subset that is easier to interpret.
Note that the criterion for redundancy mentioned above is equivalent to a Chebyshev distance, rather than Euclidean.
This is easier to interpret, especially given that the median intensity is defined separately for each marker.
Unlike in countCells
, the threshold is not scaled by the number of markers because each hypersphere location is computed as an average across cells.
This means that there is generally no need to account for extra distance due to noise between cells.
The default threshold
of unity assumes that the intensities have been transformed to or near a log10 scale.
It means that one hypersphere must vary from another by at least one log10-unit (i.e., a 10-fold change in intensity) in at least one marker to be considered non-redundant.
This avoids reporting many hyperspheres that differ from each other by relatively small, uninteresting shifts in intensity.
Greater resolution can be obtained by decreasing this value, e.g., to 0.5.
If block
is set, non-redundant hyperspheres are only identified within each block (i.e., a hypersphere cannot be redundant to hyperspheres in different blocks).
For example, one can set block
to the sign of the log-fold change.
This ensures that hyperspheres changing in one direction are not considered redundant to those changing in another direction.
By default, all hyperspheres are considered to be part of the same block.
A logical vector indicating whether each of the hyperspheres in x
is non-redundant.
Aaron Lun
# Mocking up some data.
coords <- matrix(rnorm(10000, 2, sd=0.3), nrow=1000)
pval <- runif(1000)
logfc <- rnorm(1000)
# Keep most significant non-redundant ("first") hyperspheres.
findFirstSphere(coords, pval)
# Block on the sign of the log-fold change.
findFirstSphere(coords, pval, block=sign(logfc))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.