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

Bug with function PercentageFeatureSet() #8009

Closed
wjzwjz5 opened this issue Nov 13, 2023 · 1 comment
Closed

Bug with function PercentageFeatureSet() #8009

wjzwjz5 opened this issue Nov 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@wjzwjz5
Copy link

wjzwjz5 commented Nov 13, 2023

Hello! When I use the function PercentageFeatureSet() to remove the mitochondrial gene , I get some negative values in the results.Therefore,I reviewed the source code for PercentageFeatureSet().

layers <- Layers(object = object, pattern = "counts")

When I allowed this line of code , The layers I get are shown below.

layers
[1] "scale.data" "data"       "counts"

This results in subsequent calculations incorrectly using the 'data' matrix instead of the 'counts' matrix , resulting in a negative value.
When I change this line of code to look like this, it works.

layers <- Layers(object = object, search = "counts")

Thanks!

@wjzwjz5 wjzwjz5 added the bug Something isn't working label Nov 13, 2023
@samuel-marsh
Copy link
Collaborator

Hi,

Not member of dev team but hopefully can be helpful. Overall, while I cannot directly replicate your issue with getting negative values but there does seem to be issue here based on that line of code.

When I run with hca or pbmc Seurat data objects I get the correct values as in my case the layers get listed as:

> Layers(object = hca, pattern = "counts")
[1] "counts"     "data"       "scale.data"

So when it calculates the PercentageFeatureSet it actually does it 3 times (twice more than needed so extends running time). In my tests it does add the correct values to meta.data slot because the code then unlists the runs and because the "counts" slot is first in code result above only those values get added but you can see by size of unlisted vector it is 3x as large as hca dataset. Also could potentially add wrong values if layer order was different as in original bug report

> length(percent.featureset)
[1] 120000

I will submit PR shortly with the change.

Best,
Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants