... | ... |
@@ -21,7 +21,9 @@ |
21 | 21 |
#' dat$predicted <- kmeans(dist(dat[,-1]),3)$cluster |
22 | 22 |
#' # evaluation |
23 | 23 |
#' evaluateClustering(dat$predicted, dat$cluster) |
24 |
-evaluateClustering <- function(x, tl){ |
|
24 |
+evaluateClustering <- function(x, tl=NULL){ |
|
25 |
+ if(is.null(tl)) tl <- attr(x,"true.labels") |
|
26 |
+ if(is.null(tl)) stop("True labels not found!") |
|
25 | 27 |
e <- match_evaluate_multiple(x, tl) |
26 | 28 |
x <- as.character(x) |
27 | 29 |
unmatched <- length(x)-sum(e$n_cells_matched) |
... | ... |
@@ -147,12 +147,14 @@ using the `dr` function.", |
147 | 147 |
dims <- max(dims,2,na.rm=TRUE) |
148 | 148 |
x <- get(clustmethod)(x, dims=dims, resolution=resolution, k=k, |
149 | 149 |
steps=steps, min.size=min.size) |
150 |
- list( x=x, intermediate_return=evaluateClustering(x,tl) ) |
|
150 |
+ attr(x, "true.labels") <- tl |
|
151 |
+ x |
|
151 | 152 |
} |
152 | 153 |
) |
153 | 154 |
|
154 | 155 |
eva <- list( doublet=NULL, filtering=NULL, normalization=evaluateNorm, |
155 |
- selection=NULL, dimreduction=evaluateDimRed , clustering=NULL ) |
|
156 |
+ selection=NULL, dimreduction=evaluateDimRed, |
|
157 |
+ clustering=evaluateClustering ) |
|
156 | 158 |
# functions to aggregate the intermediate_return of the different steps |
157 | 159 |
agg <- list( doublet=.aggregateExcludedCells, |
158 | 160 |
filtering=.aggregateExcludedCells, |