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

ADAT writer breaks with a single analyte soma_adat object #51

Closed
stufield opened this issue May 30, 2023 · 0 comments · Fixed by #52
Closed

ADAT writer breaks with a single analyte soma_adat object #51

stufield opened this issue May 30, 2023 · 0 comments · Fixed by #52
Labels
bug Something isn't working

Comments

@stufield
Copy link
Contributor

stufield commented May 30, 2023

This is likely an corner case resulting from the apply() call expecting a 2nd dimension object but returning a vector ... see drop = FALSE to [.

out <- example_data[, seq(getMeta(example_data, n = TRUE) + 1L)]
write_adat(out, "foo.adat")

Timing solution:

n <- 1:100000
m <- matrix(n, nrow = 1)
bench::mark(
  mat = apply(m, 2, sprintf, fmt = "%0.1f"),
  vec = sprintf("%0.1f", n) 
)

Thanks for reporting 🥳!

@stufield stufield added the bug Something isn't working label May 30, 2023
stufield added a commit that referenced this issue May 30, 2023
- RFU values are rounded to 1 decimal during in `write_adat()`,
  via a call to `apply()`, which expects a 2-dim object when
  replacing those values.
- a single SOMAmer `soma_adat` will break unless `drop = FALSE`
- instead of this fix, convert the entire RFU
  data frame to a matrix (which maintains original dimensions)
  and use vectorized format conversion via `sprintf()`
- in theory this should be faster because `sprintf()`
  is only called once on a long vector, rather than
  1000s of times on shorter vectors.
- fixes #51
stufield added a commit that referenced this issue May 30, 2023
- RFU values are rounded to 1 decimal during in `write_adat()`,
  via a call to `apply()`, which expects a 2-dim object when
  replacing those values.
- a single SOMAmer `soma_adat` will break unless `drop = FALSE`
- instead of this fix, convert the entire RFU
  data frame to a matrix (which maintains original dimensions)
  and use vectorized format conversion via `sprintf()`
- in theory this should be faster because `sprintf()`
  is only called once on a long vector, rather than
  1000s of times on shorter vectors.
- fixes #51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant