@platforma-open/milaboratories.vj-usage.model 2.0.0
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 +13 -0
- package/dist/bundle.js +6047 -0
- package/dist/bundle.js.map +1 -0
- package/dist/index.cjs +73 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +71 -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 +109 -0
- package/tsconfig.json +16 -0
- package/vite.config.mts +20 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { GraphMakerState } from '@milaboratories/graph-maker';
|
|
2
|
+
import type { InferOutputsType, PlRef, SUniversalPColumnId } from '@platforma-sdk/model';
|
|
3
|
+
import { BlockModel, createPFrameForGraphs, isPColumnSpec } from '@platforma-sdk/model';
|
|
4
|
+
|
|
5
|
+
export type BlockArgs = {
|
|
6
|
+
vGeneRef?: PlRef;
|
|
7
|
+
jGeneRef?: SUniversalPColumnId;
|
|
8
|
+
abundanceRef?: SUniversalPColumnId;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type UiState = {
|
|
12
|
+
blockTitle: string;
|
|
13
|
+
weightedFlag: boolean;
|
|
14
|
+
vUsagePlotState: GraphMakerState;
|
|
15
|
+
jUsagePlotState: GraphMakerState;
|
|
16
|
+
vjUsagePlotState: GraphMakerState;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const model = BlockModel.create()
|
|
20
|
+
|
|
21
|
+
.withArgs<BlockArgs>({})
|
|
22
|
+
|
|
23
|
+
.withUiState<UiState>({
|
|
24
|
+
blockTitle: 'V/J Usage',
|
|
25
|
+
weightedFlag: true,
|
|
26
|
+
vUsagePlotState: {
|
|
27
|
+
title: 'V Usage',
|
|
28
|
+
template: 'heatmap',
|
|
29
|
+
currentTab: 'settings',
|
|
30
|
+
},
|
|
31
|
+
jUsagePlotState: {
|
|
32
|
+
title: 'V Usage',
|
|
33
|
+
template: 'heatmap',
|
|
34
|
+
currentTab: null,
|
|
35
|
+
},
|
|
36
|
+
vjUsagePlotState: {
|
|
37
|
+
title: 'V/J Usage',
|
|
38
|
+
template: 'heatmap',
|
|
39
|
+
currentTab: null,
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
.argsValid((ctx) =>
|
|
44
|
+
ctx.args.vGeneRef !== undefined
|
|
45
|
+
&& ctx.args.jGeneRef !== undefined
|
|
46
|
+
&& ctx.args.abundanceRef !== undefined,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
.output('vGeneOptions', (ctx) =>
|
|
50
|
+
ctx.resultPool.getOptions((c) =>
|
|
51
|
+
isPColumnSpec(c) && c.valueType === 'String'
|
|
52
|
+
&& (c.name === 'pl7.app/vdj/geneHit' || c.name === 'pl7.app/vdj/geneHitWithAllele')
|
|
53
|
+
&& c.domain?.['pl7.app/vdj/reference'] === 'VGene',
|
|
54
|
+
))
|
|
55
|
+
|
|
56
|
+
.output('jGeneOptions', (ctx) => {
|
|
57
|
+
const inputRef = ctx.args.vGeneRef;
|
|
58
|
+
if (inputRef === undefined) return undefined;
|
|
59
|
+
const vGeneSpec = ctx.resultPool.getPColumnSpecByRef(inputRef);
|
|
60
|
+
if (vGeneSpec === undefined) return undefined;
|
|
61
|
+
return ctx.resultPool.getCanonicalOptions({ main: inputRef }, [
|
|
62
|
+
{
|
|
63
|
+
axes: [{ anchor: 'main', idx: 0 }],
|
|
64
|
+
name: vGeneSpec.name,
|
|
65
|
+
domain: {
|
|
66
|
+
'pl7.app/vdj/reference': 'JGene',
|
|
67
|
+
'pl7.app/vdj/scClonotypeChain': { anchor: 'main' },
|
|
68
|
+
'pl7.app/vdj/scClonotypeChain/index': { anchor: 'main' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
], { ignoreMissingDomains: true });
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
.output('abundanceOptions', (ctx) => {
|
|
75
|
+
const inputRef = ctx.args.vGeneRef;
|
|
76
|
+
if (inputRef === undefined) return undefined;
|
|
77
|
+
return ctx.resultPool.getCanonicalOptions({ main: inputRef },
|
|
78
|
+
{
|
|
79
|
+
axes: [{/* sampleId */}, { anchor: 'main', idx: 0 }],
|
|
80
|
+
annotations: {
|
|
81
|
+
'pl7.app/isAbundance': 'true',
|
|
82
|
+
'pl7.app/abundance/normalized': 'false',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
.output('pf', (ctx) => {
|
|
89
|
+
const pCols = ctx.outputs?.resolve('pf')?.getPColumns();
|
|
90
|
+
if (pCols === undefined) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return createPFrameForGraphs(ctx, pCols);
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
.output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)
|
|
98
|
+
|
|
99
|
+
.title((ctx) => ctx.uiState?.blockTitle ?? 'V/J Usage')
|
|
100
|
+
|
|
101
|
+
.sections((_) => [
|
|
102
|
+
{ type: 'link', href: '/', label: 'V Gene Usage' },
|
|
103
|
+
{ type: 'link', href: '/jUsage', label: 'J Gene Usage' },
|
|
104
|
+
{ type: 'link', href: '/vjUsage', label: 'V/J Gene Usage' },
|
|
105
|
+
])
|
|
106
|
+
|
|
107
|
+
.done();
|
|
108
|
+
|
|
109
|
+
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
|
+
});
|