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

Support rectangular (and arbitrarily configurable) layouts; minor typo fixes / detail additions in CLI #145

Merged
merged 90 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f067e58
MNT: Fix typos and add details to Q2 plugin CLI
fedarko Feb 8, 2020
5560a88
ENH: progress on rectangular layout
fedarko Feb 10, 2020
303b52f
REL/STY: add igraph dependency; fix flake8 stuff
fedarko Feb 10, 2020
3a3bbe5
MNT/TST: split off code to to_igraph; fix tests
fedarko Feb 10, 2020
d0eeea7
TST/MNT: beef up to_igraph test; new code docs
fedarko Feb 10, 2020
137d710
STY: fix flake8 problems with test code
fedarko Feb 10, 2020
b477c33
BUG: in to_igraph, use nodes (not names) as keys
fedarko Mar 2, 2020
9cd646d
ENH: use scaling factors in rect layout
fedarko Mar 2, 2020
077a8d6
HACK: attempt at switching to pgviz
fedarko Mar 2, 2020
2ec8f37
Revert "HACK: attempt at switching to pgviz"
fedarko Mar 2, 2020
1c58797
ENH: replace igraph R-T layout with basic layout
fedarko Mar 18, 2020
27f58e2
MNT: remove igraph stuff
fedarko Mar 18, 2020
fb545eb
MNT: simplify things by spacing y-posns by 1 not 5
fedarko Mar 18, 2020
8be1adc
MNT: start y-coords from 0 rather than 1
fedarko Mar 18, 2020
04a39c8
BUG: Also scale root node's coords in rect layout
fedarko Mar 18, 2020
b975bcc
DOC: tidy up rect/circ layout docs
fedarko Mar 19, 2020
10d81e5
ENH: add nonfunctional side panel layout section
fedarko Mar 19, 2020
b7a10d7
ENH: Add dynamic layout toggling in the UI!
fedarko Mar 19, 2020
5188da4
STY: fix flake8/jshint problems
fedarko Mar 19, 2020
98aa718
BUG: don't call resetTree() when changing layout
fedarko Mar 19, 2020
93c3ba3
BUG/DOC: mention corner case in layout switching
fedarko Mar 19, 2020
da2d2a6
MNT: remove old comment
fedarko Mar 19, 2020
5370283
MNT: Make layout *only* dependent on coords(), etc
fedarko Mar 19, 2020
70a3e27
DOC: Adjust rect layout python shader/etc comment
fedarko Mar 19, 2020
3b83215
DOC: replace redundant comments
fedarko Mar 19, 2020
c12275a
DOC: Add example "full-length rectangular" layout
fedarko Mar 19, 2020
63839e5
STY: appease flake8/etc
fedarko Mar 19, 2020
8ababae
STY: fix flake8 pbms
fedarko Mar 19, 2020
00041e4
ENH: Render rect layout properly in JS!!!!!
fedarko Mar 20, 2020
ba9bdf4
MNT: remove old logging stmts from js
fedarko Mar 20, 2020
d51777d
Merge branch 'alternative-layout-example' into layout-stuff
fedarko Mar 23, 2020
954ba09
MNT: take out example 'full-length' layout
fedarko Mar 23, 2020
dee07fe
STY: Run prettier 2.x on JS files
fedarko Mar 23, 2020
8b3f486
BUG: Add (currently untested) input-matching code
fedarko Mar 23, 2020
45a6cb2
STY: flake8 pbms
fedarko Mar 23, 2020
e3f770b
TST: Test input matching
fedarko Mar 23, 2020
74d0f46
TST: attempt to set up codecov
fedarko Mar 23, 2020
f84fa78
TST: Run nose with coverage
fedarko Mar 23, 2020
1634527
TST: test a match_inputs failure case, clean code
fedarko Mar 23, 2020
0f3ddd1
Revert "BUG: Add (currently untested) input-matching code"
fedarko Mar 24, 2020
0f645bf
Revert "Revert "BUG: Add (currently untested) input-matching code""
fedarko Mar 24, 2020
fec25af
Revert "Revert "Revert "BUG: Add (currently untested) input-matching …
fedarko Mar 24, 2020
b3538df
Revert "Revert "BUG: Add (currently untested) input-matching code""
fedarko Mar 24, 2020
8d36994
Revert "TST: test a match_inputs failure case, clean code"
fedarko Mar 24, 2020
9098d65
Revert "TST: Run nose with coverage"
fedarko Mar 24, 2020
5f2f3b3
Revert "STY: flake8 pbms"
fedarko Mar 24, 2020
392ae4d
Merge branch 'layout-stuff' of https://github.com/fedarko/empress int…
fedarko Mar 24, 2020
197bc98
TST: begin refactoring tests
fedarko Mar 24, 2020
35b2900
MNT: Rename update_coordinates to reflect its use
fedarko Mar 24, 2020
a6bed86
DOC: update docs for update_unrooted_coords()
fedarko Mar 24, 2020
7d09b65
DOC: rescale -> layout in function names
fedarko Mar 24, 2020
812b810
TST: add detailed rect layout test
fedarko Mar 24, 2020
a28408a
DOC: add comment re: #141
fedarko Mar 24, 2020
af181e3
TST: beef up from_tree test a bit
fedarko Mar 24, 2020
c8b18f2
MNT: rm remaining matching changes in _plot
fedarko Mar 24, 2020
bda954c
DOC: update example qzv
fedarko Mar 24, 2020
0def156
DOC: fix small typo
fedarko Mar 24, 2020
2cd8c27
TST: test that vertical bar coords set properly
fedarko Mar 26, 2020
25e2d5f
BUG: account for rect layout 1-node-tree case
fedarko Mar 26, 2020
62ff6eb
BUG/ENH: Draw thick lines properly in rect layout
fedarko Mar 26, 2020
bcd32fb
STY: store tL/tR/bL/bR coords in (reusable) arrays
fedarko Mar 26, 2020
be913dc
BUG: redraw thick lines in btwn layout changes
fedarko Mar 26, 2020
e853c47
DOC: update example qzv
fedarko Mar 26, 2020
402470c
MNT: Abstract triangle-drawing code to sep func
fedarko Mar 27, 2020
8555e1b
MNT: Add check for invalid layout names in JS
fedarko Mar 27, 2020
f645782
BUG: Disallow trees with <= 1 nodes
fedarko Mar 27, 2020
515492d
DOC: Draw nodes more intuitively & imprv docs
fedarko Mar 27, 2020
1db74c9
BUG/MNT: Thicken root if it's colored
fedarko Mar 27, 2020
b1c96ff
DOC: remove old TODO that i just fixed
fedarko Mar 27, 2020
f9321c3
BUG: set coords_size better; fix thick bugs
fedarko Mar 27, 2020
fe1fa56
STY: fix js style
fedarko Mar 27, 2020
0dc3920
BUG/ENH: set 'for' for layout labels correctly
fedarko Mar 27, 2020
a58cc81
BUG: Improve thick-line adjusting on layout change
fedarko Mar 27, 2020
1e12024
BUG: Fix division-by-0 errors in r. layout scaling
fedarko Mar 27, 2020
b3ece44
DOC/MNT: Add note about v.lines and 1-out nodes
fedarko Mar 27, 2020
2690bee
TST: add test for rect layout in A->B->C case
fedarko Mar 28, 2020
dd681e7
TST: Disallow < 0 or all 0 node lens and test
fedarko Mar 28, 2020
0e85354
TST: explicitly check b.len. error msg precedence
fedarko Mar 28, 2020
b9fe69b
BUG/TST: Ignore root br.lens; acct for no br.lens
fedarko Mar 28, 2020
c8c3332
TST: document util func
fedarko Mar 28, 2020
dbc1936
STY: switch some layout vars to camelCase
fedarko Mar 30, 2020
3b27abb
DOC: Describe coords() output better
fedarko Mar 30, 2020
ddc54ee
Merge branch 'layout-stuff' of https://github.com/fedarko/empress int…
fedarko Mar 30, 2020
dce8588
DOC: think -> thick in comments
fedarko Mar 30, 2020
f779988
MNT: Remove circular layout function skeleton
fedarko Mar 30, 2020
16fcca9
Remove extraneous whitespace lines
fedarko Mar 31, 2020
467266e
MNT: split off coords-size-computation to sep func
fedarko Apr 1, 2020
ea44d18
Merge branch 'layout-stuff' of https://github.com/fedarko/empress int…
fedarko Apr 1, 2020
ea4af7f
Merge branch 'master' into layout-stuff
fedarko Apr 6, 2020
e9f2f06
STY: apply prettier chgs
fedarko Apr 6, 2020
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
Binary file modified docs/moving-pictures/empress-tree.qzv
Binary file not shown.
20 changes: 16 additions & 4 deletions empress/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,29 @@ def plot(output_dir: str,
tools.name_internal_nodes(empress_tree)

# TODO: figure out implications of screen size
empress_tree.coords(4020, 4020)
layout_to_coordsuffix, default_layout = empress_tree.coords(4020, 4020)

tree_data = {}
names_to_keys = {}
for i, node in enumerate(empress_tree.postorder(include_self=True), 1):
tree_data[i] = {
'name': node.name,
'x': node.x2,
'y': node.y2,
'color': [0.75, 0.75, 0.75],
'sampVal': 1,
'visible': True,
'single_samp': False}
'single_samp': False
}
# Add coordinate data from all layouts for this node
for layoutsuffix in layout_to_coordsuffix.values():
xcoord = "x" + layoutsuffix
ycoord = "y" + layoutsuffix
tree_data[i][xcoord] = getattr(node, xcoord)
tree_data[i][ycoord] = getattr(node, ycoord)
# Also add vertical bar coordinate info for the rectangular layout
if not node.is_tip():
tree_data[i]["highestchildyr"] = node.highestchildyr
tree_data[i]["lowestchildyr"] = node.lowestchildyr
ElDeveloper marked this conversation as resolved.
Show resolved Hide resolved

