stemangiola / tidySingleCellExperiment

Brings SingleCellExperiment objects to the tidyverse
https://stemangiola.github.io/tidySingleCellExperiment/index.html
35 stars 10 forks source link

Add slice functions #90

Closed noriakis closed 1 year ago

noriakis commented 1 year ago

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

noriakis commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.