In the quick start section we picked some simple and familiar
clustering options that would run quickly and needed little explanation.
However, our workflow generally assumes more complex options and more
parameter variations are tried. Before getting into the specific options
of clusterMany, let us first describe some of these more
complicated setups, since many of the arguments of
clusterMany depend on understanding them.
Internal clustering procedures
clusterMany iteratively calls a function
clusterSingle over the collection of parameters.
clusterSingle is the clustering workhorse, and may be used
by the user who wants more fine-grained control, see documentation of
clusterSingle.
Within each call of clusterSingle, there are three
possible steps, depending on the value of the arguments
subsample and sequential:
- Subsampling (
subsampleClustering) – if
subsample=TRUE
- Main Clustering (
mainClustering)
- Sequential (
seqCluster) – if
sequntial=TRUE
If both sequential and subsample are
FALSE, then step 1 and step 3 are skipped and
clusterSingle just calls the mainClustering
(step 2), resulting in a basic clustering routine applied to the input
data. If subsample=TRUE, then step 1
(subsampleClustering) is called which subsamples the input
data and clusters each subsample to calculate a co-occurance matrix.
That co-occurance matrix is used as the input for
mainClustering (step 2). If sequential=TRUE
this process (step 1 then step 2 if subsample=TRUE or just
step 2 if subsample=FALSE) is iterated over and over again
to iteratively select the best clusters (see ?seqCluster
for a detailed description). Each of these steps has a function that
goes with it, noted above, but they should not generally be called
directly by the user. However, the documentation of these functions can
be useful.
In particular, arguments to these three functions that are not set by
clusterMany can be passed via named lists to the
arguments: subsampleArgs, mainClusterArgs, and
seqArgs. Some of the arguments to these functions can be
varied in clusterMany, but more esoteric ones should be
sent as part of the named list of parameters given to
clusterMany; those named lists will be fixed for all
parameter combinations tried in clusterMany.
Main Clustering (Step 2): mainClustering
The main clustering (step 2) described above is done by the function
mainClustering. In addition to the basic clustering
algorithms on the input data, we also implement many other common
cluster processing steps that are relevant to the result of the
clustering. We have already seen such an example with dimensionality
reduction, where the input \(D\) is
determined based on different input data. Many of the arguments to
mainClustering are arguments to clusterMany as
well so that mainClusterArgs is usually not needed. The
main exception would be to send more esoteric arguments to the
underlying clustering function called in the main clustering step. The
syntax for this would be to give a nested list to the argument
mainClusterArgs
clusterMany(x,clusterFunction="hierarchicalK", ... , mainClusterArgs=list(clusterArgs=list(method="single") ))
Here we change the argument method in the clustering
function hclust called by the hierarchicalK
function to single.
Subsampling (step 1) subsampleClustering
A more significant process that can be coupled with any clustering
algorithm is to continually by subsample the data and cluster the
subsampled data. This creates a \(n x
n\) matrix \(S\) that is a
matrix of co-clustering percentages – how many times two samples
co-clustered together over the subsamples (there are slight variations
as how this can be calculated, see help pages of
subsampleClustering ). This does not itself give a
clustering, but the resulting \(S\)
matrix can then form the basis for clustering the samples. Specifically,
the matrix \(D=1-S\) is then given as
input to the main clustering step described above. The subsampling
option is computationally expensive, and when coupled with comparing
many parameters, does result in a lengthy evaluation of
clusterMany. However, we recommend it if the number of
samples is not too large as one of the most useful methods for getting
stable clustering results.
Note that the juxtaposition of step 1 then step 2 (the subsampling
and then feeding the results to the main clustering function) implies
there actually two different possible clustering algorithms (and sets of
corresponding parameters) – one for the clustering on the subsampled
data, and one for the clustering of the resulting \(D\) based on the percentage of coClustering
of samples. This brings up a restriction on the clustering function in
the main clustering step – it needs to be able to handle input that is a
dissimilarity (inputType is either diss or
either).
Furthermore, the user might want to set clustering function and
corresponding parameters separately for step 1 and step 2. The way that
clusterMany handles this is that the main arguments of
clusterMany focus on varying the parameters related to step
2 (the main clustering step, i.e. the clustering of \(D\) after subsampling). For this reason,
the argument clusterFunction in clusterMany
varies the clustering function used by the main clustering (step 2), not
the subsampling step. The clustering function of the subsampling (step
1) can be specified by the user via subsampleArgs, but in
this case it is set for all calls of clusterMany
and does not vary. Alternatively, if the user doesn’t specify the
clusterFunction in subsampleArgs then the
default is to use clusterFunction of the main clustering
step along with any required arguments given by the user for that
function (there are some cases where using the
clusterFunction of the main step is not possible for the
subsampling step, in which case the default is to use “pam”).
More generally, since few of the arguments to
subsampleClustering are allowed to be varied by the direct
arguments to clusterMany, it is also more common to want to
change these arguments via the argument subsampleArgs.
Examples might be resamp.num (the number of subsamples to
draw) or samp.p (the proportion of samples to draw in each
subsample) – see ?subsampleClustering for a full
documentation of the possible arguments. In addition, there are
arguments to be passed to the underlying clustering function; like for
mainClustering, these arguments would be a nested list to
the argument subsampleArgs.
An example of a syntax that sets the arguments for
subsampleClustering would be:
clusterMany(x,..., subsampleArgs=list(resamp.num=100,samp.p=0.5,clusterFunction="hiearchicalK", clusterArgs=list(method="single") ))
Sequential Detection of Clusters (Step 3):
seqCluster
Another complicated addition that can be added to the main clustering
step is the implementation of sequential clustering. This refers to
clustering of the data, then removing the “best” cluster, and then
re-clustering the remaining samples, and then continuing this iteration
until all samples are clustered (or the algorithm in some other way
calls a stop). Such sequential clustering can often be convenient when
there is very dominant cluster, for example, that is far away from the
other mass of data. Removing samples in these clusters and resampling
can sometimes be more productive and result in a clustering more robust
to the choice of samples. A particular implementation of such a
sequential method, based upon (Tseng and Wong
2005), is implemented in the clusterExperiment
package when the option sequential=TRUE is chosen (see
?seqCluster for documentation of how the iteration is
done). Sequential clustering can also be quite computationally
expensive, particularly when paired with subsampling to determine \(D\) at each step of the iteration.
Because of the iterative nature of the sequential step, there are
many possible parameters (see ?seqCluster). Like subsample
clustering, clusterMany does not allow variation of very
many of these parameters, but they can be set via passing arguments in a
named list to seqArgs. An example of a syntax that sets the
arguments for seqCluster would be:
clusterMany(x,..., seqArgs=list( remain.n=10))
This code changes the remain.n option of the sequential
step, which governs when the sequential step stops because there are not
enough samples remaining.
Example changing the distance function
Providing different distance functions is slightly more involved than
the other parameters, so we give an example here.
First we define distances that we would like to compare. We are going
to define two distances that take values between 0-1 based on different
choices of correlation.
corDist<-function(x){(1-cor(t(x),method="pearson"))/2}
spearDist<-function(x){(1-cor(t(x),method="spearman"))/2}
These distances are defined so as to give distance of 0 between
samples with correlation 1, and distance of 1 for correlation -1.
We will also compare using different algorithms for clustering.
Currently, clusterMany requires that the distances work
with all of the clusterFunction choices given. Since some
of the clusterFunction algorithms require a distance matrix
between 0-1, this means we can only compare all of the algorithms when
the distance is a 0-1 distance. (Future versions may try to create a
work around so that the algorithm just skips algorithms that don’t match
the distance). Since the distances we defined are between 0-1, however,
we can use any algorithm that takes dissimilarities as input.
Note on 0-1 clustering when
subsample=FALSE We would note that the default
values of \(\alpha\) in
clusterMany and RSEC for the 0-1 clustering
were set with the distance \(D\) the
result of subsampling or other concensus summary in mind. In generally,
subsampling creates a \(D\) matrix with
high similarity for many samples who share a cluster (the proportion of
times samples are seen together for well clustered samples can easily be
in the .8-.95 range, or even exactly 1). For this reason the default
\(\alpha\) is 0.1 which requires
distances between samples in the 0.1 range or less (i.e. a similarity in
the range of 0.9 or more).
To illustrate this point, we show an example of the \(D\) matrix from subsampling. To do this we
make use of the clusterSingle which is the workhorse
mentioned above that runs a single clustering command directly; it gives
the output \(D\) from the sampling in
the “coClustering” slot of ce when we set
replaceCoCluster=TRUE (and therefore we save it as a
separate object, so that it doesn’t write over the existing
“coClustering” slot in ce). Note that the result is \(1-p_{ij}\) where \(p_{ij}\) is the proportion of times sample
\(i\) and \(j\) clustered together.
ceSub<-clusterSingle(ce,reduceMethod="mad",nDims=1000,subsample=TRUE,subsampleArgs=list(clusterFunction="pam",clusterArgs=list(k=8)),clusterLabel="subsamplingCluster",mainClusterArgs=list(clusterFunction="hierarchical01",clusterArgs=list(alpha=0.1),minSize=5), saveSubsamplingMatrix=TRUE)
plotCoClustering(ceSub)

