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

Fix PercentageFeatureSet to respect the assay parameter #9686

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dcollins15
Copy link
Contributor

This PR makes two small changes to PercentageFeatureSet:

  1. Correctly passes assay to the Layers call on line 1178 of utilities.R.
  2. Raises a warning when the features parameter contains values not present in the specified assay instead of erroring out.

My intent is to introduce a proper test for PercentageFeatureSet for now, the following scripts can be used to verify the fixes. Verify that assay is being respected:

library(testthat)
library(Seurat)

counts <- LayerData(pbmc_small, assay = "RNA", layer = "counts")
data <- LayerData(pbmc_small, assay = "RNA", layer = "data")

assay_left <- CreateAssay5Object(data = data)
assay_right <- CreateAssay5Object(counts)

test_case <- CreateSeuratObject(assay_left, assay = "LEFT")
test_case[["RIGHT"]] <- assay_right

DefaultAssay(test_case) <- "RIGHT"
expected <- PercentageFeatureSet(test_case, assay = "RIGHT", pattern = "^RP[LS]")

DefaultAssay(test_case) <- "LEFT"
result <- PercentageFeatureSet(test_case, assay = "RIGHT", pattern = "^RP[LS]")

expect_true(identical(result, expected))

And check that a warning (not an error) is raised when features contains bad values:

PercentageFeatureSet(pbmc_small, features = "not-a-gene")

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.

2 participants