@platforma-open/milaboratories.repertoire-diversity-2.model 1.1.2
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/.turbo/turbo-build.log +31 -0
- package/CHANGELOG.md +19 -0
- package/dist/bundle.js +6091 -0
- package/dist/bundle.js.map +1 -0
- package/dist/index.cjs +82 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/model.json +1 -0
- package/eslint.config.mjs +4 -0
- package/package.json +39 -0
- package/src/index.ts +130 -0
- package/tsconfig.json +16 -0
- package/vite.config.mts +20 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { GraphMakerState } from '@milaboratories/graph-maker';
|
|
2
|
+
import type { InferOutputsType, PColumnSpec, PlDataTableState, PlRef } from '@platforma-sdk/model';
|
|
3
|
+
import { BlockModel, createPFrameForGraphs, createPlDataTable, isPColumnSpec } from '@platforma-sdk/model';
|
|
4
|
+
|
|
5
|
+
export type DiversityType = 'chao1' | 'd50' | 'efronThisted' |
|
|
6
|
+
'observed' | 'shannonWienerIndex' | 'shannonWiener' |
|
|
7
|
+
'normalizedShannonWiener' | 'inverseSimpson' | 'gini';
|
|
8
|
+
|
|
9
|
+
export type Metric = {
|
|
10
|
+
type: DiversityType | undefined;
|
|
11
|
+
downsampling: {
|
|
12
|
+
type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;
|
|
13
|
+
valueChooser?: 'min' | 'fixed' | 'max' | 'auto';
|
|
14
|
+
n?: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type BlockArgs = {
|
|
19
|
+
abundanceRef?: PlRef;
|
|
20
|
+
metrics: Metric[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type UiState = {
|
|
24
|
+
blockTitle: string;
|
|
25
|
+
tableState?: PlDataTableState;
|
|
26
|
+
graphState: GraphMakerState;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function isNumericType(c: PColumnSpec): boolean {
|
|
30
|
+
return c.valueType === 'Double' || c.valueType === 'Int' || c.valueType === 'Float' || c.valueType === 'Long';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const model = BlockModel.create()
|
|
34
|
+
|
|
35
|
+
.withArgs<BlockArgs>({
|
|
36
|
+
metrics: [
|
|
37
|
+
{
|
|
38
|
+
type: 'observed',
|
|
39
|
+
downsampling: {
|
|
40
|
+
type: 'hypergeometric',
|
|
41
|
+
valueChooser: 'auto',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'shannonWiener',
|
|
46
|
+
downsampling: {
|
|
47
|
+
type: 'hypergeometric',
|
|
48
|
+
valueChooser: 'auto',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: 'chao1',
|
|
53
|
+
downsampling: {
|
|
54
|
+
type: 'hypergeometric',
|
|
55
|
+
valueChooser: 'auto',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'gini',
|
|
60
|
+
downsampling: {
|
|
61
|
+
type: 'hypergeometric',
|
|
62
|
+
valueChooser: 'auto',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'd50',
|
|
67
|
+
downsampling: {
|
|
68
|
+
type: 'hypergeometric',
|
|
69
|
+
valueChooser: 'auto',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
.withUiState<UiState>({
|
|
76
|
+
blockTitle: 'Repertoire Diversity',
|
|
77
|
+
graphState: {
|
|
78
|
+
title: 'Repertoire Diversity',
|
|
79
|
+
template: 'bar',
|
|
80
|
+
currentTab: null,
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
tableState: {
|
|
84
|
+
gridState: {},
|
|
85
|
+
pTableParams: {
|
|
86
|
+
sorting: [],
|
|
87
|
+
filters: [],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
.argsValid((ctx) => ctx.args.abundanceRef !== undefined)
|
|
93
|
+
|
|
94
|
+
.output('abundanceOptions', (ctx) =>
|
|
95
|
+
ctx.resultPool.getOptions((c) =>
|
|
96
|
+
isPColumnSpec(c) && isNumericType(c)
|
|
97
|
+
&& c.annotations?.['pl7.app/isAbundance'] === 'true'
|
|
98
|
+
&& c.annotations?.['pl7.app/abundance/normalized'] === 'false',
|
|
99
|
+
))
|
|
100
|
+
|
|
101
|
+
.output('pt', (ctx) => {
|
|
102
|
+
const pCols = ctx.outputs?.resolve('pf')?.getPColumns();
|
|
103
|
+
if (pCols === undefined) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return createPlDataTable(ctx, pCols, ctx.uiState?.tableState);
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
.output('pf', (ctx) => {
|
|
111
|
+
const pCols = ctx.outputs?.resolve('pf')?.getPColumns();
|
|
112
|
+
if (pCols === undefined) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return createPFrameForGraphs(ctx, pCols);
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
.output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)
|
|
120
|
+
|
|
121
|
+
.title((ctx) => ctx.uiState?.blockTitle ?? 'Repertoire Diversity')
|
|
122
|
+
|
|
123
|
+
.sections((_) => [
|
|
124
|
+
{ type: 'link', href: '/', label: 'Main' },
|
|
125
|
+
{ type: 'link', href: '/diversityGraph', label: 'Diversity Graph' },
|
|
126
|
+
])
|
|
127
|
+
|
|
128
|
+
.done();
|
|
129
|
+
|
|
130
|
+
export type BlockOutputs = InferOutputsType<typeof model>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"types": [],
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
build: {
|
|
5
|
+
emptyOutDir: false,
|
|
6
|
+
lib: {
|
|
7
|
+
entry: 'src/index.ts',
|
|
8
|
+
name: 'model',
|
|
9
|
+
fileName: (format) => `my-lib.${format}.js`
|
|
10
|
+
},
|
|
11
|
+
minify: false,
|
|
12
|
+
sourcemap: true,
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
output: {
|
|
15
|
+
format: 'iife',
|
|
16
|
+
entryFileNames: 'bundle.js'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|