Skip to content

refineCentroids: Error: subscript out of bounds if the only centroid is on position 1 #103

@Pascallio

Description

@Pascallio

Hi, this issue may be related to issue #102 but since the results are different, I thought a separate issue might be more appropriate.

If I adapt the example code for the pidx to only have a centroid on position 1 an error occurs:

ints <- c(12, 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(1)

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

Gives:

Error in v[, "left"] : subscript out of bounds

This does not occur if the centroid is on any other position or if more than 1 centroid is defined.
It also does not throw an error if descending = FALSE.

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