Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop bind generics #62

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tidyseurat
Title: Brings Seurat to the Tidyverse
Version: 0.6.0
Version: 0.6.1
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
role = c("aut", "cre")),
person("Maria", "Doyle", email = "[email protected]",
Expand Down Expand Up @@ -34,7 +34,6 @@ Imports:
stringr,
cli,
fansi,
pkgconfig,
Matrix
Suggests:
testthat,
Expand Down
7 changes: 4 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ S3method(add_count,Seurat)
S3method(arrange,Seurat)
S3method(as_tibble,Seurat)
S3method(bind_cols,Seurat)
S3method(bind_cols,default)
S3method(bind_rows,Seurat)
S3method(bind_rows,default)
S3method(count,Seurat)
S3method(distinct,Seurat)
S3method(extract,Seurat)
Expand Down Expand Up @@ -41,11 +39,11 @@ S3method(tidy,Seurat)
S3method(unite,Seurat)
S3method(unnest,tidyseurat_nested)
export("%>%")
export()
export(add_count)
export(aggregate_cells)
export(arrange)
export(as_tibble)
export(bind_cols)
export(bind_rows)
export(count)
export(distinct)
Expand Down Expand Up @@ -93,6 +91,7 @@ importFrom(dplyr,arrange)
importFrom(dplyr,count)
importFrom(dplyr,distinct)
importFrom(dplyr,distinct_at)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
Expand Down Expand Up @@ -161,6 +160,8 @@ importFrom(tidyr,spread)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(ttservice,aggregate_cells)
importFrom(ttservice,bind_cols)
importFrom(ttservice,bind_rows)
importFrom(ttservice,join_features)
importFrom(utils,packageDescription)
importFrom(utils,tail)
Expand Down
40 changes: 9 additions & 31 deletions R/dplyr_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ arrange.Seurat <- function(.data, ..., .by_group = FALSE) {
}



#' Efficiently bind multiple data frames by row and column
#'
#' This is an efficient implementation of the common pattern of
Expand Down Expand Up @@ -96,6 +95,8 @@ arrange.Seurat <- function(.data, ..., .by_group = FALSE) {
#' used instead.
#' @param add.cell.ids from Seurat 3.0 A character vector of length(x = c(x, y)). Appends the corresponding values to the start of each objects' cell names.
#'
#' @importFrom ttservice bind_rows
#'
#' @return `bind_rows()` and `bind_cols()` return the same type as
#' the first input, either a data frame, `tbl_df`, or `grouped_df`.
#' @examples
Expand All @@ -106,25 +107,10 @@ arrange.Seurat <- function(.data, ..., .by_group = FALSE) {
#' tt_bind = tt %>% select(nCount_RNA ,nFeature_RNA)
#' tt %>% bind_cols(tt_bind)
#'
#' @name bind
NULL


#' @rdname dplyr-methods
#'
#' @inheritParams bind
#'
#' @export
#'
bind_rows <- function(..., .id = NULL, add.cell.ids = NULL) {
UseMethod("bind_rows")
}

#' @export
bind_rows.default <- function(..., .id = NULL, add.cell.ids = NULL)
{
dplyr::bind_rows(..., .id = .id)
}
#'
#' @name bind_rows
NULL

#' @importFrom rlang dots_values
#' @importFrom rlang flatten_if
Expand Down Expand Up @@ -154,26 +140,19 @@ bind_cols_ = function(..., .id = NULL){

tts = flatten_if(dots_values(...), is_spliced)

tts[[1]]@meta.data = dplyr::bind_cols( tts[[1]][[]], tts[[2]], .id = .id)
tts[[1]]@meta.data = bind_cols( tts[[1]][[]], tts[[2]], .id = .id)

tts[[1]]

}

#' @export
#'
#' @inheritParams bind
#' @importFrom ttservice bind_cols
#' @inheritParams bind_cols
#'
#' @rdname dplyr-methods
bind_cols <- function(..., .id = NULL) {
UseMethod("bind_cols")
}

#' @export
bind_cols.default <- function(..., .id = NULL)
{
dplyr::bind_cols(..., .id = .id)
}
NULL

#' @importFrom rlang dots_values
#' @importFrom rlang flatten_if
Expand All @@ -183,7 +162,6 @@ bind_cols.default <- function(..., .id = NULL)
#'
bind_cols.Seurat <- bind_cols_


#' distinct
#'
#' @importFrom dplyr distinct
Expand Down
6 changes: 6 additions & 0 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ NULL

#' aggregate_cells
#'
#' @importFrom dplyr everything
#'
#' @docType methods
#' @rdname aggregate_cells
#'
Expand All @@ -176,6 +178,10 @@ setMethod("aggregate_cells", "Seurat", function(.data,
slot = "data",
assays = NULL,
aggregation_function = Matrix::rowSums){
# Solve NOTE
data = NULL
.feature = NULL


.sample = enquo(.sample)

Expand Down
2 changes: 1 addition & 1 deletion R/tibble_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ NULL
#'
as_tibble.Seurat = function(x, ...,
.name_repair = c("check_unique", "unique", "universal", "minimal"),
rownames = pkgconfig::get_config("tibble::rownames", NULL)){
rownames = NULL){
x[[]] %>%
tibble::as_tibble(rownames=c_(x)$name) %>%

Expand Down
4 changes: 2 additions & 2 deletions man/bind.Rd → man/bind_rows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 2 additions & 20 deletions man/dplyr-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.