-
Notifications
You must be signed in to change notification settings - Fork 929
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
Implement group.by arg to FindAllMarkers #9550
Merged
dcollins15
merged 11 commits into
satijalab:develop
from
rharao:rharao-findallmarkers-groupby
Dec 20, 2024
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d988101
Implement group.by arg to FindAllMarkers
rharao 28af73f
Handle "ident"; guard against group.by not in metadata
rharao e93d0f5
roxygenize
rharao 0e9b6ff
stray file mode change
rharao 44e500b
Ensure condition length 1
rharao ffd4a20
ensure condition length 1
rharao 51654e5
Move FindAllMarkers calls inside test_that
dcollins15 1ae260b
Add test case for FindMarkers group.by
dcollins15 f93380a
Raise warning when `node` and `group.by` are both set
dcollins15 8723dcc
Update changelog
dcollins15 9c9a859
Bump version
dcollins15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ FindAllMarkers <- function( | |
object, | ||
assay = NULL, | ||
features = NULL, | ||
group.by = NULL, | ||
logfc.threshold = 0.1, | ||
test.use = 'wilcox', | ||
slot = 'data', | ||
|
@@ -75,11 +76,25 @@ FindAllMarkers <- function( | |
return.thresh <- 0.7 | ||
} | ||
if (is.null(x = node)) { | ||
if (!is.null(x = group.by) && !identical(x = group.by, y = "ident")) { | ||
if (length(x = group.by) == 1 && ! group.by %in% colnames(x = [email protected])) { | ||
stop("'", group.by, "' not found in object metadata") | ||
} | ||
Idents(object = object) <- group.by | ||
} | ||
idents.all <- sort(x = unique(x = Idents(object = object))) | ||
} else { | ||
if (!PackageCheck('ape', error = FALSE)) { | ||
stop(cluster.ape, call. = FALSE) | ||
} | ||
if (!is.null(group.by)) { | ||
warning( | ||
paste0( | ||
"The `group.by` parameter for `FindAllMarkers` ", | ||
"is ignored when `node` is set." | ||
) | ||
) | ||
} | ||
tree <- Tool(object = object, slot = 'BuildClusterTree') | ||
if (is.null(x = tree)) { | ||
stop("Please run 'BuildClusterTree' before finding markers on nodes") | ||
|
@@ -896,7 +911,7 @@ FindMarkers.DimReduc <- function( | |
#' use all other cells for comparison; if an object of class \code{phylo} or | ||
#' 'clustertree' is passed to \code{ident.1}, must pass a node to find markers for | ||
#' @param group.by Regroup cells into a different identity class prior to | ||
#' performing differential expression (see example) | ||
#' performing differential expression (see example); \code{"ident"} to use Idents | ||
#' @param subset.ident Subset a particular identity class prior to regrouping. | ||
#' Only relevant if group.by is set (see example) | ||
#' @param assay Assay to use in differential expression testing | ||
|
@@ -919,10 +934,13 @@ FindMarkers.Seurat <- function( | |
reduction = NULL, | ||
... | ||
) { | ||
if (!is.null(x = group.by)) { | ||
if (!is.null(x = group.by) && !identical(x = group.by, y = "ident")) { | ||
if (!is.null(x = subset.ident)) { | ||
object <- subset(x = object, idents = subset.ident) | ||
} | ||
if (length(x = group.by) == 1 && ! group.by %in% colnames(x = [email protected])) { | ||
stop("'", group.by, "' not found in object metadata") | ||
} | ||
Idents(object = object) <- group.by | ||
} | ||
if (!is.null(x = assay) && !is.null(x = reduction)) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a copy-paste error here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, I'll need to update
NEWS.md
as part of the final release anyways—thanks for the catch!