Fix subsetLiger removing cell.data and reporting 0 cells when no clustering available. #231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dear rliger team,
The current implementation of subsetLiger() deletes everything in the cell.data slot when subsetting a liger object that has no data in the clusters slot.
This is because of the following line:
liger/R/rliger.R
Line 6510 in 89b2443
Here, the cell.data slot is subsetted by the names of a@cluster, which is of course empty if subsetLiger() is called before clustering.
It also causes the show method to report "0 total cells" for the subset.
This error can be very frustrating, as there are also no warnings.
It can be fixed by getting the cell names for the subsetting of the cell data e.g. from the raw.data slot. As in:
I think should be a very small and easy change. This was already present in liger 0.5.0, and I had created a pull request also then. I've created this new pull request for the current version of rliger to make it easier to merge.
Best regards and thanks for the great package!
Nils