Browse code

- Accessors for metadata columns changed to be robust in situtations when the column doesn't exist by using $column rather than [, "column"] access style.

Dario Strbenac authored on 12/09/2022 05:00:05
Showing 7 changed files

... ...
@@ -3,8 +3,8 @@ Type: Package
3 3
 Title: A framework for cross-validated classification problems, with
4 4
        applications to differential variability and differential
5 5
        distribution testing
6
-Version: 3.1.15
7
-Date: 2022-08-31
6
+Version: 3.1.16
7
+Date: 2022-09-12
8 8
 Author: Dario Strbenac, Ellis Patrick, John Ormerod, Graham Mann, Jean Yang
9 9
 Maintainer: Dario Strbenac <dario.strbenac@sydney.edu.au>
10 10
 VignetteBuilder: knitr
... ...
@@ -102,7 +102,7 @@ setMethod("crossValidate", "DataFrame",
102 102
               outcome <- measurementsAndOutcome[["outcome"]]
103 103
               
104 104
               # Which data-types or data-views are present?
105
-              assayIDs <- unique(mcols(measurements)[, "assay"])
105
+              assayIDs <- unique(mcols(measurements)$assay)
106 106
               if(is.null(assayIDs)) assayIDs <- 1
107 107
               
108 108
               checkData(measurements, outcome)
... ...
@@ -450,7 +450,7 @@ setMethod("crossValidate", "list",
450 450
 ######################################
451 451
 cleanNFeatures <- function(nFeatures, measurements){
452 452
     #### Clean up
453
-    if(!is.null(mcols(measurements)))
453
+    if(!is.null(mcols(measurements)$assay))
454 454
       obsFeatures <- unlist(as.list(table(mcols(measurements)[, "assay"])))
455 455
     else obsFeatures <- ncol(measurements)
456 456
     if(is.null(nFeatures) || length(nFeatures) == 1 && nFeatures == "all") nFeatures <- as.list(obsFeatures)
... ...
@@ -467,7 +467,7 @@ cleanNFeatures <- function(nFeatures, measurements){
467 467
 ######################################
468 468
 cleanSelectionMethod <- function(selectionMethod, measurements){
469 469
     #### Clean up
470
-    if(!is.null(mcols(measurements)))
470
+    if(!is.null(mcols(measurements)$assay))
471 471
       obsFeatures <- unlist(as.list(table(mcols(measurements)[, "assay"])))
472 472
     else return(list(selectionMethod))
473 473
 
... ...
@@ -483,7 +483,7 @@ cleanSelectionMethod <- function(selectionMethod, measurements){
483 483
 ######################################
484 484
 cleanClassifier <- function(classifier, measurements){
485 485
     #### Clean up
486
-    if(!is.null(mcols(measurements)))
486
+    if(!is.null(mcols(measurements)$assay))
487 487
       obsFeatures <- unlist(as.list(table(mcols(measurements)[, "assay"])))
488 488
     else return(list(classifier))
489 489
 
... ...
@@ -55,9 +55,9 @@ setMethod("prepareData", "DataFrame",
55 55
     measurements <- measurements[, useFeatures]
56 56
 
57 57
   # Won't ever be true if input data was MultiAssayExperiment because wideFormat already produces valid names.  
58
-  if(!all.equal(colnames(measurements), make.names(colnames(measurements))))
58
+  if(all.equal(colnames(measurements), make.names(colnames(measurements))) != TRUE)
59 59
   {
60
-    mcols(measurements)[, "feature"] <- colnames(measurements) # Save the originals.
60
+    mcols(measurements)$feature <- colnames(measurements) # Save the originals.
61 61
     colnames(measurements) <- make.names(colnames(measurements)) # Ensure column names are safe names.
62 62
   }
63 63
       
... ...
@@ -272,7 +272,7 @@ input data. Autmomatically reducing to smaller number.")
272 272
   {
273 273
     if(!is.null(rankedFeaturesIndices))
274 274
     {
275
-      if(is.null(S4Vectors::mcols(measurementsTrain)))
275
+      if(is.null(S4Vectors::mcols(measurementsTrain)) || !"assay" %in% colnames(S4Vectors::mcols(measurementsTrain)))
276 276
       {
277 277
         rankedFeatures <- originalFeatures[rankedFeaturesIndices]
278 278
       } else {
... ...
@@ -282,7 +282,8 @@ input data. Autmomatically reducing to smaller number.")
282 282
     } else { rankedFeatures <- NULL}
283 283
     if(!is.null(selectedFeaturesIndices))
284 284
     {
285
-      if(is.null(S4Vectors::mcols(measurementsTrain))){
285
+      if(is.null(S4Vectors::mcols(measurementsTrain)) || !"assay" %in% colnames(S4Vectors::mcols(measurementsTrain)))
286
+      {
286 287
         selectedFeatures <- originalFeatures[selectedFeaturesIndices]
287 288
       } else {
288 289
         featureColumns <- na.omit(match(c("assay", "feature"), colnames(S4Vectors::mcols(measurementsTrain))))  
... ...
@@ -78,7 +78,8 @@ setMethod("runTests", "DataFrame", function(measurements, outcome, crossValParam
78 78
     stop("Some data elements are missing and classifiers don't work with missing data. Consider imputation or filtering.")            
79 79
 
80 80
   originalFeatures <- colnames(measurements)
81
-  if("feature" %in% colnames(S4Vectors::mcols(measurements))) originalFeatures <- S4Vectors::mcols(measurements)[, c("assay", "feature")]                 
81
+  if("assay" %in% colnames(S4Vectors::mcols(measurements)))
82
+      originalFeatures <- S4Vectors::mcols(measurements)[, c("assay", "feature")]                 
82 83
   splitDataset <- prepareData(measurements, outcome, ...)
83 84
   measurements <- splitDataset[["measurements"]]
84 85
   outcome <- splitDataset[["outcome"]]
... ...
@@ -17,7 +17,7 @@
17 17
 #' design to compare. Can be any characteristic that all results share.
18 18
 #' @param metric Default: "Sample Error". The sample-wise metric to plot.
19 19
 #' @param featureValues If not NULL, can be a named factor or named numeric
20
-#' vector specifying some variable of interest to plot underneath the above the
20
+#' vector specifying some variable of interest to plot above the
21 21
 #' heatmap.
22 22
 #' @param featureName A label describing the information in
23 23
 #' \code{featureValues}. It must be specified if \code{featureValues} is.
... ...
@@ -40,7 +40,9 @@ elasticNetGLMparams <- function() {
40 40
 
41 41
 # Support Vector Machine
42 42
 SVMparams = function() {
43
-    trainParams <- TrainParams(SVMtrainInterface, tuneParams = list(kernel = c("linear", "polynomial", "radial", "sigmoid"), cost = 10^(-3:3), performanceType = "Balanced Error"))
43
+    trainParams <- TrainParams(SVMtrainInterface,
44
+                   tuneParams = list(kernel = c("linear", "polynomial", "radial", "sigmoid"),
45
+                                     cost = 10^(-3:3), performanceType = "Balanced Error"))
44 46
     predictParams <- PredictParams(SVMpredictInterface)
45 47
     
46 48
     return(list(trainParams = trainParams, predictParams = predictParams))