Skip to content

Commit 9f63e7b

Browse files
committed
Update version to 0.8.9, modify add_count() to use dplyr's group_by and mutate for better compatibility, and add rlang::sym for dynamic variable names. Update NEWS with CRAN fix details.
1 parent 20c2332 commit 9f63e7b

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
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 = "[email protected]",
66
role = c("aut", "cre")),
77
person("Maria", "Doyle", email = "[email protected]",

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: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,26 +952,35 @@ 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+
x %>%
957+
dplyr::group_by(..., .add = TRUE) %>%
958+
dplyr::mutate(!!rlang::sym(name) := if (is.null(wt)) n() else sum(!!enquo(wt), na.rm = TRUE)) %>%
959+
dplyr::ungroup() %>%
960+
{ if (sort) dplyr::arrange(., desc(!!rlang::sym(name))) else . }
956961
}
957962

958963
#' @rdname count
959964
#' @aliases add_count
960-
#' @importFrom dplyr add_count
965+
#' @importFrom rlang sym
961966
#' @export
962967
add_count.Seurat <- function(x, ..., wt=NULL, sort=FALSE, name=NULL) {
963968

964969
# Deprecation of special column names
965-
.cols <- enquos(..., .ignore_empty="all") %>%
970+
.cols <- enquos(..., .ignore_empty="all") %>%
966971
map(~ quo_name(.x)) %>% unlist()
967972
if (is_sample_feature_deprecated_used(x, .cols)) {
968973
x <- ping_old_special_column_into_metadata(x)
969974
}
970975

976+
if (is.null(name)) name <- "n"
971977
x@meta.data <-
972978
x %>%
973979
as_tibble %>%
974-
dplyr::add_count(..., wt=!!enquo(wt), sort=sort, name=name) %>%
980+
dplyr::group_by(..., .add = TRUE) %>%
981+
dplyr::mutate(!!sym(name) := if (is.null(wt)) n() else sum(!!enquo(wt), na.rm = TRUE)) %>%
982+
dplyr::ungroup() %>%
983+
{ if (sort) dplyr::arrange(., desc(!!sym(name))) else . } %>%
975984
as_meta_data(x)
976985

977986
x

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/summarise.Rd

Lines changed: 2 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)