Improve obs_to_matrix with data.table#210
Improve obs_to_matrix with data.table#210andrewrech wants to merge 12 commits intopachterlab:develfrom andrewrech:master
Conversation
Emergency patch to fix #190
Replace reshape2::dcast with data.table::dcadt for speed gain and to avoid issue with long sample names causing vector return error in reshape2 but not data.table: Using reshape2: ``` obs_counts <- dcast(obj$obs_norm, target_id ~ sample, value.var = value_name) Aggregation function missing: defaulting to length Error during wrapup: dims [product 868328] do not match the length of object [41674225] ``` But no error using data.table. [`obj_norm`](https://s3.amazonaws.com/rech-ul/obj_norm.RDS?AWSAccessKeyId=AKIAI6SXE4VOIPIZJI6Q&Expires=1601162547&Signature=3lPIt6yZ2UPFhMioUwwRopzo8eM%3D) to reproduce:
|
Additionally fixed use of data.table::dcast on data.frame (this function does not implicitly convert) |
|
Hi @andrewrech, Thank you for your work here! Two suggestions:
In both cases, you can run |
|
Also, I've switched to the |
For d05cd9b ed95e7
If `tabd_df` is not a data table, it is converted. Don't need `as.data.table`.
|
@warrenmcg Thank you for your help
data.table::dcast(test_df, time ~ variable, fun=mean) %>% str
|
warrenmcg
left a comment
There was a problem hiding this comment.
Changing reshape2::dcast to data.table::dcast means that tabd_df is now a data.table object rather than a data.frame. I think it would be best if there was a line after the if statements to convert tabd_df to a data.frame (at line 1049, for example).
|
@warrenmcg see my note above |
|
Hi @andrewrech, you are correct. Sorry about that! We will be reviewing everything next week to merge and hopefully have a new release soon! Thanks again for your help and effort! 👍 |
Replace reshape2::dcast with data.table::dcast for speed gain and to avoid issue with long sample names causing vector return error in reshape2 but not data.table:
Using reshape2:
But no error using data.table.
obj_norm to reproduce
Linux i-094bb338984186ac0 4.15.0-1031-aws #33-Ubuntu SMP Fri Dec 7 09:32:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux