Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in labRcpp(ncol(lr)) : Index out of bounds #15

Closed
grayfall opened this issue Jun 28, 2020 · 1 comment
Closed

Error in labRcpp(ncol(lr)) : Index out of bounds #15

grayfall opened this issue Jun 28, 2020 · 1 comment

Comments

@grayfall
Copy link

Hello again. Having resolved the overflow issue (#14), I have proceeded with my work to find another bizarre bug. First of all, I'd like to reiterate that I no longer have issues with the number of features. The following code with synthetic data runs perfectly fine:

n.features <- 60000
n.samples <- 80
sample.counts <- rpois(n.features*n.samples, 1000) %>% matrix(nrow=n.samples, ncol=n.features)
phs <- propr(sample.counts, metric='phs')

Alert: Saving log-ratio transformed counts to @logratio.
Alert: Fixing permutations to active random seed.
Alert: Use '[' to index proportionality matrix.
Alert: Use 'updateCutoffs' to calculate FDR.

Now on to the new issue. It seems that propr can't handle an odd number of features. Here is an example

n.features <- 100 + 1
n.samples <- 10

sample.counts <- rpois(n.features*n.samples, 1000) %>% matrix(nrow=n.samples, ncol=n.features)
phs <- propr(sample.counts, metric='phs')

Alert: Saving log-ratio transformed counts to @logratio.
Alert: Fixing permutations to active random seed.
Error in labRcpp(ncol(lr)) : 
  Index out of bounds: [index=5000; extent=5000].

Here's the traceback

3. stop(structure(list(message = "Index out of bounds: [index=5000; extent=5000].", call = labRcpp(ncol(lr)), cppstack = NULL), class = c("Rcpp::index_out_of_bounds", "C++Error", "error", "condition")))
2. labRcpp(ncol(lr))
1. propr(sample.counts, metric = "phs")

The same thing happens with any odd number of features and never happens with an even number. To be clear, I'm running propr installed from the master branch with my PR. The PR hasn't changed any logic, so it shouldn't be at fault.

@grayfall
Copy link
Author

I take my words back. It was my PR that broke things. Reordering int llt = nfeats * (nfeats - 1) / 2; into int llt = (nfeats / 2) * (nfeats - 1); solves the overflow issue, but it introduces a problem with integer division and rounding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant