Skip to content

refineCentroids: warning in cbind if centroid is on position 1 #102

@Pascallio

Description

@Pascallio

Hi, I got a warning in cbind when I adapted the example code to have a centroid on position 1. See the code below

ints <- c(13, 8, 12, 7, 4, 9, 15, 16, 11, 8, 3, 2, 3, 9, 12, 14, 13, 8, 3) 
mzs <- seq_along(ints) 
pidx <- as.integer(c(1, 3, 8, 16))

MsCoreUtils::refineCentroids(mzs, ints, pidx, k = 3L, descending = TRUE, threshold = .33)

Results in:

[1]  1.380952  2.568182  7.898305 15.982143 
Warning message: In cbind(...) :   number of rows of result is not a multiple of vector length (arg 1)

It does produce the correct weighted mass for the centroid on position 1, but does not for the 2nd centroid. Changing the ints variable and pidx (without a centroid on position 1) back to the example code gives a different (correct) weighted mass.

ints <- c(5, 8, 12, 7, 4, 9, 15, 16, 11, 8, 3, 2, 3, 9, 12, 14, 13, 8, 3)
pidx <- as.integer(c(3, 8, 16))
MsCoreUtils::refineCentroids(mzs, ints, pidx, k = 3L, descending = TRUE, threshold = .33)

[1]  2.916667  7.898305 15.982143

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions