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 a bug with barplot length scaling; abstract and test length-scaling code #309

Merged
merged 5 commits into from
Aug 6, 2020

Conversation

fedarko
Copy link
Collaborator

@fedarko fedarko commented Aug 6, 2020

The bug in question occurs when any of the values in the feature metadata field used for length scaling are integer values represented as floats (e.g. "0.0"). The mapping between unique numeric feature metadata values and their corresponding lengths is contained in a mapping where, previously, the keys were passed through parseFloat() first. The problem with this is that parseFloat("0.0") is 0, and keys in Objects are treated as Strings -- so the entry for 0 was inaccessible to the nodes with a feature metadata value of 0.0, bizarrely. (The code assumes that a value being missing as a key from that mapping means that the value in question was non-numeric... but in this case it was because the Object was created incorrectly.)

Anyway, now the code stores the original string values as the keys in the Object, not the parseFloat()-ed values. (This is the same way the color-scaling code works -- the reason that that code doesn't suffer from this bug is likely because I was able to adapt it directly from Emperor, while the length-scaling code required some extra tweaking :) The problematic code in question has also been abstracted to a new utility function, which is now decently tested.

(This bug came up when testing visualizing feature importance scores as barplots -- the majority of importance scores in the moving-pictures-classifier/feature_importance.qza file in this tutorial are 0s, so I noticed that a lot of these were just missing from the barplot.)

fedarko added 5 commits August 6, 2020 09:46
TLDR, "0.0" was getting converted to "0", and those are different
things from JS' perspective in a mapping (since mapping keys are
all treated as strings).

By storing the initial string metadata values as the keys, we should
be good. (This is already what the coloring code was doing.)
(biocore#300 is now documented on GitHub, so we can get to it eventually)
@emperor-helper
Copy link

The following artifacts were built for this PR: empire-biplot.qzv, empire.qzv, empress-tree.qzv

@kwcantrell kwcantrell self-requested a review August 6, 2020 21:15
@kwcantrell
Copy link
Collaborator

Thanks @fedarko, this looks good to me. I think it should be good to merge.

@kwcantrell kwcantrell merged commit e3ed544 into biocore:master Aug 6, 2020
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