Skip to content

Commit

Permalink
Merge branch 'master' into controls-to-map
Browse files Browse the repository at this point in the history
* master:
  Fix bug with display of genotype colorby control
  tip modal click behavior. closes #252
  Map colors by genotype. Fixes #220.
  version bump to 1.1.2 for release
  add gates tweet
  • Loading branch information
jameshadfield committed Mar 17, 2017
2 parents 74f032e + d89efe2 commit c92b0fd
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextstrain-auspice",
"version": "1.1.1",
"version": "1.1.2",
"description": "Nextstrain auspice",
"scripts": {
"clean": "rimraf dist",
Expand Down
6 changes: 3 additions & 3 deletions src/components/controls/color-by.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class ColorBy extends React.Component {
}

genotypeInput() {
let placeholder = "Genome position";
let value = "";
if (this.props.colorBy) {
if (this.props.colorBy.slice(0, 2) === "gt") {
placeholder = this.props.colorBy.slice(3);
value = this.props.colorBy.slice(3);
}
}
if (this.state.selected === "gt") {
return (
<input type="text" placeholder={placeholder}
<input type="text" placeholder="Genome position" value={value}
onChange={(e) => this.setGenotypeColorBy(e.target.value)}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import getLatLongs from "../../util/mapHelpersLatLong";
colorBy: state.controls.colorBy,
map: state.map,
geoResolution: state.controls.geoResolution,
sequences: state.sequences
};
})
class Map extends React.Component {
Expand Down Expand Up @@ -230,7 +231,8 @@ class Map extends React.Component {
this.state.map,
this.props.colorBy,
this.props.geoResolution,
this.props.colorScale.scale,
this.props.colorScale,
this.props.sequences
);
}
createMap() {
Expand Down
9 changes: 8 additions & 1 deletion src/components/tree/tipSelectedPanel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*eslint-env browser*/
import React from "react";
import {infoPanelStyles} from "../../globalStyles";

Expand Down Expand Up @@ -34,11 +35,17 @@ const TipSelectedPanel = ({tip, goAwayCallback}) => {
}
};

const stopProp = (e) => {
if (!e) {e = window.event;}
e.cancelBubble = true;
if (e.stopPropagation) {e.stopPropagation();}
};

const makePanel = () => {
if (!tip) {return null;}
return (
<div style={styles.container} onClick={() => goAwayCallback(tip)}>
<div className={"panel"} style={infoPanelStyles.panel}>
<div className={"panel"} style={infoPanelStyles.panel} onClick={(e) => stopProp(e)}>
<p style={infoPanelStyles.modalHeading}>
{`${tip.n.strain}`}
</p>
Expand Down
1 change: 1 addition & 0 deletions src/static/helpers/tweets.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/util/mapHelpersLatLong.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {averageColors} from "./colorHelpers";
import {getTipColorAttribute} from "./treeHelpers";

const getLatLongs = (nodes, visibility, metadata, map, colorBy, geoResolution, colorScale) => {

const getLatLongs = (nodes, visibility, metadata, map, colorBy, geoResolution, colorScale, sequences) => {
const aggregatedLocations = {}; /* demes */
const aggregatedTransmissions = {}; /* edges, animation paths */
const demesToColors = {};
Expand Down Expand Up @@ -29,13 +29,14 @@ const getLatLongs = (nodes, visibility, metadata, map, colorBy, geoResolution, c
*/
nodes.forEach((n, i) => {
/* demes only count terminal nodes */
const tipColorAttribute = getTipColorAttribute(n, colorScale, sequences);
if (!n.children && visibility[i] === "visible") {
// look up geo1 geo2 geo3 do lat longs differ
if (aggregatedLocations[n.attr[geoResolution]]) {
aggregatedLocations[n.attr[geoResolution]].push(colorScale(n.attr[colorBy]));
aggregatedLocations[n.attr[geoResolution]].push(colorScale.scale(tipColorAttribute));
} else {
// if we haven't added this pair, add it
aggregatedLocations[n.attr[geoResolution]] = [colorScale(n.attr[colorBy])];
aggregatedLocations[n.attr[geoResolution]] = [colorScale.scale(tipColorAttribute)];
}
}
/* transmissions count internal node transitions as well
Expand All @@ -51,9 +52,9 @@ const getLatLongs = (nodes, visibility, metadata, map, colorBy, geoResolution, c
visibility[child.arrayIdx] === "visible") {
const transmission = n.attr[geoResolution] + "/" + child.attr[geoResolution];
if (aggregatedTransmissions[transmission]) {
aggregatedTransmissions[transmission].push(colorScale(n.attr[colorBy]));
aggregatedTransmissions[transmission].push(colorScale.scale(n.attr[colorBy]));
} else {
aggregatedTransmissions[transmission] = [colorScale(n.attr[colorBy])];
aggregatedTransmissions[transmission] = [colorScale.scale(n.attr[colorBy])];
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/util/treeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const calcBranchThickness = function (nodes, visibility, rootIdx) {
));
};

const getTipColorAttribute = function (node, colorScale, sequences) {
export const getTipColorAttribute = function (node, colorScale, sequences) {
if (colorScale.colorBy.slice(0, 3) === "gt-" && colorScale.genotype) {
return getGenotype(colorScale.genotype[0][0],
colorScale.genotype[0][1],
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "1.1.1";
export const version = "1.1.2";

0 comments on commit c92b0fd

Please sign in to comment.