Skip to content

Feature/r6 class#24

Merged
Arshammik merged 11 commits intomainfrom
feature/r6-class
Nov 19, 2025
Merged

Feature/r6 class#24
Arshammik merged 11 commits intomainfrom
feature/r6-class

Conversation

@Arshammik
Copy link
Collaborator

No description provided.

- Implement SplikitObject R6 class with public fields (m1, m2, eventData, geneExpression, metadata)
- Add methods: initialize, makeM2, findVariableEvents, findVariableGenes, getPseudoCorrelation
- Add utility methods: subset, setGeneExpression, annotateEvents, summary, print, clone
- Include comprehensive input validation in private methods
- Add standardized error handling with informative messages
- Add R6 to DESCRIPTION Imports
- Update package description to mention R6 interface
- Test initialization from matrices and junction_ab
- Test dimension validation and error handling
- Test makeM2 produces identical results to make_m2 function
- Test findVariableEvents produces identical results
- Test subset, summary, print methods
- Test deepCopy creates independent copies
- Test metadata storage
- Test backward compatibility with existing functions
- Rename clone to deepCopy (clone is reserved in R6)

All 39 tests pass
- find_variable_events() now accepts SplikitObject as first argument
- get_pseudo_correlation() now accepts SplikitObject as first argument
- Both functions extract m1/m2 automatically from SplikitObject
- Maintain full backward compatibility with existing signatures
- Fix pipe operator for R 3.5.0 compatibility in get_silhouette_mean example
- Implement make_m2_cpp and make_m2_cpp_parallel in C++
- Uses column-wise parallel processing for sparse matrix efficiency
- Add use_cpp and n_threads parameters to make_m2 R function
- Default to C++ implementation (use_cpp = TRUE)
- Produces IDENTICAL results to R implementation
- 1.18x speedup with single thread on test data (25k events x 7.5k cells)
- OpenMP parallelization available for multi-threaded execution
- Add R6 library to requirements
- Document SplikitObject R6 class interface as recommended approach
- Show traditional function interface for backward compatibility
- Highlight key features: C++ backend, sparse matrices, validation
- Add n_threads parameter examples for parallel processing
Fixes and improvements:
- Add edge case tests from deep analysis (Issue #1)
- Add integer matrix support to rowVariance_cpp (Issue #16)
- Add empty result check to find_variable_events (Issue #23)
- Add n_threads and use_cpp params to SplikitObject$makeM2
- Add integration tests for full R6 pipeline
- Add tests for subset operations and parameter validation

C++ messaging cleanup:
- Remove all debug Rcout messages from C++ functions
- Remove atomic includes no longer needed
- Let R wrappers control verbosity via verbose parameter
- Cleaner output that respects user preferences

Test coverage expanded from 39 to 80 tests.
Major rewrite of make_m2_cpp for minimal memory usage:
- Build CSC format directly instead of triplet intermediate
- Two-pass algorithm: count then fill
- O(n_groups) workspace per column instead of dense group_sums matrix
- Eliminated 720MB+ memory spike for typical datasets

Memory improvement:
- Before: O(n_groups * n_cells) + O(6 * nnz_output)
- After: O(nnz_output) + O(n_groups) workspace

Performance improvement:
- 8.6x faster (1.0s vs 8.8s for test dataset)
- All 80 tests pass in 47s (vs 275s previously)

Results are IDENTICAL to previous implementation.
- Add R6 Object-Oriented Interface section to vignette
- Update make_m2 docs with n_threads, use_cpp, performance notes
- Add SplikitObject to pkgdown reference index
- Update version to 2.0.0
- Regenerate Rd documentation files
- Add eventdata to toy_m1_m2_obj.rds test data
- Update test expectations for correct data dimensions
- Fix non-ASCII characters in R/zzz.R
- Add missing NAMESPACE imports (methods, stats)
- Add NSE variable declaration for data.table
- Fix long example lines in documentation
- Simplify internal function documentation

Package now passes R CMD check --as-cran with 0 errors, 0 warnings, and 4 acceptable notes.
@Arshammik Arshammik self-assigned this Nov 19, 2025
@Arshammik Arshammik added the enhancement New feature or request label Nov 19, 2025
@Arshammik Arshammik merged commit 5dd8aef into main Nov 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant