Skip to content

Commit

Permalink
BUG FIX: poolRuns() would produce an error [#112]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Jul 23, 2024
1 parent 2c45bf9 commit 99da9f8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: QDNAseq
Version: 1.41.1-9000
Version: 1.41.1-9001
Title: Quantitative DNA Sequencing for Chromosomal Aberrations
Depends: R (>= 3.1.0)
Imports:
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Version (development version)

* ...
## Bug Fixes

* `poolRuns()` would give an error "Error in colMeans2(oldphenodata,
cols = numericCols, useNames = FALSE) : Argument 'x' must be a
matrix or a vector."


# Version 1.41.1 [2024-07-20]
Expand Down
13 changes: 6 additions & 7 deletions R/poolRuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,18 @@ setMethod("poolRuns", signature=c(object="QDNAseqSignals",
totalReads <- sum(oldphenodata$total.reads)
usedReads <- sum(oldphenodata$used.reads)
numericCols <- sapply(oldphenodata, FUN=is.numeric)
oldphenodata[1, numericCols] <- colMeans2(oldphenodata, cols=numericCols, useNames=FALSE)
oldphenodata[1, !numericCols] <- apply(oldphenodata[, !numericCols,
drop=FALSE], MARGIN=2L, concatenateIfNotEqual)
oldphenodata[1, numericCols] <- apply(oldphenodata[, numericCols, drop = FALSE], MARGIN = 2L, FUN = mean)
oldphenodata[1, !numericCols] <- apply(oldphenodata[, !numericCols, drop = FALSE], MARGIN = 2L, FUN = concatenateIfNotEqual)
if ("paired.ends" %in% colnames(oldphenodata))
oldphenodata[1, "paired.ends"] <- pairedEnds
oldphenodata[1, "total.reads"] <- totalReads
oldphenodata[1, "used.reads"] <- usedReads
newphenodata <- rbind(newphenodata, oldphenodata[1, ], stringsAsFactors=FALSE)
}
rownames(newphenodata) <- newphenodata[, 1]
newphenodata <- AnnotatedDataFrame(newphenodata,
varMetadata=varMetadata(object))

rownames(newphenodata) <- newphenodata$name
metadata <- varMetadata(object)
metadata <- rbind(metadata, structure(data.frame(labelDescription = NA_character_), rownames = "total.reads"))
newphenodata <- AnnotatedDataFrame(newphenodata, varMetadata=metadata)
if (inherits(object, "QDNAseqReadCounts")) {
storage.mode(newcounts) <- "integer"
object2 <- new("QDNAseqReadCounts",
Expand Down
2 changes: 0 additions & 2 deletions tests/poolRuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ message("poolRuns(LGG150set) ...")
x_pool <- poolRuns(x, samples = sampleNames(x))
print(x_pool)

if (FALSE) {
message("poolRuns(LGG150set) - pooled ...")
## BUG #112 (https://github.com/ccagc/QDNAseq/issues/112)
x_pool <- poolRuns(x, samples = rep("pooled", times = 2L))
print(x_pool)
}

message("poolRuns(LGG150set) ... done")

0 comments on commit 99da9f8

Please sign in to comment.