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

Animation #146

Merged
merged 73 commits into from
Apr 6, 2020
Merged

Animation #146

merged 73 commits into from
Apr 6, 2020

Conversation

kwcantrell
Copy link
Collaborator

No description provided.

Copy link
Member

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

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

Looks good, thanks so much Kalen. I've made a few comments but they are all fairly minor.

empress/_plot.py Outdated Show resolved Hide resolved
empress/_plot.py Outdated
@@ -78,6 +78,22 @@ def plot(output_dir: str,
.to_dataframe().filter(feature_table.index, axis=0) \
.to_dict(orient='index')

# TODO: Empress is currently sorting all metadata as strings. This is
Copy link
Member

Choose a reason for hiding this comment

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

I think sample metadata is in general fine loaded as a string. Have you encountered any issues?

empress/support_files/css/empress.css Outdated Show resolved Hide resolved
this.cam = cam;
this.VERTEX_SIZE = 5;

// sets empress to night mode
// TODO: make this a customizable parameter
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment can be removed based on @fedarko's issue here #143

Suggested change
// TODO: make this a customizable parameter
// TODO: make this a customizable parameter

empress/support_files/js/animator.js Show resolved Hide resolved
empress/support_files/js/animator.js Outdated Show resolved Hide resolved
empress/support_files/js/animator.js Outdated Show resolved Hide resolved
empress/support_files/js/animator.js Outdated Show resolved Hide resolved
empress/support_files/js/animator.js Show resolved Hide resolved
Copy link
Collaborator

@fedarko fedarko left a comment

Choose a reason for hiding this comment

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

This looks great @kwcantrell! I suggested a few changes -- some of these might take a nontrivial amount of work, so if you'd prefer to defer some to new issues on GitHub that's totally fine. (Or if you disagree with anything, just let me know :)

I'll try to get that big insertion tree animated through here later today and will let you all know how that goes.

empress/_plot.py Outdated Show resolved Hide resolved
empress/_plot.py Outdated Show resolved Hide resolved

// dont show next button on last frame
if (this.animator.onLastFrame()) {
this.nextFrameBtn.classList.add("hidden");
Copy link
Collaborator

Choose a reason for hiding this comment

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

A slight problem with this approach is that the buttons are positioned such that, when the Next Frame button is hidden, the Previous Frame button is shifted over to where this button previously was:

Second-from-last frame in an animation
penultimate

Last frame in an animation
ultimate

This means that, for people who are manually clicking through the animation, they'll likely accidentally press Previous Frame when they get to the final frame. Not a big deal, but an annoyance nonetheless.

IMO it would be better to absolutely position these buttons, to attempt to stave off this problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch! I'll update the PR to disable the prev/next button when on the first/last frame instead of hiding them.

this.startBtn.classList.add("hidden");
this.resumeBtn.classList.add("hidden");
this.prevFrameBtn.classList.add("hidden");
this.nextFrameBtn.classList.add("hidden");
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion at least :), it would be nice to have the prev/next-frame buttons present from the start of the animation -- it wasn't clear to me initially that these buttons were even available until I pressed Pause. For users who want to step through the animations at their own pace (either to go slower or faster), I suspect these buttons will be preferable.

Copy link
Collaborator Author

@kwcantrell kwcantrell Mar 31, 2020

Choose a reason for hiding this comment

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

@fedarko thanks for the suggestion! My goal with the GUI is to make things as intuitive and easy to use. One way I try to accomplish this is by only presenting options to the user that can be applied at that moment. Since the prev/next features can only be used when the animation is paused, I decided to hide those options unless the user pauses the animation.

Instead of hiding those buttons, I can disable them while the animation is running and enable them when the animation is paused. Also, I can start the animation is the pause state instead of the run state so users who wanted to manually step through the animation could do so without having to first pause the animation first.

@ElDeveloper how does Emperor handle this?

Copy link
Member

Choose a reason for hiding this comment

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

In emperor we disable the buttons and still leave them visible (instead of hiding them).

<label for="animate-trajectory">Trajectory</label>
<label class="select-container">
<select id="animate-trajectory"></select>
</label>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really needed for this PR, but I'm just going to tag #138 here -- this would be a great place to add tooltips in the future explaining what exactly Gradient and Trajectory mean, for new users and/or for folks who haven't used the animation functionality in Emperor before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great suggestion!

Copy link
Member

Choose a reason for hiding this comment

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

Great suggestion @fedarko, I suggest doing that now using the title= attribute.

@@ -31,7 +31,7 @@
</p>
<p>
<label for="sample-line-width">Line Width</label>
<input id="sample-line-width" type="number" value="1">
<input id="sample-line-width" type="number" value="4">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not clear why the default is switched to 4 here? As #144 describes, line widths this large can start to look pretty jumbled when you inspect details of the tree. I would suggest keeping 1 as the default (it's also easier to see colored lines on a white background, IMO; another reason to keep light mode as the default)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This ties into the comment I posted on #144. The main issue comes from how line widths are calculate in empress. To create new lines, a rectangle is created (in tree space) whose width is 2*line_width. So, a line width of 4 can appear larger/smaller depending on how much space the tree spans.

I set the default to 4 before #144 came up because the tree I, when testing the animation feature, a line width of 4 looked the best. I guess I forgot to switch it back.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Understood! That makes sense to me. We'll probably have to reevaluate stuff for #144, but until then I guess the defaults don't matter too much.

//draw tree
this.empress.resetTree();
this.empress._colorTree(obs, this.cm);
this.empress.thickenSameSampleLines(this.lWidth);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This behavior differs from the normal sample coloring behavior -- in SidePanel.prototype._updateSample(), the call made is

        if (lWidth !== 1) {
            this.empress.thickenSameSampleLines(lWidth - 1);
        }

This inconsistency means that the same line width will result in differently-drawn rectangles between the sample coloring stuff and between the animation stuff:

Animation drawn with line width = 1:
image

Normal sample coloring, with line width = 1:
image

(Notice how the top screenshot's lines are drawn as being notably thicker than the bottom screenshot's.)

I would strongly suggest making this consistent (one way or another). That being said, we'll probably come back to this stuff when we get around to #144, so not a huge issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! SidePanel (which probably should be renamed to SampleColorer or something like) should not be responsible for adjusting the line width as that operation should be handled by the thickenSameSampleLines (which also should be renamed since it is thickens all colored branches not same sample lines).

I'll update #144 to include this.

empress/support_files/js/biom-table.js Outdated Show resolved Hide resolved
Comment on lines +100 to +101
// TODO: add total percentage of tree colored by each category
// old method was not correct.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's still not really clear how the previous method was incorrect from looking at #148. Not urgent or anything, but describing the bug somewhere would be nice (if nothing else, so that someone unfamiliar with it like me doesn't accidentally make the same mistake again :P)

kwcantrell and others added 20 commits March 30, 2020 15:26
Co-Authored-By: Yoshiki Vázquez Baeza <[email protected]>
Co-Authored-By: Yoshiki Vázquez Baeza <[email protected]>
Co-Authored-By: Marcus Fedarko <[email protected]>
Co-Authored-By: Yoshiki Vázquez Baeza <[email protected]>
Co-Authored-By: Yoshiki Vázquez Baeza <[email protected]>
Copy link
Member

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

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

All looks good to me, except for the tooltips. If those are added and @fedarko's comments are all addressed, I think this is good to be merged.

}

// convert result to array and sort
values = [...values];
Copy link
Member

Choose a reason for hiding this comment

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

The number of samples can be up to hundreds of thousands. Not sure what method might be better these days, but I think Array.from might be better.


// sets empress to night mode
// TODO: make this a customizable parameter
this.CLR_COL = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the light background until this can be user-modifiable.

empress/support_files/js/empress.js Show resolved Hide resolved
<label for="animate-trajectory">Trajectory</label>
<label class="select-container">
<select id="animate-trajectory"></select>
</label>
Copy link
Member

Choose a reason for hiding this comment

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

Great suggestion @fedarko, I suggest doing that now using the title= attribute.

@fedarko fedarko merged commit 3417f59 into biocore:master Apr 6, 2020
@ElDeveloper
Copy link
Member

Thanks everyone!

🎆 :shipit: 🚀 🎥

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