Skip to content

Commit

Permalink
fix as.vector() - closes issue #203
Browse files Browse the repository at this point in the history
  • Loading branch information
lgatto committed Mar 26, 2024
1 parent 21f74a8 commit c703655
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: QFeatures
Title: Quantitative features for mass spectrometry data
Version: 1.13.2
Version: 1.13.3
Authors@R: c(person("Laurent", "Gatto",
email = "[email protected]",
comment = c(ORCID = "0000-0002-1520-2268"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# QFeatures 1.13

## QFeatures 1.13.3

- Fix `is.vector()` (see issue #203)

## QFeatures 1.13.2

- Move the `filterFeatures` generic method to `ProtGenerics`.
Expand Down
12 changes: 6 additions & 6 deletions R/QFeatures-aggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ setMethod("aggregateFeatures", "SummarizedExperiment",
if (!fcol %in% names(rd))
stop("'fcol' not found in the assay's rowData.")
groupBy <- rd[[fcol]]

## Store class of assay i in case it is not a SummarizedExperiment
## so that the aggregated assay can be reverted to that class
.class <- class(object)

## Message about NA values is quant/row data
has_na <- character()
if (anyNA(m))
Expand All @@ -326,8 +326,8 @@ setMethod("aggregateFeatures", "SummarizedExperiment",
"effects of missing values on data aggregation.")
message(paste(strwrap(msg), collapse = "\n"))
}
if (is.vector(groupBy)) {

if (is.vector(groupBy) & !is.list(groupBy)) { ## atomic vectors
aggregated_assay <- aggregate_by_vector(m, groupBy, fun, ...)
aggcount_assay <- aggregate_by_vector(m, groupBy, colCounts)
aggregated_rowdata <- QFeatures::reduceDataFrame(rd, rd[[fcol]],
Expand All @@ -348,14 +348,14 @@ setMethod("aggregateFeatures", "SummarizedExperiment",
## Count the number of peptides per protein
.n <- apply(groupBy != 0, 2, sum)
aggregated_rowdata[[".n"]] <- .n[rownames(aggregated_rowdata)]

assays <- SimpleList(assay = as.matrix(aggregated_assay)) ## to discuss
rowdata <- aggregated_rowdata[rownames(aggregated_assay), , drop = FALSE]
} else stop("'fcol' must refer to a vector or a sparse matrix.")
se <- SummarizedExperiment(assays = assays,
colData = colData(object),
rowData = rowdata)

## If the input objects weren't SummarizedExperiments, then try to
## convert the merged assay into that class. If the conversion
## fails, keep the SummarizedExperiment, otherwise use the
Expand Down

0 comments on commit c703655

Please sign in to comment.