if node.name in names_to_keys:
names_to_keys[node.name].append(i)
else:
Expand Down Expand Up @@ -93,6 +103,8 @@ def plot(output_dir: str,
'sample_data': sample_data,
'obs_data': obs_data,
'names': names,
'layout_to_coordsuffix': layout_to_coordsuffix,
'default_layout': default_layout,
})

copytree(SUPPORT_FILES, os.path.join(output_dir, 'support_files'))
Expand Down
31 changes: 19 additions & 12 deletions empress/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@
import pkg_resources
__version__ = pkg_resources.get_distribution('empress').version # noqa

PARAMETERS = {'metadata': Metadata}
PARAMETERS_DESC = {
'metadata': 'The sample metadata.'
}

plugin = Plugin(
name='empress',
version=__version__,
website='http://github.com/biocore/empress',
package='empress',
citations=Citations.load('citations.bib', package='empress'),
description=('This QIIME 2 plugin wraps Empress and '
'supports interactive visualization of phylogentic '
'supports interactive visualization of phylogenetic '
'trees.'),
short_description='Plugin for visualizing phylogenies with Empress.'
)
Expand All @@ -44,14 +39,26 @@
'feature_metadata': Metadata
},
input_descriptions={
'tree': 'The phylogentic tree to visualize.',
'feature_table': 'The feature table to decorate the phylogeny.'
'tree': 'The phylogenetic tree to visualize.',
'feature_table': (
'The feature table relating samples to features in the tree. '
'This information allows us to decorate the phylogeny by '
'sample metadata.'
)
},
parameter_descriptions={
'sample_metadata': 'The sample metadata',
'feature_metadata': 'The feature metadata',
'sample_metadata': (
'Sample metadata. Can be used to color tips in the tree by '
'the samples they are unique to.'
),
'feature_metadata': (
'Feature metadata. Not currently used for anything, but will '
'be soon.'
)
},
name='Visualize and Explore Phylogenies with Empress',
description='Generates an interactive phylgentic tree where the user '
'can visually integrate sample and feature metadata. '
description=(
'Generates an interactive phylogenetic tree visualization '
'supporting interaction with sample and feature metadata.'
)
)
14 changes: 7 additions & 7 deletions empress/support_files/js/biom-table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define([], function() {
define([], function () {
/**
* @class BIOM-table
*
Expand Down Expand Up @@ -44,7 +44,7 @@ define([], function() {
*
* @return {Array}
*/
BIOMTable.convertToObs = function(countArray, obsIDs) {
BIOMTable.convertToObs = function (countArray, obsIDs) {
var obs = [];
for (var i = 0; i < countArray.length; i++) {
if (countArray[i] != 0) {
Expand All @@ -61,9 +61,9 @@ define([], function() {
*
* @return {Array}
*/
BIOMTable.prototype.getObjservationUnionForSamples = function(sIds) {
BIOMTable.prototype.getObjservationUnionForSamples = function (sIds) {
var result = new Set();
var addToResult = function(ob) {
var addToResult = function (ob) {
result.add(ob);
};
for (var i = 0; i < sIds.length; i++) {
Expand All @@ -81,7 +81,7 @@ define([], function() {
*
* @return {Dictionary}
*/
BIOMTable.prototype.getObsBy = function(cat) {
BIOMTable.prototype.getObsBy = function (cat) {
var result = {};
var cVal;
for (var sample in this._samp) {
Expand All @@ -106,7 +106,7 @@ define([], function() {
*
* @return {Number}
*/
BIOMTable.prototype.getObservations = function() {
BIOMTable.prototype.getObservations = function () {
var obs = new Set();

for (var sample in this._samp) {
Expand All @@ -123,7 +123,7 @@ define([], function() {
*
* @return{Array}
*/
BIOMTable.prototype.getSampleCategories = function() {
BIOMTable.prototype.getSampleCategories = function () {
return Object.keys(Object.values(this._samp)[0]).sort();
};

Expand Down
52 changes: 26 additions & 26 deletions empress/support_files/js/bp-tree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["ByteArray"], function(ByteArray) {
define(["ByteArray"], function (ByteArray) {
/**
*
* @class BPTree
Expand Down Expand Up @@ -123,7 +123,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return{Number}
*/
BPTree.prototype.rank = function(t, i) {
BPTree.prototype.rank = function (t, i) {
var rCache = t ? this.r1Cache_ : this.r0Cache_;
return rCache[i];
};
Expand All @@ -138,7 +138,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return{Number}
*/
BPTree.prototype.select = function(t, k) {
BPTree.prototype.select = function (t, k) {
var sCache = t ? this.s1Cache_ : this.s0Cache_;
return sCache[k - 1];
};
Expand All @@ -153,7 +153,7 @@ define(["ByteArray"], function(ByteArray) {
* @return{Number} The excess at position i
* @private
*/
BPTree.prototype.excess_ = function(i) {
BPTree.prototype.excess_ = function (i) {
// need to subtract 1 since i starts at 0
// Note: rank(1,i) - rank(0,i) = (2*(rank(1,i)) - i
return 2 * this.r1Cache_[i] - i - 1;
Expand All @@ -167,7 +167,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return{Number} Depth of node i
*/
BPTree.prototype.depth = function(i) {
BPTree.prototype.depth = function (i) {
//depth is same as excess
return this.eCache_[i];
};
Expand All @@ -180,7 +180,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return{String}
*/
BPTree.prototype.name = function(i) {
BPTree.prototype.name = function (i) {
return this.names_[this.preorder(i) - 1];
};

Expand All @@ -190,7 +190,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.numleafs = function() {
BPTree.prototype.numleafs = function () {
var total = 0;
for (var i = 0; i < this.b_.length - 1; i++) {
total = this.isleaf(i) ? total + 1 : total;
Expand All @@ -206,7 +206,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return{Number}
*/
BPTree.prototype.length = function(i) {
BPTree.prototype.length = function (i) {
return this.lengths_[this.preorder(i) - 1];
};

Expand All @@ -220,7 +220,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.fwdsearchNaive = function(i, d) {
BPTree.prototype.fwdsearchNaive = function (i, d) {
var b = this.eCache_[i] + d;
for (var j = i + 1; i < this.b_.length; j++) {
if (this.eCache_[j] === b) {
Expand All @@ -235,7 +235,7 @@ define(["ByteArray"], function(ByteArray) {
/**
* Currently this is just place holder
*/
BPTree.prototype.fwdsearch = function(i, d) {
BPTree.prototype.fwdsearch = function (i, d) {
return this.fwdsearchNaive(i, d);
};

Expand All @@ -249,7 +249,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.bwdsearchNaive = function(i, d) {
BPTree.prototype.bwdsearchNaive = function (i, d) {
var b = this.eCache_[i] + d;
for (var j = i - 1; j >= 0; j--) {
if (this.eCache_[j] === b) {
Expand All @@ -264,7 +264,7 @@ define(["ByteArray"], function(ByteArray) {
/**
* Currently this is just a place holder
*/
BPTree.prototype.bwdsearch = function(i, d) {
BPTree.prototype.bwdsearch = function (i, d) {
return this.bwdsearchNaive(i, d);
};

Expand All @@ -276,7 +276,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.open = function(i) {
BPTree.prototype.open = function (i) {
return this.b_[i] ? i : this.ocCache_[i];
};

Expand All @@ -288,7 +288,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.close = function(i) {
BPTree.prototype.close = function (i) {
return this.b_[i] ? this.ocCache_[i] : i;
};

Expand All @@ -300,7 +300,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.enclose = function(i) {
BPTree.prototype.enclose = function (i) {
// i is an open paren
if (this.b_[i]) {
return this.bwdsearch(i, -2) + 1;
Expand All @@ -319,7 +319,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.parent = function(i) {
BPTree.prototype.parent = function (i) {
// i represents the root node
if (i === this.root() || i === this.b_.length - 1) {
return -1;
Expand All @@ -333,7 +333,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.root = function() {
BPTree.prototype.root = function () {
return 0;
};

Expand All @@ -342,7 +342,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {boolean}
*/
BPTree.prototype.isleaf = function(i) {
BPTree.prototype.isleaf = function (i) {
return this.b_[i] && !this.b_[i + 1];
};

Expand All @@ -354,7 +354,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} return 0 if i is a leaf node
*/
BPTree.prototype.fchild = function(i) {
BPTree.prototype.fchild = function (i) {
if (this.isleaf(i)) {
return 0;
}
Expand All @@ -373,7 +373,7 @@ define(["ByteArray"], function(ByteArray) {
* i can be either an open or close parenthesis
* @return {Number} return 0 if i is a leaf node
*/
BPTree.prototype.lchild = function(i) {
BPTree.prototype.lchild = function (i) {
if (this.isleaf(i)) {
return 0;
}
Expand All @@ -393,7 +393,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number}
*/
BPTree.prototype.nsibling = function(i) {
BPTree.prototype.nsibling = function (i) {
// i is a close parenthesis
if (!this.b_[i]) {
return this.nsibling(this.open(i));
Expand All @@ -419,7 +419,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} returns 0 if no previous sibling
*/
BPTree.prototype.psibling = function(i) {
BPTree.prototype.psibling = function (i) {
var pos = 0;

// check to see if i is root
Expand Down Expand Up @@ -459,7 +459,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} The postorder rank of node i
*/
BPTree.prototype.postorder = function(i) {
BPTree.prototype.postorder = function (i) {
if (this.b_[i]) {
return this.rank(0, this.close(i));
} else {
Expand All @@ -475,7 +475,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} The index position of the node in the tree
*/
BPTree.prototype.postorderselect = function(k) {
BPTree.prototype.postorderselect = function (k) {
return this.open(this.select(0, k));
};

Expand All @@ -486,7 +486,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} The preorder rank of node i
*/
BPTree.prototype.preorder = function(i) {
BPTree.prototype.preorder = function (i) {
if (this.b_[i]) {
return this.rank(1, i);
} else {
Expand All @@ -502,7 +502,7 @@ define(["ByteArray"], function(ByteArray) {
*
* @return {Number} The index position of the node in the tree
*/
BPTree.prototype.preorderselect = function(k) {
BPTree.prototype.preorderselect = function (k) {
return this.select(1, k);
};

Expand Down
Loading