mergeClusters: Merge clusters based on dendrogram

Description Usage Arguments Details Value References See Also Examples

Description

Takes an input of hierarchical clusterings of clusters and returns estimates of number of proportion of non-null and merges those below a certain cutoff.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S4 method for signature 'matrix'
mergeClusters(x, cl, dendro = NULL,
  mergeMethod = c("none", "Storey", "PC", "adjP", "locfdr", "MB", "JC"),
  plotInfo = c("none", "all", "Storey", "PC", "adjP", "locfdr", "MB", "JC",
  "mergeMethod"), cutoff = 0.1, plot = TRUE, isCount = TRUE, ...)

## S4 method for signature 'ClusterExperiment'
mergeClusters(x, eraseOld = FALSE,
  isCount = FALSE, mergeMethod = "none", plotInfo = "all",
  clusterLabel = "mergeClusters", leafType = c("samples", "clusters"),
  labelType = c("colorblock", "name", "ids"), plot = TRUE, ...)

Arguments

x

data to perform the test on. It can be a matrix or a ClusterExperiment.

cl

A numeric vector with cluster assignments to compare to. “-1” indicates the sample was not assigned to a cluster.

dendro

dendrogram providing hierarchical clustering of clusters in cl. If x is a matrix, then the default is dendro=NULL and the function will calculate the dendrogram with the given (x, cl) pair using makeDendrogram. If x is a ClusterExperiment object, the dendrogram in the slot dendro_clusters will be used. In this case, this means that makeDendrogram needs to be called before mergeClusters.

mergeMethod

method for calculating proportion of non-null that will be used to merge clusters (if 'none', no merging will be done). See details for description of methods.

plotInfo

what type of information about the merging will be shown on the dendrogram. If 'all', then all the estimates of proportion non-null will be plotted at each node of the dendrogram; if 'mergeMethod', then only the value used in the merging is plotted at each node. If 'none', then no proportions will be added to the dendrogram. 'plotInfo' can also be one of the mergeMethod choices (even if that method is not the method chosen in 'mergeMethod' options).

cutoff

minimimum value required for NOT merging a cluster, i.e. two clusters with the proportion of DE below cutoff will be merged. Must be a value between 0, 1, where lower values will make it harder to merge clusters.

plot

logical as to whether to plot the dendrogram with the merge results

isCount

logical as to whether input data is a count matrix. See details.

...

for signature matrix, arguments passed to the plot.phylo function of ape that plots the dendrogram. For signature ClusterExperiment arguments passed to the method for signature matrix and then onto plot.phylo.

eraseOld

logical. Only relevant if input x is of class ClusterExperiment. If TRUE, will erase existing workflow results (clusterMany as well as mergeClusters and combineMany). If FALSE, existing workflow results will have "_i" added to the clusterTypes value, where i is one more than the largest such existing workflow clusterTypes.

clusterLabel

a string used to describe the type of clustering. By default it is equal to "mergeClusters", to indicate that this clustering is the result of a call to mergeClusters (only if x is a ClusterExperiment object)

leafType

if plotting, whether the leaves should be the clusters or the samples. Choosing 'samples' allows for visualization of how many samples are in the merged clusters (only if x is a ClusterExperiment object), which is the main difference between choosing "clusters" and "samples", particularly if labelType="colorblock"

labelType

if plotting, then whether leaves of dendrogram should be labeled by rectangular blocks of color ("colorblock") or with the names of the leaves ("name") (only if x is a ClusterExperiment object).

Details

If isCount=TRUE, and the input is a matrix, log2(count + 1) will be used for makeDendrogram and the original data with voom correction will be used in getBestFeatures). If input is ClusterExperiment, then setting isCount=TRUE also means that the log2(1+count) will be used as the transformation, like for the matrix case as well as the voom calculation, and will NOT use the transformation stored in the object. If FALSE, then transform(x) will be given to the input and will be used for both makeDendrogram and getBestFeatures, with no voom correction.

"Storey" refers to the method of Storey (2002). "PC" refers to the method of Pounds and Cheng (2004). "JC" refers to the method of Ji and Cai (2007), and implementation of "JC" method is copied from code available on Jiashin Ji's website, December 16, 2015 (http://www.stat.cmu.edu/~jiashun/Research/software/NullandProp/). "locfdr" refers to the method of Efron (2004) and is implemented in the package locfdr. "MB" refers to the method of Meinshausen and Buhlmann (2005) and is implemented in the package howmany. "adjP" refers to the proportion of genes that are found significant based on a FDR adjusted p-values (method "BH") and a cutoff of 0.05.

If mergeMethod is not equal to 'none' then the plotting will indicate where the clusters will be merged (assuming plotInfo is not 'none'). Note setting both 'mergeMethod' and 'plotInfo' to 'none' will cause function to stop, because nothing is asked to be done. If you just want plot of the dendrogram, with no merging performed or demonstrated on the plot, see plotDendrogram.

If the dendrogram was made with option unassignedSamples="cluster" (i.e. unassigned were clustered in with other samples), then you cannot choose the option leafType='samples'. This is because the current code cannot reliably link up the internal nodes of the sample dendrogram to the internal nodes of the cluster dendrogram when the unassigned samples are intermixed.

Value

If 'x' is a matrix, it returns (invisibly) a list with elements

If 'x' is a ClusterExperiment, it returns a new ClusterExperiment object with an additional clustering based on the merging. This becomes the new primary clustering.

References

Ji and Cai (2007), "Estimating the Null and the Proportion of Nonnull Effects in Large-Scale Multiple Comparisons", JASA 102: 495-906.

Efron (2004) <e2><80><9c>Large-scale simultaneous hypothesis testing: the choice of a null hypothesis,<e2><80><9d> JASA, 99: 96<e2><80><93>104.

Meinshausen and Buhlmann (2005) "Lower bounds for the number of false null hypotheses for multiple testing of associations", Biometrika 92(4): 893-907.

Storey (2002) "A direct approach to false discovery rates", J. R. Statist. Soc. B 64 (3)": 479<e2><80><93>498.

Pounds and Cheng (2004). "Improving false discovery rate estimation." Bioinformatics 20(11): 1737-1745.

See Also

makeDendrogram, plotDendrogram, getBestFeatures

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(simData)

#create a clustering, for 8 clusters (truth was 3)
cl<-clusterSingle(simData, subsample=FALSE,
sequential=FALSE, mainClusterArgs=list(clusterFunction="pam", clusterArgs=list(k=8)))

#give more interesting names to clusters:
newNames<- paste("Cluster",clusterLegend(cl)[[1]][,"name"],sep="")
clusterLegend(cl)[[1]][,"name"]<-newNames
#make dendrogram
cl <- makeDendrogram(cl)

#plot showing the before and after clustering
#(Note argument 'use.edge.length' can improve
#readability)
merged <- mergeClusters(cl, plotInfo="all",
mergeMethod="adjP", use.edge.length=FALSE)

#Simpler plot with just dendrogram and single method
merged <- mergeClusters(cl, plotInfo="mergeMethod",
mergeMethod="adjP", use.edge.length=FALSE,
leafType="clusters",label="name")

#compare merged to original
table(primaryCluster(cl), primaryCluster(merged))

Bioconductor-mirror/clusterExperiment documentation built on Aug. 2, 2017, 4:28 p.m.