@datagrok/bio 2.11.22 → 2.11.23

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
@@ -5,7 +5,7 @@
5
5
  "name": "Leonid Stolbov",
6
6
  "email": "lstolbov@datagrok.ai"
7
7
  },
8
- "version": "2.11.22",
8
+ "version": "2.11.23",
9
9
  "description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -39,6 +39,7 @@
39
39
  "@datagrok-libraries/ml": "^6.3.68",
40
40
  "@datagrok-libraries/tutorials": "^1.3.11",
41
41
  "@datagrok-libraries/utils": "^4.1.36",
42
+ "@datagrok-libraries/math": "^1.0.7",
42
43
  "cash-dom": "^8.0.0",
43
44
  "css-loader": "^6.7.3",
44
45
  "datagrok-api": "^1.16.0",
@@ -3,13 +3,11 @@ import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
4
 
5
5
  import {_package} from '../package';
6
-
7
- import * as lev from 'fastest-levenshtein';
8
- import {DistanceMatrix} from '@datagrok-libraries/ml/src/distance-matrix';
9
6
  import {getTreeHelper, ITreeHelper} from '@datagrok-libraries/bio/src/trees/tree-helper';
10
7
  import {getDendrogramService, IDendrogramService} from '@datagrok-libraries/bio/src/trees/dendrogram';
11
8
  import {demoSequenceSpace, handleError} from './utils';
12
9
  import {DemoScript} from '@datagrok-libraries/tutorials/src/demo-script';
10
+ import {getClusterMatrixWorker} from '@datagrok-libraries/math';
13
11
 
14
12
  const dataFn = 'data/sample_FASTA_PT_activity.csv';
15
13
  const seqColName = 'sequence';
@@ -55,13 +53,11 @@ export async function demoBio01aUI() {
55
53
  delay: 2000,
56
54
  })
57
55
  .step('Cluster sequences', async () => {
58
- const seqCol: DG.Column<string> = df.getCol(seqColName);
59
- const seqList = seqCol.toList();
60
- const distance: DistanceMatrix = DistanceMatrix.calc(seqList, (aSeq: string, bSeq: string) => {
61
- const levDistance = lev.distance(aSeq, bSeq);
62
- return levDistance / ((aSeq.length + bSeq.length) / 2);
63
- });
64
- const treeRoot = await treeHelper.hierarchicalClusteringByDistance(distance, 'ward');
56
+ const distance = await treeHelper.calcDistanceMatrix(df, [seqColName]);
57
+ const clusterMatrix = await getClusterMatrixWorker(
58
+ distance!.data, df.rowCount, 1,
59
+ );
60
+ const treeRoot = treeHelper.parseClusterMatrix(clusterMatrix);
65
61
  dendrogramSvc.injectTreeForGrid(view.grid, treeRoot, undefined, 150, undefined);
66
62
  }, {
67
63
  description: `Perform hierarchical clustering to reveal relationships between sequences.`,
@@ -6,14 +6,13 @@ import {_package, activityCliffs} from '../package';
6
6
  import $ from 'cash-dom';
7
7
 
8
8
  import {TEMPS as acTEMPS} from '@datagrok-libraries/ml/src/viewers/activity-cliffs';
9
- import * as lev from 'fastest-levenshtein';
10
- import {DistanceMatrix} from '@datagrok-libraries/ml/src/distance-matrix';
11
9
  import {getTreeHelper, ITreeHelper} from '@datagrok-libraries/bio/src/trees/tree-helper';
12
10
  import {getDendrogramService, IDendrogramService} from '@datagrok-libraries/bio/src/trees/dendrogram';
13
11
  import {handleError} from './utils';
14
12
  import {DemoScript} from '@datagrok-libraries/tutorials/src/demo-script';
15
13
  import {DimReductionMethods} from '@datagrok-libraries/ml/src/reduce-dimensionality';
16
14
  import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule-distance-functions';
15
+ import {getClusterMatrixWorker} from '@datagrok-libraries/math';
17
16
 
18
17
  const dataFn: string = 'data/sample_FASTA_PT_activity.csv';
19
18
 
@@ -67,13 +66,12 @@ export async function demoBio01bUI() {
67
66
  })
68
67
  .step('Cluster sequences', async () => {
69
68
  const progressBar = DG.TaskBarProgressIndicator.create(`Running sequence clustering...`);
70
- const seqCol: DG.Column<string> = df.getCol('sequence');
71
- const seqList = seqCol.toList();
72
- const distance: DistanceMatrix = DistanceMatrix.calc(seqList, (aSeq: string, bSeq: string) => {
73
- const levDistance = lev.distance(aSeq, bSeq);
74
- return levDistance / ((aSeq.length + bSeq.length) / 2);
75
- });
76
- const treeRoot = await treeHelper.hierarchicalClusteringByDistance(distance, 'ward');
69
+
70
+ const distance = await treeHelper.calcDistanceMatrix(df, ['sequence']);
71
+ const clusterMatrix = await getClusterMatrixWorker(
72
+ distance!.data, df.rowCount, 1,
73
+ );
74
+ const treeRoot = treeHelper.parseClusterMatrix(clusterMatrix);
77
75
  progressBar.close();
78
76
  dendrogramSvc.injectTreeForGrid(view.grid, treeRoot, undefined, 150, undefined);
79
77
 
@@ -294,6 +294,10 @@ enum WlRenderLevel {
294
294
  Freqs = 2,
295
295
  }
296
296
 
297
+ export const Debounces = new class {
298
+ render: number = 20;
299
+ }();
300
+
297
301
  const POSITION_LABELS_HEIGHT: number = 12;
298
302
 
299
303
  export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
@@ -507,7 +511,7 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
507
511
  const dataFrameTxt: string = this.dataFrame ? 'data' : 'null';
508
512
  _package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${dataFrameTxt} ) start`);
509
513
  const dpr = window.devicePixelRatio;
510
- this.viewSubs.push(DG.debounce(this.renderRequest)
514
+ this.viewSubs.push(DG.debounce(this.renderRequest, Debounces.render)
511
515
  .subscribe(this.renderRequestOnDebounce.bind(this)));
512
516
 
513
517
  this.helpUrl = '/help/visualize/viewers/web-logo.md';