Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
epurdom committed Jun 14, 2017
2 parents 19ecc5e + d79b3b4 commit a26d494
Show file tree
Hide file tree
Showing 36 changed files with 1,925 additions and 923 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ language: r
cache: packages

# R versions to be tested on
r:
r:
- bioc-release
- bioc-devel

## Turn this to true before submission to CRAN/Bioconductor
warnings_are_errors: false

r_build_args: "--no-build-vignettes"
r_check_args: "--no-vignettes"
# r_build_args: "--no-build-vignettes"
# r_check_args: "--no-vignettes"

notifications:
email:
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clusterExperiment
Title: Compare Clusterings for Single-Cell Sequencing
Version: 1.3.0
Version: 1.3.1
Description: Provides functionality for running and comparing many
different clusterings of single-cell sequencing data or other large mRNA Expression data sets.
Authors@R: c(person("Elizabeth", "Purdom", email = "epurdom@stat.berkeley.edu",
Expand All @@ -13,9 +13,9 @@ BugReports: https://github.com/epurdom/clusterExperiment/issues
License: Artistic-2.0
Depends:
R (>= 3.3),
methods,
SummarizedExperiment
Imports:
methods,
NMF,
RColorBrewer,
ape,
Expand All @@ -29,7 +29,8 @@ Imports:
matrixStats,
graphics,
parallel,
MAST
MAST,
RSpectra
Suggests:
BiocStyle,
knitr,
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exportMethods("clusterTypes<-")
exportMethods("coClustering<-")
exportMethods("orderSamples<-")
exportMethods("primaryClusterIndex<-")
exportMethods("transformation<-")
exportMethods(RSEC)
exportMethods(addClusters)
exportMethods(clusterContrasts)
Expand All @@ -39,6 +40,7 @@ exportMethods(clusterTypes)
exportMethods(coClustering)
exportMethods(combineMany)
exportMethods(convertClusterLegend)
exportMethods(dendroClusterIndex)
exportMethods(getBestFeatures)
exportMethods(makeDendrogram)
exportMethods(mergeClusters)
Expand Down Expand Up @@ -73,6 +75,8 @@ importFrom(MAST,Hypothesis)
importFrom(NMF,aheatmap)
importFrom(RColorBrewer,brewer.pal)
importFrom(RColorBrewer,brewer.pal.info)
importFrom(RSpectra,svds)
importFrom(ape,phydataplot)
importFrom(ape,plot.phylo)
importFrom(cluster,daisy)
importFrom(cluster,pam)
Expand All @@ -87,8 +91,13 @@ importFrom(matrixStats,rowVars)
importFrom(parallel,mclapply)
importFrom(phylobase,ancestors)
importFrom(phylobase,descendants)
importFrom(phylobase,edgeLength)
importFrom(phylobase,getNode)
importFrom(phylobase,labels)
importFrom(phylobase,nNodes)
importFrom(phylobase,nodeLabels)
importFrom(phylobase,rootNode)
importFrom(phylobase,subset)
importFrom(stats,dist)
importFrom(stats,hclust)
importFrom(stats,mad)
Expand Down
25 changes: 25 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
Changes in version 1.3.1 ( Release date: 2017-06-14 )
==============
Changes:
* change how `plotHeatmap` handles visualizeData argument, so not required to have same number of genes as original, only same number of samples.
* Now if color of vectors given in `clusterLegend` does not have names, `plotHeatmap` will give them names matching the variable so that they will be used by `aheatmap` (previously would have left all colors white because do not have matching names).
* Large changes to how dendrograms are plotted by `plotDendrogram` and `mergeClusters`. This includes the ability to see the before and after clusterings along side the mergeClusters result, as well as a new slot added to the clusterExperiment class (`dendro_outbranch`). The names of several arguments to `mergeClusters` and `plotDendrogram` were changed for clarity:
- `leaves` is now `leafType` in `plotDendrogram`.
- `plotType` is now `plotInfo` in `mergeClusters`
- `doPlot` is now `plot` in `mergeClusters`
- `leafType` is now an option for `mergeClusters` as well.
- Now when `plotInfo` (previously `plotType`) is set to `none`, the plot is still drawn, but just no information about the merging is added to the plot. To not plot the dendrogram at all, set `plot=FALSE`.
- The option `labelType` in either `plotDendrogram` or `mergeClusters` controls whether names (`name`) or rectangular color blocks corresponding to the cluster (`colorblock`) are put at the tips of the dendrogram to label the clusters/samples.
* added `dendroClusterIndex` that behaves similarly to `primaryClusterIndex`
* added ability to give `dendro` as charater option to `whichClusters` argument
* added `transformation<-` to be able to assign manually the transformation slot
* Move MAST into 'suggests' pacakge so that not need R 3.4 to run the package.
* Change calculation of PCA dimensionality reduction to use `svds` from `RSpectra` package to improve speed

Bugs:
* Fixed bug in RSEC where `combineProportion` argument was being ignored (set to 1)
* Fixed bug in definition of `transform` so that extends existing generic rather than masking it.

Changes in version 1.3.0 ( Release date: 2017-05-24 )
==============
Changes:
* `plotHeatmap` accepts `data.frame` or `ExpressionSet` objects for the data argument (calls `data.matrix` or `exprs` on object and sends to matrix version)
* Added `plotBarplot` to plot a barplot for 1 cluster or comparison of 2 clusters along with tests.
* Added `whichClusters` argument to `clusterMatrix` to return only clusters corresponding to certain clusters. Mainly relevant for using arguments like `workflow` that are used by other commands (otherwise could just index the complete matrix manually...)


Bug fixes:
* `plotHeatmap` now goes through the `clusterLegend` input and removes levels that do not exist in the sampleData; this was causing incorrect coloring when the `clusterLegend` had more (or less) levels that it assigned color to than the `sampleData` did (e.g. if `sampleData` was a subset of larger dataset upon which the original colors were assigned.) NOTE: that this now has the effect of NOT plotting all values in the clusterLegend if they are not represented in the data, thus changing the previous behavior of `plotHeatmap` legend.
* fixed bug in how `plotHeatmap` checked that the dimensions of user-supplied dendrogram match that of data (matrix version).
* fixed `convertClusterLegend` so when `output` is `matrixNames` or `matrixColors`, the resulting matrix has the `colnames` equal to cluster labels, like `clusterMatrix`.
* internal function .convertToNum now preserves names of input vector.
* fixed bug in plotting with merge clusters; previously if plotType="all", might not have been correctly plotted with the right internal node of the dendrogram.

Changes in version 1.2.0 ( Release date: 2017-04-04 )
==============
Expand Down
19 changes: 15 additions & 4 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ setClassUnion("matrixOrMissing",members=c("matrix", "missing"))
#' details).
#' @slot dendro_index numeric. An integer giving the cluster that was used to
#' make the dendrograms. NA_real_ value if no dendrograms are saved.
#' @slot dendro_outbranch logical. Whether the dendro_samples dendrogram put
#' missing/non-clustered samples in an outbranch, or intermixed in the dendrogram.
#' @slot coClustering matrix. A matrix with the cluster co-occurrence
#' information; this can either be based on subsampling or on co-clustering
#' across parameter sets (see \code{clusterMany}). The matrix is a square matrix
Expand Down Expand Up @@ -85,6 +87,7 @@ setClass(
dendro_samples = "dendrogramOrNULL",
dendro_clusters = "dendrogramOrNULL",
dendro_index = "numeric",
dendro_outbranch = "logical",
coClustering = "matrixOrNULL",
clusterLegend="list",
orderSamples="numeric"
Expand Down Expand Up @@ -129,32 +132,37 @@ setValidity("ClusterExperiment", function(object) {
if(NCOL(object@clusterMatrix)!= length(object@clusterInfo)) {
return("length of clusterInfo must be same as NCOL of the clusterMatrix")
}

##Check dendrograms
############
##Check dendrogram slotNames
############
#browser()
if(!is.null(object@dendro_samples)){
if(nobs(object@dendro_samples) != NCOL(object)) {
return("dendro_samples must have the same number of leaves as the number of samples")
}
if(is.na(object@dendro_outbranch)) return("if dendro_samples is defined, must also define dendro_outbranch")
}
else{
if(!is.null(object@dendro_clusters)) return("dendro_samples should not be null if dendro_clusters is non-null")
if(!is.na(object@dendro_outbranch)) return("dendro_samples should not be null if dendro_outbranch is not NA")
}
if(!is.null(object@dendro_clusters)){
if(is.na(object@dendro_index)) return("if dendrogram slots are filled, must have corresponding dendro_index defined.")
dcluster<-clusterMatrix(object)[,object@dendro_index]
if(is.na(dendroClusterIndex(object))) return("if dendrogram slots are filled, must have corresponding dendro_index defined.")
dcluster<-clusterMatrix(object)[,dendroClusterIndex(object)]
if(nobs(object@dendro_clusters) != max(dcluster)) {
return("dendro_clusters must have the same number of leaves as the number of (non-negative) clusters")
}
}
else{
if(!is.null(object@dendro_samples)) return("dendro_clusters should not be null if dendro_samples is non-null")
}
## Check co-clustering
if(!is.null(object@coClustering) &&
(NROW(object@coClustering) != NCOL(object@coClustering)
| NCOL(object@coClustering) != NCOL(object))) {
return("`coClustering` must be a sample by sample matrix.")
}
## If have a cluster matrix
if(!all(is.na(object@clusterMatrix))){ #what does this mean, how can they be all NA?
#check primary index
if(length(object@primaryIndex) != 1) {
Expand Down Expand Up @@ -331,6 +339,7 @@ setMethod(
#'@param dendro_samples dendrogram. Sets the `dendro_samples` slot (see Slots).
#'@param dendro_clusters dendrogram. Sets the `dendro_clusters` slot (see
#' Slots).
#' @param dendro_outbranch logical. Sets the `dendro_outbranch` slot (see Slots)
#'@param dendro_index numeric. Sets the dendro_index slot (see Slots).
#'@param coClustering matrix. Sets the `coClustering` slot (see Slots).
#'@details The \code{clusterExperiment} constructor function gives clusterLabels
Expand All @@ -348,6 +357,7 @@ setMethod(
dendro_samples=NULL,
dendro_index=NA_real_,
dendro_clusters=NULL,
dendro_outbranch=NA,
coClustering=NULL
){
if(NCOL(se) != nrow(clusters)) {
Expand Down Expand Up @@ -396,6 +406,7 @@ setMethod(
dendro_samples=dendro_samples,
dendro_clusters=dendro_clusters,
dendro_index=dendro_index,
dendro_outbranch=dendro_outbranch,
coClustering=coClustering
)
validObject(out)
Expand Down
21 changes: 17 additions & 4 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,20 @@ setGeneric(
standardGeneric("transformation")
}
)

setGeneric(
name = "transform",
def = function(x,...) {
standardGeneric("transform")
name = "transformation<-",
def = function(object, value) {
standardGeneric("transformation<-")
}
)
# don't need this because a standard generic already exists
# setGeneric(
# name = "transform",
# def = function(x,...) {
# standardGeneric("transform")
# }
# )
setGeneric("transform")

setGeneric(
name = "clusterMatrix",
Expand Down Expand Up @@ -228,6 +235,12 @@ setGeneric(
}
)

setGeneric(
name = "dendroClusterIndex",
def = function(x) {
standardGeneric("dendroClusterIndex")
}
)
setGeneric(
name = "coClustering",
def = function(x) {
Expand Down
29 changes: 28 additions & 1 deletion R/AllHelper.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ setMethod(
cat("Table of clusters (of primary clustering):")
print(table(primaryClusterNamed(object)))
cat("Total number of clusterings:", NCOL(clusterMatrix(object)),"\n")
if(!is.na(object@dendro_index) ) cat("Dendrogram run on '",clusterLabels(object)[object@dendro_index],"' (cluster index: ", object@dendro_index,")\n",sep="") else cat("No dendrogram present\n")
if(!is.na(dendroClusterIndex(object)) ) cat("Dendrogram run on '",clusterLabels(object)[dendroClusterIndex(object)],"' (cluster index: ", dendroClusterIndex(object),")\n",sep="") else cat("No dendrogram present\n")
cat("-----------\n")
cat("Workflow progress:\n")
typeTab<-names(table(clusterTypes(object)))
Expand Down Expand Up @@ -148,6 +148,19 @@ setMethod(
}
)

#' @rdname ClusterExperiment-methods
#' @export
#' @aliases transformation<-
setReplaceMethod(
f = "transformation",
signature = signature("ClusterExperiment", "function"),
definition = function(object, value) {
object@transformation <- value
validObject(object)
return(object)
}
)

#' @rdname ClusterExperiment-methods
#' @return \code{nClusters} returns the number of clusterings (i.e., ncol of
#' clusterMatrix).
Expand Down Expand Up @@ -252,6 +265,20 @@ setMethod(
}
)

#' @rdname ClusterExperiment-methods
#' @return \code{dendroClusterIndex} returns/sets the clustering index
#' of the clusters used to create dendrogram
#' (i.e., which column of clusterMatrix corresponds to the clustering).
#' @export
#' @aliases dendroClusterIndex
setMethod(
f = "dendroClusterIndex",
signature = "ClusterExperiment",
definition = function(x) {
return(x@dendro_index)
}
)

#' @rdname ClusterExperiment-methods
#' @export
#' @aliases primaryClusterIndex<-
Expand Down
7 changes: 5 additions & 2 deletions R/addClusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ setMethod(
newClusterColors<-clusterLegend(x)[-whichRemove]
dend_samples <- x@dendro_samples
dend_cl <- x@dendro_clusters
dend_ind<-x@dendro_index
dend_ind<-dendroClusterIndex(x)
dend_out<-x@dendro_outbranch
coMat<-x@coClustering
orderSamples<-orderSamples(x)
if(primaryClusterIndex(x) %in% whichRemove) pIndex<-1
else pIndex<-match(primaryClusterIndex(x),(1:NCOL(clusterMatrix(x)))[-whichRemove])
if(x@dendro_index %in% whichRemove){
if(dendroClusterIndex(x) %in% whichRemove){
dend_cl<-NULL
dend_samples<-NULL
dend_ind<-NA_real_
dend_out<-NA
}
else{
dend_ind<-match(dend_ind,(1:NCOL(clusterMatrix(x)))[-whichRemove])
Expand All @@ -139,6 +141,7 @@ setMethod(
dendro_samples=dend_samples,
dendro_clusters=dend_cl,
dendro_index=dend_ind,
dendro_outbranch=dend_out,
coClustering=coMat,
orderSamples=orderSamples
)
Expand Down
Loading

0 comments on commit a26d494

Please sign in to comment.