Skip to content

Conversation

@noriakis
Copy link
Contributor

Hello, I added the following functions to dplyr_methods.R. I would be grateful if you could review the changes.

  • slice_head()
  • slice_tail()
  • slice_sample()
  • slice_min()
  • slice_max()

Comment on lines 584 to 587
stop("tidySingleCellExperiment says:",
" the resulting data container is empty.",
" Seurat does not allow for empty containers.")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for "Seurat" in all files, and please replace ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe an empty SCE is completely fine. Not sure this check is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your prompt review. I apologize that the part of the message remained the same as tidyseurat. Also, to accept the empty SCE, all the checks for zero length ID in the slice functions are removed.

@stemangiola stemangiola added the enhancement New feature or request label Aug 30, 2023
Copy link
Collaborator

@stemangiola stemangiola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can I please ask to add the 0-length SCE to the uni tests? As we start with our standard SCE and we slice to result to 0 rows, and see what happens (within the unit tests)

@noriakis
Copy link
Contributor Author

Thank you for the guidance. I have added the tests to expect ncol()=0. All the functions run without error or warnings, except for slice_sample producing the following warning.

> pbmc_small |> slice_sample(n=0)
# A SingleCellExperiment-tibble abstraction: 0 × 17
# Features=230 | Cells=0 | Assays=counts, logcounts
# ℹ 17 variables: .cell <chr>, orig.ident <fct>, nCount_RNA <dbl>, nFeature_RNA <int>, RNA_snn_res.0.8 <fct>,
#   letter.idents <fct>, groups <chr>, RNA_snn_res.1 <fct>, file <chr>, ident <fct>, PC_1 <dbl>, PC_2 <dbl>,
#   PC_3 <dbl>, PC_4 <dbl>, PC_5 <dbl>, tSNE_1 <dbl>, tSNE_2 <dbl>
Warning message:
In max(count_cells$n) : no non-missing arguments to max; returning -Inf

@stemangiola
Copy link
Collaborator

Thank you for the guidance. I have added the tests to expect ncol()=0. All the functions run without error or warnings, except for slice_sample producing the following warning.

> pbmc_small |> slice_sample(n=0)
# A SingleCellExperiment-tibble abstraction: 0 × 17
# Features=230 | Cells=0 | Assays=counts, logcounts
# ℹ 17 variables: .cell <chr>, orig.ident <fct>, nCount_RNA <dbl>, nFeature_RNA <int>, RNA_snn_res.0.8 <fct>,
#   letter.idents <fct>, groups <chr>, RNA_snn_res.1 <fct>, file <chr>, ident <fct>, PC_1 <dbl>, PC_2 <dbl>,
#   PC_3 <dbl>, PC_4 <dbl>, PC_5 <dbl>, tSNE_1 <dbl>, tSNE_2 <dbl>
Warning message:
In max(count_cells$n) : no non-missing arguments to max; returning -Inf

Great. If this warning comes from tidySingleCellExperiment we should take care of it.

@noriakis
Copy link
Contributor Author

Thank you for the review. I have committed the changes to overcome the warning in slice_sample.
I would be grateful if you could review the relevant part.

Comment on lines 549 to 552
.max_cell_count <- ifelse(nrow(count_cells)==0, 0, max(count_cells$n))

# If repeated cells due to replacement
if (count_cells$n |> max() |> gt(1)){
if (.max_cell_count |> gt(1)){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, does the warning appear in tidyseurat as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for checking. Seems to be yes, although it results in an error. Should I also replace the part for tidyseurat?

> pbmc_small |> slice_sample(n=0)
Error: No cells found
In addition: Warning message:
In max(count_cells$n) : no non-missing arguments to max; returning -Inf

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noriakis Yes, please fix the error in tidyseurat and write a unit test for it.

If this is relative to an empty object I thought you had a stop() call already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your reply. The error is related to an empty object coming from stop() call in subset.Seurat() as you pointed out, so I will just fix the warnings.

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.

2 participants