Skip to content

Commit 5a96f95

Browse files
authored
Merge pull request #92 from stemangiola/fix-drop-argument-deprecation-dplyr
Fix drop argument deprecation dplyr
2 parents 20c2332 + 78794a2 commit 5a96f95

File tree

11 files changed

+241
-107
lines changed

11 files changed

+241
-107
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ dev/dplyr-master/*
1616
tidyseurat.Rproj
1717
/doc/
1818
/Meta/
19+
..Rcheck/*

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: tidyseurat
33
Title: Brings Seurat to the Tidyverse
4-
Version: 0.8.8
4+
Version: 0.8.9
55
Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com",
66
role = c("aut", "cre")),
77
person("Maria", "Doyle", email = "Maria.Doyle@petermac.org",

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ importFrom(Seurat,SplitObject)
6161
importFrom(Seurat,VariableFeatures)
6262
importFrom(SeuratObject,"DefaultAssay<-")
6363
importFrom(SeuratObject,DefaultAssay)
64-
importFrom(dplyr,add_count)
6564
importFrom(dplyr,arrange)
6665
importFrom(dplyr,contains)
6766
importFrom(dplyr,count)
@@ -129,6 +128,7 @@ importFrom(rlang,is_spliced)
129128
importFrom(rlang,names2)
130129
importFrom(rlang,quo_name)
131130
importFrom(rlang,quo_squash)
131+
importFrom(rlang,sym)
132132
importFrom(stats,setNames)
133133
importFrom(stringr,regex)
134134
importFrom(stringr,str_detect)

R/dplyr_methods.R

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -952,27 +952,36 @@ add_count <- function(x, ..., wt=NULL, sort=FALSE, name=NULL) {
952952
#' @export
953953
#' @rdname count
954954
add_count.default <- function(x, ..., wt=NULL, sort=FALSE, name=NULL) {
955-
dplyr::add_count(x=x, ..., wt=!!enquo(wt), sort=sort, name=name)
955+
if (is.null(name)) name <- "n"
956+
.out <- x %>%
957+
dplyr::group_by(..., .add = TRUE) %>%
958+
dplyr::mutate(!!rlang::sym(name) := if (is.null(wt)) dplyr::n() else sum(!!enquo(wt), na.rm = TRUE)) %>%
959+
dplyr::ungroup()
960+
if (sort) .out <- dplyr::arrange(.out, dplyr::desc(!!rlang::sym(name)))
961+
.out
956962
}
957963

958964
#' @rdname count
959965
#' @aliases add_count
960-
#' @importFrom dplyr add_count
966+
#' @importFrom rlang sym
961967
#' @export
962968
add_count.Seurat <- function(x, ..., wt=NULL, sort=FALSE, name=NULL) {
963969

964970
# Deprecation of special column names
965-
.cols <- enquos(..., .ignore_empty="all") %>%
971+
.cols <- enquos(..., .ignore_empty="all") %>%
966972
map(~ quo_name(.x)) %>% unlist()
967973
if (is_sample_feature_deprecated_used(x, .cols)) {
968974
x <- ping_old_special_column_into_metadata(x)
969975
}
970976

971-
x@meta.data <-
972-
x %>%
977+
if (is.null(name)) name <- "n"
978+
.out <- x %>%
973979
as_tibble %>%
974-
dplyr::add_count(..., wt=!!enquo(wt), sort=sort, name=name) %>%
975-
as_meta_data(x)
980+
dplyr::group_by(..., .add = TRUE) %>%
981+
dplyr::mutate(!!sym(name) := if (is.null(wt)) dplyr::n() else sum(!!enquo(wt), na.rm = TRUE)) %>%
982+
dplyr::ungroup()
983+
if (sort) .out <- dplyr::arrange(.out, dplyr::desc(!!sym(name)))
984+
x@meta.data <- .out %>% as_meta_data(x)
976985

977986
x
978987
}

inst/NEWS.rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
\name{NEWS}
22
\title{News for Package \pkg{tidyseurat}}
33

4+
\section{Changes in version 0.8.9}{
5+
\itemize{
6+
\item CRAN fix: \code{add_count()} now uses \code{count(..., .add = TRUE)} instead of \code{dplyr::add_count()}, avoiding the defunct \code{.drop} argument (dplyr 1.0.0+).
7+
}}
8+
49
\section{Changes in version 0.8.8}{
510
\itemize{
611
\item Removed deprecated \code{.drop} argument from \code{add_count.Seurat()} to align with dplyr's API changes

man/filter.Rd

Lines changed: 137 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/group_by.Rd

Lines changed: 16 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mutate.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)