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

Shear UI #505

Merged
merged 75 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
cbf4060
bp shear
kwcantrell Mar 1, 2021
227ec29
style fix
kwcantrell Mar 1, 2021
66c2e56
checkpoint
kwcantrell Mar 6, 2021
1183aa7
checkpoint
kwcantrell Mar 9, 2021
eafbea3
Finished TreeController
kwcantrell Mar 10, 2021
7301e82
tree-controller
kwcantrell Mar 17, 2021
888cf72
merged with master
kwcantrell Mar 17, 2021
f4f668f
fix doc issue
kwcantrell Mar 17, 2021
a408326
style fix
kwcantrell Mar 17, 2021
b043826
Apply suggestions from code review
kwcantrell Mar 19, 2021
caa916e
Merge branch 'master' of https://github.com/biocore/empress into tree…
kwcantrell Mar 19, 2021
f598928
fix style
kwcantrell Mar 19, 2021
5ca5809
addressed comments
kwcantrell Mar 23, 2021
89a4326
removed shear
kwcantrell Mar 23, 2021
654df69
start ui
kwcantrell Mar 24, 2021
d6aa515
finished basic shear ui
kwcantrell Mar 25, 2021
de01d93
fixed test issue
kwcantrell Mar 25, 2021
fcb6b5b
removed old comments
kwcantrell Mar 25, 2021
55f6f7e
merged master
kwcantrell Mar 25, 2021
b3acbd1
Apply suggestions from code review
kwcantrell Mar 30, 2021
263dd6a
started addressing PR suggestions
kwcantrell Mar 30, 2021
5bb8729
Merge branch 'shear-ui' of https://github.com/kwcantrell/empress into…
kwcantrell Mar 30, 2021
68d0d63
fixed style
kwcantrell Mar 30, 2021
603bf97
still addressing comments
kwcantrell Apr 1, 2021
31b5af3
fixed style
kwcantrell Apr 1, 2021
7f56e68
fix unselect all
kwcantrell Apr 1, 2021
9a9bb75
Fixed unselect all for circ layout
kwcantrell Apr 1, 2021
9dc26bc
fixed issue were tree disappears if all tips sheared
kwcantrell Apr 1, 2021
4445ebd
check point
kwcantrell Apr 1, 2021
15f81ab
fixed clade collapse
kwcantrell Apr 1, 2021
4630689
fixed style
kwcantrell Apr 1, 2021
73892fd
fixed test
kwcantrell Apr 1, 2021
3ca595e
fixed no biom error
kwcantrell Apr 2, 2021
66e5ded
checkpoint
kwcantrell Apr 6, 2021
9eb4243
performance improvemens
kwcantrell Apr 7, 2021
e3d128f
merged master
kwcantrell Apr 8, 2021
4b4d8e3
finished documenting
kwcantrell Apr 9, 2021
3d05f17
style fix
kwcantrell Apr 9, 2021
d909e83
added warning to shear
kwcantrell Apr 9, 2021
3b6d854
Major performance increase!
kwcantrell Apr 11, 2021
0803dc0
Apply suggestions from code review
kwcantrell Apr 12, 2021
cc754e9
fix style
kwcantrell Apr 12, 2021
3a2eede
Add warning message to shear panel
kwcantrell Apr 13, 2021
95392a5
starting addressing @fedarko's comments
kwcantrell May 4, 2021
45e2d49
addressed @fedarko's comments
kwcantrell May 4, 2021
3570a19
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell May 4, 2021
e78ecd1
fix test
kwcantrell May 4, 2021
c95adf8
Apply suggestions from code review
kwcantrell May 17, 2021
af71569
added more @fedarko's suggestions + stle fix
kwcantrell May 17, 2021
35a2aa9
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell May 28, 2021
928a2ce
address @fedarko's PR comments
kwcantrell May 28, 2021
6d4571a
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell Jun 6, 2021
6074e5d
fixed collapse issue
kwcantrell Jun 10, 2021
0b081ca
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell Jun 10, 2021
0bd1160
Apply suggestions from code review
kwcantrell Jun 10, 2021
d3c2a61
fixed callback for emperor selections
kwcantrell Jun 10, 2021
ac544fb
fixed style
kwcantrell Jun 10, 2021
55ca475
modified node circle text
kwcantrell Jun 10, 2021
aedb860
merged with master
kwcantrell Jun 11, 2021
90571be
disabled tabs during animation
kwcantrell Jun 11, 2021
149ecb5
fixed tests/lint issues
kwcantrell Jun 11, 2021
288a140
Apply suggestions from code review
kwcantrell Jun 29, 2021
7faa70a
modified message
kwcantrell Jun 29, 2021
cb085ba
addressed comments
kwcantrell Jun 29, 2021
8af9b93
fixed python test
kwcantrell Jun 29, 2021
c0fbd57
Merge branch 'master' of https://github.com/biocore/empress into pr50…
fedarko Jul 17, 2021
0505705
Remove extra " in side panel disabled message
fedarko Jul 17, 2021
924b938
rm another extra "
fedarko Jul 17, 2021
0bae2ce
space after "
fedarko Jul 17, 2021
953abd8
fix problem i introduced in the last commit ._.
fedarko Jul 17, 2021
8767132
MNT: RM \t chars, make e-d-*.js docs consistent
fedarko Jul 17, 2021
01d7022
DOC: Adjust tab-disabled prefix using isEmpirePlot
fedarko Jul 17, 2021
c57a5d2
DOC: Make uses of bold fonts consistent
fedarko Jul 17, 2021
00b7dee
STY: prettify
fedarko Jul 17, 2021
b664bfd
Cleaner toast msg for no-FM-b/c-shearing case
fedarko Jul 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion empress/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def __init__(self, tree, table=None, sample_metadata=None,
self.features = None

self.ordination = ordination
self.is_empire_plot = (self.ordination is not None)

self.base_url = resource_path
if self.base_url is None:
Expand All @@ -157,7 +158,7 @@ def __init__(self, tree, table=None, sample_metadata=None,
shear_to_feature_metadata,
)

if self.ordination is not None:
if self.is_empire_plot:

# biplot arrows can optionally have metadata, think for example
# a study where the arrows represent pH, Alkalinity, etc.
Expand Down Expand Up @@ -365,6 +366,8 @@ def to_dict(self):
'names': names,
# Should we show sample metadata coloring / animation panels?
'is_community_plot': self.is_community_plot,
# Are we working with an EMPire plot?
'is_empire_plot': self.is_empire_plot,
# feature table
's_ids': s_ids,
'f_ids': f_ids,
Expand Down
6 changes: 6 additions & 0 deletions empress/support_files/css/empress.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,17 @@ p.side-header button:hover,

/* Somewhere else in the CSS adjusts line height and justify-content,
* so we reset these here.
*
* Also, the reason for display: block is because the .control p CSS
* elsewhere causes weird problems when there are other tags (e.g.
* <span>s, like in the shearing UI) within <p> tags of class
* side-panel-notes due to the flex display.
*/
.side-panel-notes {
font-size: small;
line-height: normal !important;
justify-content: start !important;
display: block !important;
}

.indented {
Expand Down
21 changes: 20 additions & 1 deletion empress/support_files/js/animation-panel-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ define(["Colorer", "util"], function (Colorer, util) {
* Creates tab for the animation panel and handles their events events.
*
* @param{Object} animator The object that creates the animations
* @param{EnableDisableAnimationTab} tab The Animation tab
*
* @return {AnimationPanel}
* construct AnimationPanel
*/
function AnimationPanel(animator) {
function AnimationPanel(animator, tab) {
this.tab = tab;
// used in event triggers
this.animator = animator;

Expand Down Expand Up @@ -45,6 +47,23 @@ define(["Colorer", "util"], function (Colorer, util) {
this._onAnimationStopped = null;
}

/*
* Enables the Animation tab. This will result in the Animation tab
* containing its original content.
*/
AnimationPanel.prototype.enableTab = function () {
this.tab.enableTab();
};

/*
* Disables the Animation tab. This will result in the Animation tab
* containing a message describing why the tab has been disabled and how to
* re-enable it.
*/
AnimationPanel.prototype.disableTab = function () {
this.tab.disableTab();
};

/**
* Makes the play button visible. This is the menu shown before user has
* started the animation.
Expand Down
36 changes: 35 additions & 1 deletion empress/support_files/js/animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ define(["Colorer", "util"], function (Colorer, util) {
*
* @param{Empress} empress The core class. Entry point for all metadata and
* tree operations.
* @param{Array} sidePanelTabs An array of EnableDisableSidePanelTab
* for the side-panel tabs. These tabs will be
* disabled while the animator is active and
* enabled otherwise.
*
* @returns{Animator}
* @constructs Animator
*/
function Animator(empress) {
function Animator(empress, sidePanelTabs) {
/**
* @type {Empress}
* The Empress state machine
Expand Down Expand Up @@ -109,7 +113,35 @@ define(["Colorer", "util"], function (Colorer, util) {
* Extra width for branches.
*/
this.lWidth = 0;

/**
* @type {Array}
* Stores the side-panel tabs. These tabs will be disabled
* while the animator is active and enabled otherwise.
* Each element of this array is an EnableDisableSidePanelTab object
*/
this.sidePanelTabs = sidePanelTabs;
}
/*
* Enables the side panel tabs. This will result in the side panel tabs
* containing their original content.
*/
Animator.prototype.disableSidePanelTabs = function () {
_.each(this.sidePanelTabs, function (tab) {
tab.disableTab();
});
};

/*
* Disables the side panel tabs. This will result in the side panel tabs
* containing a message describing why the tabs have been disabled and how
* to re-enable them.
*/
Animator.prototype.enableSidePanelTabs = function () {
_.each(this.sidePanelTabs, function (tab) {
tab.enableTab();
});
};

/**
* Sets the parameters for the animation state machine.
Expand Down Expand Up @@ -310,6 +342,7 @@ define(["Colorer", "util"], function (Colorer, util) {
* start the animation loop.
*/
Animator.prototype.startAnimation = function () {
this.disableSidePanelTabs();
this.initAnimation();

// start animation loop
Expand Down Expand Up @@ -338,6 +371,7 @@ define(["Colorer", "util"], function (Colorer, util) {
* Stops the animation and clears state machine parameters
*/
Animator.prototype.stopAnimation = function () {
this.enableSidePanelTabs();
this.__resetParams();
this.empress.clearLegend();
this.empress.resetTree();
Expand Down
35 changes: 34 additions & 1 deletion empress/support_files/js/biom-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ define(["underscore", "util"], function (_, util) {
this._tbl = tbl;
this._smCols = smCols;
this._sm = sm;

/**
* A set of feature IDs to ignore. This will be updated whenever
* the tree is sheared, and will contain the IDs of the features in
* the BIOM table (tips) that were removed.
* @ type {Set}
*/
this.ignorefIdx = new Set();
}

/**
Expand Down Expand Up @@ -278,7 +286,9 @@ define(["underscore", "util"], function (_, util) {
var cVal;
var addSampleFeatures = function (sIdx, cVal) {
_.each(scope._tbl[sIdx], function (fIdx) {
valueToFeatureIdxs[cVal].add(fIdx);
if (!scope.ignorefIdx.has(fIdx)) {
valueToFeatureIdxs[cVal].add(fIdx);
}
});
};
// For each sample...
Expand Down Expand Up @@ -582,6 +592,10 @@ define(["underscore", "util"], function (_, util) {
var fID2Freqs = {};
var totalSampleCount;
_.each(this._fIDs, function (fID, fIdx) {
// we dont want to consider features that have been marked as ignore
if (scope.ignorefIdx.has(fIdx)) {
return;
}
totalSampleCount = fIdx2SampleCt[fIdx];
fID2Freqs[fID] = {};
_.each(fIdx2Counts[fIdx], function (count, smValIdx) {
Expand All @@ -591,8 +605,27 @@ define(["underscore", "util"], function (_, util) {
}
});
});

return fID2Freqs;
};

/**
* Set which features to ignore. Features in this set will not be
* considered in functions such as getObsBy() or getFrequencyMap()
*
* @param {Set} nodes A set of feature ids to ignore
*/
BIOMTable.prototype.setIgnoreNodes = function (nodes) {
var scope = this;

// convert feature ids to feature indices
// [...nodes] converts nodes from Set to Array: see
// https://stackoverflow.com/a/63818423
var nodeIdx = _.map([...nodes], (fId) => {
return scope._getFeatureIndexFromID(fId);
});
this.ignorefIdx = new Set(nodeIdx);
};

return BIOMTable;
});
Loading