This file is indexed.

/usr/lib/R/site-library/Biobase/UnitTests/ExpressionSet_test.R is in r-bioc-biobase 2.14.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
testCombineFeatureData <- function() {
    data(sample.ExpressionSet)          # use as source for exprs data
    suppressWarnings(obj <- updateObject(sample.ExpressionSet)[1:20,1:10])

    obj1 <- new("ExpressionSet", phenoData=phenoData(obj), exprs=exprs(obj))
    obj2 <- obj1

    pData(featureData(obj1))[["x"]] <- FALSE
    pData(featureData(obj1))[["y"]] <- FALSE
    varMetadata(featureData(obj1)) <-
      data.frame(labelDescription=c("the x", "the y"), row.names=c("x", "y"))
    validObject(obj1)

    sampleNames(obj2) <- letters[1:dim(obj1)[[2]]]
    pData(featureData(obj2))[["y"]] <- FALSE
    pData(featureData(obj2))[["z"]] <- TRUE
    varMetadata(featureData(obj2)) <-
        data.frame(labelDescription=c("the y", "the z"), row.names=c("y", "z"))
    validObject(obj2)
    obj <- combine(obj1,obj2)
    checkTrue(all(varLabels(featureData(obj1)) %in% varLabels(featureData(obj))))
    checkTrue(all(varLabels(featureData(obj2)) %in% varLabels(featureData(obj))))

    ## conflicting feature pData
    pData(featureData(obj2))[["y"]] <- TRUE
    validObject(obj2)
    checkException(suppressWarnings(combine(obj1, obj2)), silent=TRUE)
}

testCombineRows <- function() {
    data(sample.ExpressionSet)
    obj <- sample.ExpressionSet

    checkEquals(obj, combine(obj[1:250,], obj[251:500,]))
    checkEquals(obj, combine(obj[,1:13], obj[,14:26]))
    ## overlapping
    checkEquals(obj, combine(obj[1:300,], obj[250:500,]))
    checkEquals(obj, combine(obj[,1:20], obj[,15:26]))
}

testAddTextNotes <- function() {
    eset <- new("ExpressionSet")
    notes(eset) <- "a note"
    checkTrue(identical(notes(eset), list("a note")))
    notes(eset) <- "another"
    checkTrue(identical(notes(eset), list("a note", "another")))
}

testExtraSlotExpressionClassInitialize1 <- function() {
    setClass("ExtraSlotExpressionSet", contains="ExpressionSet",
             representation=representation(
               extraSlot="character"),
             where=.GlobalEnv)
    ## pass if no error
    checkTrue(validObject(new("ExtraSlotExpressionSet")))
    removeClass("ExtraSlotExpressionSet", where=.GlobalEnv)
}

testExtraSlotExpressionClassInitialize2 <- function() {
    setClass("ExtraSlotExpressionSet", contains="ExpressionSet",
             representation=representation(
               extraSlot="character"),
             where=.GlobalEnv)
    e <- new("ExtraSlotExpressionSet",
             exprs=new("matrix"),
             extraSlot="hello",
             storage.mode="environment")
    checkEquals("hello", e@extraSlot)
    checkEquals("exprs", ls(assayData(e)))
    checkEquals("environment", storageMode(e))
    removeClass("ExtraSlotExpressionSet", where=.GlobalEnv)
}

testExtraSlotExpressionClassInitialize3 <- function() {
    setClass("ExtraSlotExpressionSet", contains="ExpressionSet",
             representation=representation(
               extraSlot="character"),
             where=.GlobalEnv)
    e <- new("ExtraSlotExpressionSet",
             assayData=assayDataNew(
               exprs=new("matrix"),
               storage.mode="environment"),
             extraSlot="hello")
    checkEquals("hello", e@extraSlot)
    checkEquals("exprs", ls(assayData(e)))
    checkEquals("environment", storageMode(e))
    removeClass("ExtraSlotExpressionSet", where=.GlobalEnv)
}

testDollar <- function() {
    data(sample.ExpressionSet)
    s1 <- sample.ExpressionSet$sex
    s2 <- sample.ExpressionSet$se       # we expect partial matching to work
    checkTrue(!is.null(s1), msg="$sex broken")
    checkTrue(!is.null(s2), msg="$se broken (pmatch)")
    checkEquals(s1, s2, msg="pmatch equality")
}

testSubset2 <- function() {
    data(sample.ExpressionSet)
    es <- sample.ExpressionSet
    x <- runif(ncol(es))
    ldesc <- "Random variate"
    es[["RVar", labelDescription=ldesc]] <- x
    checkEquals(es[["RVar"]], x)
    checkEquals(varMetadata(es)["RVar", "labelDescription"], ldesc)
}

testHarmonizeAssayDataDimnames <- function() {
    checkHarmonizeOne <- function(exprs) {
        es <- new("ExpressionSet", exprs=exprs)
        checkTrue(validObject(es))
    }
    checkHarmonizeTwo <- function (exprs, se.exprs) {
        es <- new("ExpressionSet", exprs=exprs, se.exprs=se.exprs)
        checkTrue(validObject(es))
        okNames <- list(featureNames(featureData(es)),
                        sampleNames(phenoData(es)))
        dimNames <- Biobase:::.assayDataDimnames(assayData(es))
        checkTrue(all(sapply(dimNames, identical, okNames)))
    }
    checkCreation <- function(exprs, se.exprs) {
        checkHarmonizeOne(exprs)
        checkHarmonizeTwo(exprs, se.exprs)

        ## names on both dimnames
        nexprs <- exprs
        dimnames(nexprs) <-
            lapply(dimnames(nexprs), function(x) {
            names(x) <- as.vector(letters[seq(1, length(x))])
            x
        })        
        checkHarmonizeOne(nexprs)
        checkHarmonizeTwo(nexprs, se.exprs)

        ## names on colnames
        nexprs <- exprs
        cnms <- colnames(nexprs)
        names(cnms) <- letters[seq(1, length(cnms))]
        colnames(nexprs) <- cnms
        checkHarmonizeOne(nexprs)
        checkHarmonizeTwo(nexprs, se.exprs)

        ## names on rownames
        nexprs <- exprs
        rnms <- rownames(nexprs)
        names(rnms) <- letters[seq(1, length(rnms))]
        rownames(nexprs) <- rnms
        checkHarmonizeOne(nexprs)
        checkHarmonizeTwo(nexprs, se.exprs)
    }

    se.exprs <- matrix(0, 5, 2)
    exprs <- matrix(0, 5, 2)
    dimnames(exprs) <- list(LETTERS[1:5], letters[1:2])

    dimnames(se.exprs) <- NULL
    checkCreation(exprs, se.exprs)

    dimnames(se.exprs) <- list(LETTERS[1:5], NULL)
    checkCreation(exprs, se.exprs)

    dimnames(se.exprs) <- list(NULL, letters[1:2])
    checkCreation(exprs, se.exprs)

    ## errors
    dimnames(se.exprs) <- list(letters[1:5], letters[1:2])
    checkException(checkCreation(exprs, se.exprs), silent=TRUE)

    dimnames(se.exprs) <- list(LETTERS[1:5], LETTERS[1:2])
    checkException(checkCreation(exprs, se.exprs), silent=TRUE)

    dimnames(se.exprs) <- list(letters[1:5], LETTERS[1:2])
    checkException(checkCreation(exprs, se.exprs), silent=TRUE)
}