Conversation
lingminhao
commented
Jun 25, 2025
- fix the bug mentioned in bambuEM error: object of type 'S4' is not subsettable bambu-singlecell-spatial#14
There was a problem hiding this comment.
Pull request overview
This PR fixes a cell clustering bug referenced in GoekeLab/bambu-singlecell-spatial#14. The fix addresses issues with how the clusters parameter is validated and processed during isoform quantification.
Changes:
- Fixed the condition at line 269 to check the class of
clustersinstead ofclusters[[i]], preventing incorrect iteration-based type checking - Uncommented
do.call(c,clusters)at line 290 to properly handle cluster assignment when there's a single quantData element
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
R/bambu.R
Outdated
| iter <- seq_len(ncol(metadata(quantData_i)$countMatrix)) # iter is integer | ||
| if(!is.null(clusters)){ | ||
| if(class(clusters[[i]])!="CompressedCharacterList"){ # !is.list(clusters) is FALSE for CompressedCharacterList | ||
| if(class(clusters)!="CompressedCharacterList"&(!is.list(clusters))){ |
There was a problem hiding this comment.
The logical operator & is the non-short-circuiting version. This means that even if the first condition is false, R will still evaluate the second condition. Using && (short-circuit AND) would be more efficient and is the standard practice for conditional statements where you want to avoid unnecessary evaluation of the second condition when the first is already false.
| if(class(clusters)!="CompressedCharacterList"&(!is.list(clusters))){ | |
| if(class(clusters)!="CompressedCharacterList" && (!is.list(clusters))){ |
29f9458 to
2e0da7d
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>