We see even here, the default of \(\alpha=0.1\) was perhaps too conservative
since only two clusters came out (at leastwith size greater than 5).
However, the distances based on correlation calculated directly on
the data, such as we created above, are also often used for clustering
expression data directly (i.e. without the subsampling step). But they
are unlikely to have dissimilarities as low as seen in subsampling, even
for well clustered samples. Here’s a visualization of the correlation
distance matrix we defined above (using Spearman’s correlation) on the
top 1000 most variable features:
dSp<-spearDist(t(transformData(ce,reduceMethod="mad",nFilterDims=1000)))
plotHeatmap(dSp,isSymmetric=TRUE)

We can see that the choice of \(\alpha\) must be much higher (and we are
likely to be more sensitive to it).
Notice to calculate the distance in the above plot, we made use of
the transform function applied to our ce
object to get the results of dimensionality reduction. The
transform function gave us a data matrix back that has been
transformed, and also reduced in dimensions, like would be done in our
clustering routines. transform has similar parameters as
seen in clusterMany,makeDendrogram or
clusterSingle and is useful when you want to manually apply
something to transformed and/or dimensionality reduced data; and you can
be sure you are getting the same matrix of data back that the clustering
algorithms are using.
Comparing distance functions with
clusterMany Now that we have defined the distances
we want to compare in our global environment, we can give these to the
argument “distFunction” in clusterMany. They should be
given as character strings giving the names of the functions. For
computational ease for this vignette, we will just choose the
dimensionality reduction to be the top 1000 features based on MAD and
set K=8 or \(\alpha=0.45\).
Since we haven’t yet calculated “mad” on this object, it hasn’t been
calculated yet. clusterMany does not let you mix and match
between uncalculated and stored filters (or dimensionality reductions),
so our first step is to store the mad results. We will save these
results as a separate object so as to not disrupt the earlier
workflow.
ceDist<-makeFilterStats(ce,filterStats="mad")
ceDist
## class: ClusterExperiment
## dim: 7069 65
## reducedDimNames: PCA
## filterStats: var var_makeConsensus.final mad
## -----------
## Primary cluster type: mergeClusters
## Primary cluster label: mergeClusters
## Table of clusters (of primary clustering):
## -1 m01 m02 m03 m04
## 8 27 14 8 8
## Total number of clusterings: 41
## Dendrogram run on 'makeConsensus,final' (cluster index: 2)
## -----------
## Workflow progress:
## clusterMany run? Yes
## makeConsensus run? Yes
## makeDendrogram run? Yes
## mergeClusters run? Yes
ceDist<-clusterMany(ceDist, k=7:9, alpha=c(0.35,0.4,0.45),
clusterFunction=c("tight","hierarchical01","pam","hierarchicalK"),
findBestK=FALSE,removeSil=c(FALSE), distFunction=c("corDist","spearDist"),
makeMissingDiss=TRUE,
reduceMethod=c("mad"),nFilterDims=1000,run=TRUE)
## 48 parameter combinations, 0 use sequential method, 0 use subsampling method
## Calculating the 2 Requested Distance Matrices needed to run clustering comparisions (if 'distFunction=NA', then needed because of choices of clustering algorithms and 'makeMissingDiss=TRUE').
## done.
##
## Running Clustering on Parameter Combinations...
## done.
clusterLabels(ceDist)<-gsub("clusterFunction","alg",clusterLabels(ceDist))
clusterLabels(ceDist)<-gsub("Dist","",clusterLabels(ceDist))
clusterLabels(ceDist)<-gsub("distFunction","dist",clusterLabels(ceDist))
clusterLabels(ceDist)<-gsub("hierarchical","hier",clusterLabels(ceDist))
par(mar=c(1.1,15.1,1.1,1.1))
plotClusters(ceDist,axisLine=-2,colData=c("Biological_Condition"))

Notice that using the “tight” methods did not give relevant results
(no samples were clustered)
Example using a user-defined clustering algorithm
Here, we show how to use a user-defined clustering algorithm in
clusterSingle. Our clustering algorithm will be a simple
nearest-neighbor clustering.
To do so, we need to create a ClusterFunction object
that defines our algorithm. ClusterFunction objects
recognize clustering algorithms of two different types, based on the
required input from the user: 01 or K (see
(ClusterFunction)[#ClusterFunction] section above for more). Type
K refers to a clustering algorithm where the user must
specify the number of clusters as input parameter, and this is the type
of algorithm we will implement (though as we’ll see, in fact our
clustering algorithm doesn’t have the user specify the number of
clusters…).
First, we need to define a wrapper function that performs the
clustering. Here, we define a simple shared nearest-neighbor clustering
using functions from the scran and the igraph
packages.
library(scran)
library(igraph)
SNN_wrap <- function(inputMatrix, k, steps = 4, ...) {
snn <- buildSNNGraph(inputMatrix, k = k, d = NA, transposed = FALSE) ##scran package
res <- cluster_walktrap(snn, steps = steps) #igraph package
return(res$membership)
}
Here the argument k defines the number of
nearest-neighbors to use in constructing the nearest neighbor graph.
To create a type K algorithm, the wrapper must have two
required arguments:
- an argument for the input data. This can be
x if the
input is a matrix of \(N\) samples on
the columns and features on the rows, or diss if the input
is expected to be a \(NxN\)
dissimilarity matrix. Both x and diss can be
given as parameters if the algorithm handles either one)
- a parameter
k specifying the number of clusters (or any
other integer-valued parameter that the clustering relies on)
Our k value for SNN_wrap will not in fact
specify the number of clusters, but that is not actually required
anywhere. But setting it up as type K mainly distinguishes
it from the 01 type (which expects a dissimilarity matrix
taking values between 0 and 1 in its dissimilarity entries, as input).
Also setting it up as type K allows us to use the
findBestK option, where a range of k values is
tried and those with the best results (in silhouette width) is
reported.
Our wrapper function should return a integer vector
corresponding to the cluster assignments of each sample (see
?ClusterFunction for information about other types of
output available).
clusterExperiment provides the function
internalFunctionCheck that validates user-defined cluster
functions. Among other things, it checks that the input and output are
compatible with the clusterExperiment workflow (see
?internalFunctionCheck for details). The call to
internalFunctionCheck contains, in addition to the function
definition, arguments specifying information about the type of input,
the type of algorithm, and type of output expected by the function. This
information is passed to clusterMany and
clusterSingle so that they know what to pass and what to
expect from the user-defined method.
internalFunctionCheck(SNN_wrap, inputType = "X", algorithmType = "K",
outputType="vector")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## [1] TRUE
If it passes all checks (returns TRUE), we can then
create an object of the S4 class ClusterFunction to be used
within the package using this same set of arguments. If it fails, it
will return a character string giving the error. Among the checks is
running the function on a small randomly generated set of data, so the
errors may not be about the format of the function, but also whether the
series of code runs.
Since we passed the checks, we are ready to define our
ClusterFunction object.
SNN <- ClusterFunction(SNN_wrap, inputType = "X", algorithmType = "K",
outputType="vector")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
Now that we have our object SNN, we can treat our custom
method as a base clustering routine to be used in
clusterMany, similarly to how we used kmeans
and pam earlier. However, unlike before, you should pass
the actual object SNN, and not a quoted version (i.e. not
"SNN").
In this example, we use clusterSingle to implement a
subsample clustering based on SNN. clusterSingle is useful
if you just want to create a single clustering.
We give SNN to the subsampleArgs that will
be passed to the subsampling. (Note that to create a consensus
clustering from the different subsamplings we use a different function,
"hierarchical01", that is passed to
mainClusterArgs),
ceCustom <- clusterSingle(ce, reduceMethod="PCA",
nDims=50, subsample = TRUE,
sequential = FALSE,
mainClusterArgs = list(clusterFunction = "hierarchical01",
clusterArgs = list(alpha = 0.3),
minSize = 1),
subsampleArgs = list(resamp.num=100,
samp.p = 0.7,
clusterFunction = SNN,
clusterArgs = list(k = 10),
ncores = 1,
classifyMethod='InSample')
)
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## class: ClusterExperiment
## dim: 7069 65
## reducedDimNames: PCA
## filterStats: var var_makeConsensus.final
## -----------
## Primary cluster type: clusterSingle
## Primary cluster label: clusterSingle
## Table of clusters (of primary clustering):
## 1 2 3 4
## 33 30 1 1
## Total number of clusterings: 42
## Dendrogram run on 'makeConsensus,final' (cluster index: 2)
## -----------
## Workflow progress:
## clusterMany run? Yes
## makeConsensus run? Yes
## makeDendrogram run? Yes
## mergeClusters run? Yes
Similarly, we can use clusterMany to compute clusters
using many different methods, including built-in and custom functions.
To mix and match built-in functions, you need to get the actual
ClusterFunction objects that match their names, using the
getBuiltInFunction function.
clFuns<-getBuiltInFunction(c("pam","kmeans"))
Then we will add our function to the list of functions. Note that it
is important we give a name to every element of the list, including our
new function!
clFuns<-c(clFuns, "SNN"=SNN)
Now we can give this list of functions to
clusterMany
ceCustom <- clusterMany(ce, dimReduce="PCA",nPCADims=50,
clusterFunction=clFuns,
ks=4:15, findBestK=FALSE)
## 36 parameter combinations, 0 use sequential method, 0 use subsampling method
## Running Clustering on Parameter Combinations...
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## Warning in .local(x, ...): 'buildSNNGraph' is deprecated.
## Use 'bluster::makeSNNGraph' instead.
## See help("Deprecated")
## done.
Note that if I call getBuiltInFunction for only one
cluster function, it returns the actual ClusterFunction
object, not a list of length 1. To combine it with other functions you
need to make it into a list.