@datagrok/peptides 1.17.8 → 1.17.10
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/CHANGELOG.md +8 -0
- package/dist/package-test.js +2 -2
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/src/model.ts +86 -59
- package/src/utils/statistics.ts +1 -1
- package/src/viewers/logo-summary.ts +9 -6
- package/src/widgets/peptides.ts +3 -1
package/package.json
CHANGED
package/src/model.ts
CHANGED
|
@@ -450,43 +450,49 @@ export class PeptidesModel {
|
|
|
450
450
|
|
|
451
451
|
if (filterAndSelectionBs.anyTrue) {
|
|
452
452
|
acc.addPane('Actions', () => {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return ui.divV([newView]);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const newCluster = ui.label('New cluster');
|
|
463
|
-
$(newCluster).addClass('d4-link-action');
|
|
464
|
-
newCluster.onclick = (): void => {
|
|
453
|
+
try {
|
|
454
|
+
const newView = ui.label('New view');
|
|
455
|
+
$(newView).addClass('d4-link-action');
|
|
456
|
+
newView.onclick = (): string => trueModel.createNewView();
|
|
457
|
+
newView.onmouseover = (ev): void =>
|
|
458
|
+
ui.tooltip.show('Creates a new view from current selection', ev.clientX + 5, ev.clientY + 5);
|
|
465
459
|
if (trueLSTViewer === null)
|
|
466
|
-
|
|
460
|
+
return ui.divV([newView]);
|
|
467
461
|
|
|
468
462
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
463
|
+
const newCluster = ui.label('New cluster');
|
|
464
|
+
$(newCluster).addClass('d4-link-action');
|
|
465
|
+
newCluster.onclick = (): void => {
|
|
466
|
+
if (trueLSTViewer === null)
|
|
467
|
+
throw new Error('Logo summary table viewer is not found');
|
|
473
468
|
|
|
474
|
-
const removeCluster = ui.label('Remove cluster');
|
|
475
|
-
$(removeCluster).addClass('d4-link-action');
|
|
476
|
-
removeCluster.onclick = (): void => {
|
|
477
|
-
const lstViewer = trueModel.findViewer(VIEWER_TYPE.LOGO_SUMMARY_TABLE) as LogoSummaryTable | null;
|
|
478
|
-
if (lstViewer === null)
|
|
479
|
-
throw new Error('Logo summary table viewer is not found');
|
|
480
469
|
|
|
470
|
+
trueLSTViewer.clusterFromSelection();
|
|
471
|
+
};
|
|
472
|
+
newCluster.onmouseover = (ev): void =>
|
|
473
|
+
ui.tooltip.show('Creates a new cluster from selection', ev.clientX + 5, ev.clientY + 5);
|
|
474
|
+
|
|
475
|
+
const removeCluster = ui.label('Remove cluster');
|
|
476
|
+
$(removeCluster).addClass('d4-link-action');
|
|
477
|
+
removeCluster.onclick = (): void => {
|
|
478
|
+
const lstViewer = trueModel.findViewer(VIEWER_TYPE.LOGO_SUMMARY_TABLE) as LogoSummaryTable | null;
|
|
479
|
+
if (lstViewer === null)
|
|
480
|
+
throw new Error('Logo summary table viewer is not found');
|
|
481
481
|
|
|
482
|
-
lstViewer.removeCluster();
|
|
483
|
-
};
|
|
484
|
-
removeCluster.onmouseover = (ev): void =>
|
|
485
|
-
ui.tooltip.show('Removes currently selected custom cluster', ev.clientX + 5, ev.clientY + 5);
|
|
486
|
-
removeCluster.style.visibility = trueLSTViewer.clusterSelection[CLUSTER_TYPE.CUSTOM].length === 0 ? 'hidden' :
|
|
487
|
-
'visible';
|
|
488
482
|
|
|
489
|
-
|
|
483
|
+
lstViewer.removeCluster();
|
|
484
|
+
};
|
|
485
|
+
removeCluster.onmouseover = (ev): void =>
|
|
486
|
+
ui.tooltip.show('Removes currently selected custom cluster', ev.clientX + 5, ev.clientY + 5);
|
|
487
|
+
removeCluster.style.visibility = trueLSTViewer.clusterSelection[CLUSTER_TYPE.CUSTOM].length === 0 ? 'hidden' :
|
|
488
|
+
'visible';
|
|
489
|
+
|
|
490
|
+
return ui.divV([newView, newCluster, removeCluster]);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
const errorDiv = ui.divText('Error in Actions');
|
|
493
|
+
ui.tooltip.bind(errorDiv, String(e));
|
|
494
|
+
return errorDiv;
|
|
495
|
+
}
|
|
490
496
|
}, true);
|
|
491
497
|
}
|
|
492
498
|
|
|
@@ -558,16 +564,24 @@ export class PeptidesModel {
|
|
|
558
564
|
(requestSource instanceof MonomerPosition) ? requestSource.invariantMapSelection : {};
|
|
559
565
|
const clusterSelection = (requestSource instanceof LogoSummaryTable) ? requestSource.clusterSelection :
|
|
560
566
|
trueLSTViewer?.clusterSelection ?? {};
|
|
561
|
-
acc.addPane('Distribution', () =>
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
567
|
+
acc.addPane('Distribution', () => {
|
|
568
|
+
try {
|
|
569
|
+
return getDistributionWidget(trueModel.df, {
|
|
570
|
+
peptideSelection: combinedBitset,
|
|
571
|
+
columns: isModelSource ? trueModel.settings!.columns ?? {} :
|
|
572
|
+
(requestSource as PeptideViewer).getAggregationColumns(),
|
|
573
|
+
activityCol: isModelSource ? trueModel.getScaledActivityColumn()! :
|
|
574
|
+
(requestSource as PeptideViewer).getScaledActivityColumn(),
|
|
575
|
+
monomerPositionSelection: totalMonomerPositionSelection,
|
|
576
|
+
clusterSelection: clusterSelection,
|
|
577
|
+
clusterColName: trueLSTViewer?.clustersColumnName,
|
|
578
|
+
});
|
|
579
|
+
} catch (e) {
|
|
580
|
+
const errorDiv = ui.divText('Error in Distribution');
|
|
581
|
+
ui.tooltip.bind(errorDiv, String(e));
|
|
582
|
+
return errorDiv;
|
|
583
|
+
}
|
|
584
|
+
}, true);
|
|
571
585
|
const areObjectsEqual = (o1?: AggregationColumns | null, o2?: AggregationColumns | null): boolean => {
|
|
572
586
|
if (o1 == null || o2 == null)
|
|
573
587
|
return false;
|
|
@@ -579,20 +593,28 @@ export class PeptidesModel {
|
|
|
579
593
|
}
|
|
580
594
|
return true;
|
|
581
595
|
};
|
|
582
|
-
acc.addPane('Selection', () =>
|
|
583
|
-
|
|
584
|
-
(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
596
|
+
acc.addPane('Selection', () => {
|
|
597
|
+
try {
|
|
598
|
+
return getSelectionWidget(trueModel.df, {
|
|
599
|
+
positionColumns: isModelSource ? trueModel.positionColumns! :
|
|
600
|
+
(requestSource as SARViewer | LogoSummaryTable).positionColumns,
|
|
601
|
+
columns: isModelSource ? trueModel.settings!.columns ?? {} :
|
|
602
|
+
(requestSource as SARViewer | LogoSummaryTable).getAggregationColumns(),
|
|
603
|
+
activityColumn: isModelSource ? trueModel.getScaledActivityColumn()! :
|
|
604
|
+
(requestSource as SARViewer | LogoSummaryTable).getScaledActivityColumn(),
|
|
605
|
+
gridColumns: trueModel.analysisView.grid.columns,
|
|
606
|
+
colorPalette: pickUpPalette(trueModel.df.getCol(isModelSource ? trueModel.settings!.sequenceColumnName :
|
|
607
|
+
(requestSource as SARViewer | LogoSummaryTable).sequenceColumnName)),
|
|
608
|
+
tableSelection: trueModel.getCombinedSelection(),
|
|
609
|
+
isAnalysis: trueModel.settings !== null && (isModelSource ||
|
|
594
610
|
areObjectsEqual(trueModel.settings.columns, (requestSource as PeptideViewer).getAggregationColumns())),
|
|
595
|
-
|
|
611
|
+
});
|
|
612
|
+
} catch (e) {
|
|
613
|
+
const errorDiv = ui.divText('Error in Selection');
|
|
614
|
+
ui.tooltip.bind(errorDiv, String(e));
|
|
615
|
+
return errorDiv;
|
|
616
|
+
}
|
|
617
|
+
}, true);
|
|
596
618
|
return acc;
|
|
597
619
|
}
|
|
598
620
|
|
|
@@ -793,12 +815,16 @@ export class PeptidesModel {
|
|
|
793
815
|
const filter = this.df.filter;
|
|
794
816
|
|
|
795
817
|
const showAccordion = (): void => {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
818
|
+
try {
|
|
819
|
+
const acc = this.createAccordion();
|
|
820
|
+
if (acc === null)
|
|
821
|
+
return;
|
|
799
822
|
|
|
800
823
|
|
|
801
|
-
|
|
824
|
+
grok.shell.o = acc.root;
|
|
825
|
+
} catch (e) {
|
|
826
|
+
console.error(e);
|
|
827
|
+
}
|
|
802
828
|
};
|
|
803
829
|
|
|
804
830
|
selection.onChanged.subscribe(() => {
|
|
@@ -825,7 +851,8 @@ export class PeptidesModel {
|
|
|
825
851
|
}
|
|
826
852
|
const lstViewer = this.findViewer(VIEWER_TYPE.LOGO_SUMMARY_TABLE) as LogoSummaryTable | null;
|
|
827
853
|
if (lstViewer !== null && typeof lstViewer.model !== 'undefined') {
|
|
828
|
-
lstViewer.
|
|
854
|
+
lstViewer._logoSummaryTable = lstViewer.createLogoSummaryTable() ?? lstViewer._logoSummaryTable;
|
|
855
|
+
lstViewer._viewerGrid = lstViewer.createLogoSummaryTableGrid() ?? lstViewer._viewerGrid;
|
|
829
856
|
lstViewer.render();
|
|
830
857
|
}
|
|
831
858
|
} catch (e) {
|
|
@@ -1178,7 +1205,7 @@ export class PeptidesModel {
|
|
|
1178
1205
|
const epsilon = this.settings!.sequenceSpaceParams!.epsilon ?? 0.01;
|
|
1179
1206
|
const minPts = this.settings!.sequenceSpaceParams!.minPts ?? 4;
|
|
1180
1207
|
const clusterRes = await getDbscanWorker(embed1, embed2, epsilon, minPts);
|
|
1181
|
-
const newClusterName = this.df.columns.getUnusedName('Cluster');
|
|
1208
|
+
const newClusterName = this.df.columns.getUnusedName('Cluster (DBSCAN)');
|
|
1182
1209
|
const clusterCol = this.df.columns.addNewString(newClusterName);
|
|
1183
1210
|
clusterCol.init((i) => clusterRes[i].toString());
|
|
1184
1211
|
if (this._sequenceSpaceViewer !== null)
|
package/src/utils/statistics.ts
CHANGED
|
@@ -47,7 +47,7 @@ export function getStats(data: RawData | number[], bitArray: BitArray): StatsIte
|
|
|
47
47
|
throw new Error('PeptidesError: Data and bit array have different lengths');
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
if (bitArray.
|
|
50
|
+
if (bitArray.trueCount() === 0)
|
|
51
51
|
throw new Error('PeptidesError: One of the samples is empty');
|
|
52
52
|
|
|
53
53
|
|
|
@@ -375,6 +375,8 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
375
375
|
this._logoSummaryTable = null;
|
|
376
376
|
doRender = true;
|
|
377
377
|
break;
|
|
378
|
+
case LST_PROPERTIES.WEB_LOGO_MODE:
|
|
379
|
+
this.viewerGrid.invalidate();
|
|
378
380
|
}
|
|
379
381
|
if (doRender)
|
|
380
382
|
this.render();
|
|
@@ -467,7 +469,7 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
467
469
|
const customClustCol = customClustColList[rowIdx];
|
|
468
470
|
customLSTClustCol.set(rowIdx, customClustCol.name);
|
|
469
471
|
const bitArray = BitArray.fromUint32Array(filteredDfRowCount, customClustCol.getRawData() as Uint32Array);
|
|
470
|
-
if (bitArray.allFalse
|
|
472
|
+
if (bitArray.allFalse)
|
|
471
473
|
continue;
|
|
472
474
|
|
|
473
475
|
|
|
@@ -495,10 +497,12 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
495
497
|
const origLST = origLSTBuilder.aggregate();
|
|
496
498
|
const origLSTLen = origLST.rowCount;
|
|
497
499
|
const origLSTCols = origLST.columns;
|
|
498
|
-
|
|
500
|
+
let origLSTClustCol: DG.Column<string> = origLST.getCol(clustersColName);
|
|
499
501
|
origLSTClustCol.name = C.LST_COLUMN_NAMES.CLUSTER;
|
|
500
|
-
if (origLSTClustCol.type !== DG.COLUMN_TYPE.STRING)
|
|
502
|
+
if (origLSTClustCol.type !== DG.COLUMN_TYPE.STRING) {
|
|
501
503
|
origLST.columns.replace(origLSTClustCol, origLSTClustCol.convertTo(DG.COLUMN_TYPE.STRING));
|
|
504
|
+
origLSTClustCol = origLST.getCol(origLSTClustCol.name);
|
|
505
|
+
}
|
|
502
506
|
|
|
503
507
|
|
|
504
508
|
const origLSTClustColCat = origLSTClustCol.categories;
|
|
@@ -515,15 +519,14 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
515
519
|
for (let rowIdx = 0; rowIdx < filteredDfRowCount; ++rowIdx) {
|
|
516
520
|
const filteredClustName = filteredDfClustColCat[filteredDfClustColData[rowIdx]];
|
|
517
521
|
const origClustIdx = origLSTClustColCat.indexOf(filteredClustName);
|
|
518
|
-
origClustMasks[origClustIdx]
|
|
522
|
+
origClustMasks[origClustIdx]?.setTrue(rowIdx);
|
|
519
523
|
}
|
|
520
524
|
|
|
521
525
|
for (let rowIdx = 0; rowIdx < origLSTLen; ++rowIdx) {
|
|
522
526
|
const mask = origClustMasks[rowIdx];
|
|
523
|
-
if (mask.allFalse
|
|
527
|
+
if (mask.allFalse)
|
|
524
528
|
continue;
|
|
525
529
|
|
|
526
|
-
|
|
527
530
|
const bsMask = DG.BitSet.fromBytes(mask.buffer.buffer, filteredDfRowCount);
|
|
528
531
|
const stats = isDfFiltered ? getStats(activityColData, mask) :
|
|
529
532
|
this.clusterStats[CLUSTER_TYPE.ORIGINAL][origLSTClustColCat[rowIdx]];
|
package/src/widgets/peptides.ts
CHANGED
|
@@ -185,7 +185,9 @@ export async function startAnalysis(activityColumn: DG.Column<number>, peptidesC
|
|
|
185
185
|
clustersColumn: DG.Column | null, sourceDf: DG.DataFrame, scaledCol: DG.Column<number>, scaling: C.SCALING_METHODS,
|
|
186
186
|
options: AnalysisOptions = {}): Promise<PeptidesModel | null> {
|
|
187
187
|
let model: PeptidesModel | null = null;
|
|
188
|
-
if (activityColumn.type !== DG.COLUMN_TYPE.FLOAT && activityColumn.type !== DG.COLUMN_TYPE.INT &&
|
|
188
|
+
if (activityColumn.type !== DG.COLUMN_TYPE.FLOAT && activityColumn.type !== DG.COLUMN_TYPE.INT &&
|
|
189
|
+
activityColumn.type !== DG.COLUMN_TYPE.QNUM
|
|
190
|
+
) {
|
|
189
191
|
grok.shell.error('The activity column must be of numeric type!');
|
|
190
192
|
return model;
|
|
191
193
|
}
|