react-mutation-mapper 0.8.57 → 0.8.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6865,10 +6865,16 @@ var LollipopPlotNoTooltip = /** @class */ (function (_super) {
6865
6865
  writable: true,
6866
6866
  value: function (y, yMax, ticks, placement, groupName, symbol) {
6867
6867
  if (symbol === void 0) { symbol = '#'; }
6868
- var label = groupName
6869
- ? symbol + " " + (this.props.hugoGeneSymbol ||
6870
- '') + " " + groupName + " Mutations"
6871
- : symbol + " " + (this.props.hugoGeneSymbol || '') + " Mutations";
6868
+ var label;
6869
+ if (this.props.yAxisLabelFormatter) {
6870
+ label = this.props.yAxisLabelFormatter(symbol, groupName);
6871
+ }
6872
+ else {
6873
+ label = groupName
6874
+ ? symbol + " " + (this.props.hugoGeneSymbol ||
6875
+ '') + " " + groupName + " Mutations"
6876
+ : symbol + " " + (this.props.hugoGeneSymbol || '') + " Mutations";
6877
+ }
6872
6878
  var placeOnBottom = placement === LollipopPlacement.BOTTOM;
6873
6879
  return (React__namespace.createElement(cbioportalFrontendCommons.SVGAxis, { key: "lollipopPlotYAxis_" + (placeOnBottom ? 'bottom' : 'top'), x: this.geneX - this.yAxisPadding, y: y, length: this.yAxisHeight, tickLength: 7, rangeLower: 0, rangeUpper: yMax, ticks: ticks, vertical: true, verticalLabelPadding: this.props.yAxisLabelPadding, reverse: placeOnBottom, label: label }));
6874
6880
  }
@@ -9549,7 +9555,7 @@ var LollipopMutationPlot = /** @class */ (function (_super) {
9549
9555
  value: function (mutationsAtPosition, countsByPosition) {
9550
9556
  var codon = mutationsAtPosition[0].proteinPosStart;
9551
9557
  var count = countsByPosition[codon];
9552
- var countInfo = this.props.lollipopTooltipCountInfo ? (this.props.lollipopTooltipCountInfo(count, mutationsAtPosition)) : (React__namespace.createElement("strong", null,
9558
+ var countInfo = this.props.lollipopTooltipCountInfo ? (this.props.lollipopTooltipCountInfo(count, mutationsAtPosition, this.props.axisMode)) : (React__namespace.createElement("strong", null,
9553
9559
  count,
9554
9560
  " mutation", "" + (count !== 1 ? 's' : '')));
9555
9561
  var label = lollipopLabelText(mutationsAtPosition);
@@ -10027,7 +10033,7 @@ var LollipopMutationPlot = /** @class */ (function (_super) {
10027
10033
  React__namespace.createElement(reactCollapse.Collapse, { isOpened: this.controlsConfig.legendShown }, this.props.legend || React__namespace.createElement(DefaultLollipopPlotLegend, null)),
10028
10034
  React__namespace.createElement(LollipopPlot, { sequence: this.sequence, lollipops: this.lollipops, domains: this.domains, dataStore: this.props.store.dataStore, vizWidth: this.props.geneWidth, vizHeight: this.props.vizHeight, hugoGeneSymbol: this.hugoGeneSymbol, xMax: this.proteinLength, yMax: this.yMaxInput, yMaxFractionDigits: this.yMaxSliderStep < 1
10029
10035
  ? this.props.yMaxFractionDigits
10030
- : undefined, yMaxLabelPostfix: this.props.yMaxLabelPostfix, yAxisLabelPadding: this.props.yAxisLabelPadding, showYAxis: this.props.showYAxis, bottomYMax: this.bottomYMaxInput, onXAxisOffset: this.onXAxisOffset, topYAxisSymbol: this.props.topYAxisSymbol, bottomYAxisSymbol: this.props.bottomYAxisSymbol, groups: this.groups }),
10036
+ : undefined, yMaxLabelPostfix: this.props.yMaxLabelPostfix, yAxisLabelPadding: this.props.yAxisLabelPadding, showYAxis: this.props.showYAxis, bottomYMax: this.bottomYMaxInput, onXAxisOffset: this.onXAxisOffset, topYAxisSymbol: this.props.topYAxisSymbol, bottomYAxisSymbol: this.props.bottomYAxisSymbol, groups: this.groups, yAxisLabelFormatter: this.props.yAxisLabelFormatter }),
10031
10037
  React__namespace.createElement(TrackPanel, { store: this.props.store, geneWidth: this.props.geneWidth, tracks: this.props.tracks, trackVisibility: this.trackVisibility, pubMedCache: this.props.pubMedCache, proteinLength: this.proteinLength, geneXOffset: this.geneXOffset, collapsePtmTrack: this.props.collapsePtmTrack, collapseUniprotTopologyTrack: this.props.collapseUniprotTopologyTrack })));
10032
10038
  }
10033
10039
  else if (this.props.store.canonicalTranscript.isComplete &&
@@ -10135,6 +10141,128 @@ var LollipopMutationPlot = /** @class */ (function (_super) {
10135
10141
  return LollipopMutationPlot;
10136
10142
  }(React__namespace.Component));
10137
10143
 
10144
+ exports.AxisScale = void 0;
10145
+ (function (AxisScale) {
10146
+ AxisScale["PERCENT"] = "%";
10147
+ AxisScale["COUNT"] = "#";
10148
+ })(exports.AxisScale || (exports.AxisScale = {}));
10149
+ var AxisScaleSwitch = /** @class */ (function (_super) {
10150
+ tslib.__extends(AxisScaleSwitch, _super);
10151
+ function AxisScaleSwitch(props) {
10152
+ var _this = _super.call(this, props) || this;
10153
+ Object.defineProperty(_this, "selectedScale", {
10154
+ enumerable: true,
10155
+ configurable: true,
10156
+ writable: true,
10157
+ value: void 0
10158
+ });
10159
+ _this.selectedScale = props.selectedScale;
10160
+ mobx.makeObservable(_this);
10161
+ return _this;
10162
+ }
10163
+ Object.defineProperty(AxisScaleSwitch.prototype, "toggleButton", {
10164
+ enumerable: false,
10165
+ configurable: true,
10166
+ writable: true,
10167
+ value: function (scale, onClick) {
10168
+ return (React__namespace.createElement("button", { className: classnames__default["default"]({
10169
+ 'btn-secondary': this.props.selectedScale === scale,
10170
+ 'btn-outline-secondary': this.props.selectedScale !== scale,
10171
+ }, 'btn', 'btn-sm', 'btn-axis-switch'), style: {
10172
+ lineHeight: 1,
10173
+ cursor: this.props.selectedScale === scale
10174
+ ? 'default'
10175
+ : 'pointer',
10176
+ fontWeight: this.props.selectedScale === scale
10177
+ ? 'bolder'
10178
+ : 'normal',
10179
+ }, onClick: onClick }, scale));
10180
+ }
10181
+ });
10182
+ Object.defineProperty(AxisScaleSwitch.prototype, "render", {
10183
+ enumerable: false,
10184
+ configurable: true,
10185
+ writable: true,
10186
+ value: function () {
10187
+ return (React__namespace.createElement(reactBootstrap.ButtonGroup, { "aria-label": "" },
10188
+ this.toggleButton(exports.AxisScale.PERCENT, this.handlePercentClick),
10189
+ this.toggleButton(exports.AxisScale.COUNT, this.handleCountClick)));
10190
+ }
10191
+ });
10192
+ Object.defineProperty(AxisScaleSwitch.prototype, "handlePercentClick", {
10193
+ enumerable: false,
10194
+ configurable: true,
10195
+ writable: true,
10196
+ value: function () {
10197
+ this.selectedScale = exports.AxisScale.PERCENT;
10198
+ this.props.onChange(this.selectedScale);
10199
+ }
10200
+ });
10201
+ Object.defineProperty(AxisScaleSwitch.prototype, "handleCountClick", {
10202
+ enumerable: false,
10203
+ configurable: true,
10204
+ writable: true,
10205
+ value: function () {
10206
+ this.selectedScale = exports.AxisScale.COUNT;
10207
+ this.props.onChange(this.selectedScale);
10208
+ }
10209
+ });
10210
+ Object.defineProperty(AxisScaleSwitch, "defaultProps", {
10211
+ enumerable: true,
10212
+ configurable: true,
10213
+ writable: true,
10214
+ value: {
10215
+ selectedScale: exports.AxisScale.COUNT,
10216
+ }
10217
+ });
10218
+ tslib.__decorate([
10219
+ mobx.observable
10220
+ ], AxisScaleSwitch.prototype, "selectedScale", void 0);
10221
+ tslib.__decorate([
10222
+ mobx.action.bound
10223
+ ], AxisScaleSwitch.prototype, "handlePercentClick", null);
10224
+ tslib.__decorate([
10225
+ mobx.action.bound
10226
+ ], AxisScaleSwitch.prototype, "handleCountClick", null);
10227
+ AxisScaleSwitch = tslib.__decorate([
10228
+ mobxReact.observer
10229
+ ], AxisScaleSwitch);
10230
+ return AxisScaleSwitch;
10231
+ }(React__namespace.Component));
10232
+
10233
+ var PercentToggle = /** @class */ (function (_super) {
10234
+ tslib.__extends(PercentToggle, _super);
10235
+ function PercentToggle(props) {
10236
+ return _super.call(this, props) || this;
10237
+ }
10238
+ Object.defineProperty(PercentToggle.prototype, "render", {
10239
+ enumerable: false,
10240
+ configurable: true,
10241
+ writable: true,
10242
+ value: function () {
10243
+ return (React__namespace.createElement("div", { className: "small", style: { display: 'flex', alignItems: 'center' } },
10244
+ React__namespace.createElement("span", { style: { marginLeft: 10, marginRight: 10 } },
10245
+ "Y-Axis:",
10246
+ ' '),
10247
+ React__namespace.createElement(AxisScaleSwitch, { selectedScale: this.props.axisMode, onChange: this.props.onScaleToggle })));
10248
+ }
10249
+ });
10250
+ return PercentToggle;
10251
+ }(React__namespace.Component));
10252
+
10253
+ var LollipopTooltipCountInfo = function (_a) {
10254
+ var count = _a.count, mutations = _a.mutations, axisMode = _a.axisMode;
10255
+ var decimalZeros = cbioportalUtils.numberOfLeadingDecimalZeros(count);
10256
+ var fractionDigits = decimalZeros < 0 ? 1 : decimalZeros + 2;
10257
+ return mutations &&
10258
+ mutations.length > 0 &&
10259
+ axisMode === exports.AxisScale.PERCENT ? (React__namespace.createElement("strong", null,
10260
+ cbioportalUtils.formatPercentValue(count, fractionDigits),
10261
+ "% mutation rate")) : (React__namespace.createElement("strong", null,
10262
+ count,
10263
+ " mutation", "" + (count !== 1 ? 's' : '')));
10264
+ };
10265
+
10138
10266
  var DefaultStringQueryCache = /** @class */ (function () {
10139
10267
  function DefaultStringQueryCache() {
10140
10268
  Object.defineProperty(this, "_cache", {
@@ -11968,7 +12096,7 @@ var DefaultMutationMapperStore = /** @class */ (function () {
11968
12096
  var _this = this;
11969
12097
  return this.groupedMutationsByPosition.map(function (groupedMutations) { return ({
11970
12098
  group: groupedMutations.group,
11971
- counts: _this.countUniqueMutationsByPosition(groupedMutations.mutations),
12099
+ counts: _this.countUniqueMutationsByPosition(groupedMutations.mutations, groupedMutations.group),
11972
12100
  }); });
11973
12101
  },
11974
12102
  enumerable: false,
@@ -11985,7 +12113,7 @@ var DefaultMutationMapperStore = /** @class */ (function () {
11985
12113
  enumerable: false,
11986
12114
  configurable: true,
11987
12115
  writable: true,
11988
- value: function (mutationsByPosition) {
12116
+ value: function (mutationsByPosition, group) {
11989
12117
  var _this = this;
11990
12118
  var map = {};
11991
12119
  Object.keys(mutationsByPosition).forEach(function (pos) {
@@ -11993,7 +12121,7 @@ var DefaultMutationMapperStore = /** @class */ (function () {
11993
12121
  // for each position multiple mutations for the same patient is counted only once
11994
12122
  var mutations = mutationsByPosition[position];
11995
12123
  if (mutations) {
11996
- map[position] = _this.countUniqueMutations(mutations);
12124
+ map[position] = _this.countUniqueMutations(mutations, group);
11997
12125
  }
11998
12126
  });
11999
12127
  return map;
@@ -12003,7 +12131,7 @@ var DefaultMutationMapperStore = /** @class */ (function () {
12003
12131
  enumerable: false,
12004
12132
  configurable: true,
12005
12133
  writable: true,
12006
- value: function (mutations) {
12134
+ value: function (mutations, group) {
12007
12135
  // assume by default all mutations are unique
12008
12136
  // child classes need to override this method to have a custom way of counting unique mutations
12009
12137
  return this.config.getMutationCount
@@ -12881,6 +13009,7 @@ var MutationMapper = /** @class */ (function (_super) {
12881
13009
  }(React__namespace.Component));
12882
13010
 
12883
13011
  exports.Annotation = Annotation;
13012
+ exports.AxisScaleSwitch = AxisScaleSwitch;
12884
13013
  exports.BadgeLabel = BadgeLabel;
12885
13014
  exports.BadgeSelector = BadgeSelector;
12886
13015
  exports.Civic = Civic;
@@ -12922,6 +13051,7 @@ exports.Lollipop = Lollipop;
12922
13051
  exports.LollipopMutationPlot = LollipopMutationPlot;
12923
13052
  exports.LollipopPlot = LollipopPlot;
12924
13053
  exports.LollipopPlotNoTooltip = LollipopPlotNoTooltip;
13054
+ exports.LollipopTooltipCountInfo = LollipopTooltipCountInfo;
12925
13055
  exports.MSI_H_NAME = MSI_H_NAME;
12926
13056
  exports.MUTATION_COLUMNS_DEFINITION = MUTATION_COLUMNS_DEFINITION;
12927
13057
  exports.MUTATION_COLUMN_HEADERS = MUTATION_COLUMN_HEADERS;
@@ -12941,6 +13071,7 @@ exports.OncoKbFeedback = OncoKbFeedback;
12941
13071
  exports.OncoKbHelper = OncoKbHelper;
12942
13072
  exports.OncoKbTooltip = OncoKbTooltip;
12943
13073
  exports.OncoKbTreatmentTable = OncoKbTreatmentTable;
13074
+ exports.PercentToggle = PercentToggle;
12944
13075
  exports.ProteinChange = ProteinChange;
12945
13076
  exports.ProteinImpactTypeBadgeSelector = ProteinImpactTypeBadgeSelector;
12946
13077
  exports.ProteinImpactTypeDropdownSelector = ProteinImpactTypeDropdownSelector;