@sjcrh/proteinpaint-shared 2.109.1-0 → 2.109.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.109.1-0",
3
+ "version": "2.109.1",
4
4
  "description": "ProteinPaint code that is shared between server and client-side workspaces",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -7,6 +7,7 @@ Initialize a bin configuration for a numeric dataset
7
7
  */
8
8
  export default function initBinConfig(data, opts = {}) {
9
9
  if (data.find(d => !Number.isFinite(d))) throw 'non-numeric values found'
10
+
10
11
  let binConfig
11
12
  const s = new Set(data)
12
13
  if (s.size === 1) {
@@ -32,7 +32,7 @@ output:
32
32
  import { bin } from 'd3-array'
33
33
  import * as d3 from 'd3'
34
34
 
35
- export function getBinsDensity(scale, plot, isKDE = false, ticks = 20) {
35
+ export function getBinsDensity(plot, isKDE = false, ticks = 20) {
36
36
  const [valuesMin, valuesMax] = d3.extent(plot.values) //Min and max on plot
37
37
  //Commented out as it seems to be handled by kde with automatic bandwidth
38
38
  //if (valuesMin == valuesMax) return { bins: [{ x0: valuesMin, density: 1 }], densityMax: valuesMax, densityMin: 0}
@@ -48,12 +48,12 @@ export function getBinsDensity(scale, plot, isKDE = false, ticks = 20) {
48
48
  //Divided thresholds(or bins) into 3 parts, below p2nd, between p2nd and p98, above p98. This allows to handle outliers better.
49
49
  //When there are no outliers, p2nd and p98 will be the same or very close to valuesMin and valuesMax respectively
50
50
  if (p2nd > valuesMin) thresholds = [...getThresholds(valuesMin, p2nd, ticks)]
51
- if (p98 > p2nd) thresholds.push(...getThresholds(p2nd, p98, ticks))
51
+ if (p98 >= p2nd) thresholds.push(...getThresholds(p2nd, p98, ticks))
52
52
  if (p98 < valuesMax) thresholds.push(...getThresholds(p98, valuesMax, ticks))
53
53
 
54
54
  const result = isKDE
55
55
  ? kde(gaussianKernel, thresholds, plot.values, valuesMin, valuesMax)
56
- : getBinsHist(scale, plot.values, thresholds, valuesMin, valuesMax)
56
+ : getBinsHist(plot.values, thresholds, valuesMin, valuesMax)
57
57
 
58
58
  result.bins.unshift({ x0: valuesMin, density: result.densityMin }) //This allows to start the plot from min prob, avoids rendering issues
59
59
 
@@ -157,9 +157,9 @@ function silvermanBandwidth(data) {
157
157
  return h
158
158
  }
159
159
 
160
- function getBinsHist(scale, values, thresholds, valuesMin, valuesMax) {
160
+ function getBinsHist(values, thresholds, valuesMin, valuesMax) {
161
161
  const binBuilder = bin()
162
- .domain(scale.domain()) /* extent of the data that is lowest to highest*/
162
+ .domain([valuesMin, valuesMax]) /* extent of the data that is lowest to highest*/
163
163
  .thresholds(thresholds) /* buckets are created which are separated by the threshold*/
164
164
  .value(d => d) /* bin the data points into this bucket*/
165
165
  const bins0 = binBuilder(values)