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

Implement group.by arg to FindAllMarkers #9550

Merged
merged 11 commits into from
Dec 20, 2024

Conversation

rharao
Copy link
Contributor

@rharao rharao commented Dec 12, 2024

I saw @AlbertoFabbri93's suggestion on #4775 and thought it was a good idea. Currently, one can't group the cells for FindAllMarkers by anything besides the object's idents.

@samuel-marsh
Copy link
Collaborator

Hi @rharao,

If you don't mind suggestion I would recommend adding two check addition checks to the PR, just for end users sake.

First, would be a check that group.by is a column in meta.data. If not then the whole object will get the same ident and cause error.
Second, would be accepting "ident" to mean the current object ident which fits with behavior of other package functions.

So overall something like:

if (!is.null(x = group.by)) {
  if (group.by != "ident") {
    if (!group.by %in% colnames(x = [email protected]) {
      stop(paste0(group.by, " is not found in object meta.data."))
    } else {
      Idents(object = object) <- group.by
    }
  }
}

Best,
Sam

@rharao
Copy link
Contributor Author

rharao commented Dec 13, 2024

@samuel-marsh I'm glad you mentioned this. I considered this, but these conditionals are the ones currently in place with FindMarkers.Seurat. In a future commit, I will implement a check in both functions that the supplied argument is in the colnames if it's a scalar.

One benefit to the minimally guarded assignment here is that the user can supply a vector of cell memberships that might not be part of the object metadata. I can add another conditional to allow this.

My opinion is that Idents<- should at least warn before recycling a scalar to use as idents, but that's another discussion.

@rharao
Copy link
Contributor Author

rharao commented Dec 16, 2024

@samuel-marsh I think this is now ready unless something else is noticed. I'd appreciate your review if you have time

@samuel-marsh
Copy link
Collaborator

Hi @rharao,

Things look ok to me. I’m not member of dev team though so can’t do the official review and merge.

Best,
Sam

@rharao
Copy link
Contributor Author

rharao commented Dec 20, 2024

@dcollins15 any additional thoughts?

@dcollins15
Copy link
Contributor

Thanks for this @rharao! I was waiting to run this change by a couple of other lab members who're fairly opinionated about the FindAllMarkers interface—they're also enthusiastic about the update 🔥

I want to get this merged in ASAP so I can start the CRAN submission process this afternoon—do you mind if I rebase (just to keep the commit history linear) and then push up a couple of small tweaks?

I've got the following changes in the can:

  • Adding a relevant test case to test_differential_expression.R
  • Throwing a warning when node and group.by are both set informing the user that the latter parameter will be ignored.
  • Updating the changelog
  • Bumping the package version (5.1.0.9017 -> 5.1.0.9018)

@rharao
Copy link
Contributor Author

rharao commented Dec 20, 2024

Don't mind at all. Thanks a lot.

@dcollins15 dcollins15 force-pushed the rharao-findallmarkers-groupby branch from ebbcc97 to ffd4a20 Compare December 20, 2024 17:46
Copy link
Contributor

@dcollins15 dcollins15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@@ -1,6 +1,8 @@
# Unreleased

## Changes
- Added `group.by` parameter to `FindAllMarkers`, allowing users to regroup their data using a non-default identity class prior to performing differential expression ([#9550](https://github.com/satijalab/seurat/pull/9550))
#' performing differential expression (see example); \code{"ident"} to use Idents
Copy link
Contributor Author

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 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Copy link
Contributor

@dcollins15 dcollins15 Dec 20, 2024

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!

@dcollins15 dcollins15 merged commit 746f872 into satijalab:develop Dec 20, 2024
1 of 2 checks passed
@rharao
Copy link
Contributor Author

rharao commented Dec 20, 2024

Thanks again @dcollins15 ❤️ I'm deleting the branch on my fork now
Coincidence: #9550 mod #4775 = 0

@rharao rharao deleted the rharao-findallmarkers-groupby branch December 20, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants