@sjcrh/proteinpaint-shared 2.186.0 → 2.188.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/README.md +10 -2
- package/constants/AiHisto.ts +27 -0
- package/constants/README.md +11 -0
- package/devTs.ts +3 -0
- package/dist/constants/AiHisto.d.ts +23 -0
- package/dist/constants/AiHisto.js +31 -0
- package/dist/constants/AiHisto.js.map +7 -0
- package/dist/src/aiHisto.d.ts +5 -0
- package/dist/src/aiHisto.js +15 -0
- package/dist/src/aiHisto.js.map +7 -0
- package/dist/src/bulk.cnv.js +83 -0
- package/dist/src/bulk.cnv.js.map +7 -0
- package/dist/src/bulk.del.js +119 -0
- package/dist/src/bulk.del.js.map +7 -0
- package/dist/src/bulk.itd.js +119 -0
- package/dist/src/bulk.itd.js.map +7 -0
- package/dist/src/bulk.js +183 -0
- package/dist/src/bulk.js.map +7 -0
- package/dist/src/bulk.snv.js +175 -0
- package/dist/src/bulk.snv.js.map +7 -0
- package/dist/src/bulk.sv.js +266 -0
- package/dist/src/bulk.sv.js.map +7 -0
- package/dist/src/bulk.svjson.js +151 -0
- package/dist/src/bulk.svjson.js.map +7 -0
- package/dist/src/bulk.trunc.js +122 -0
- package/dist/src/bulk.trunc.js.map +7 -0
- package/dist/src/clustering.js +71 -0
- package/dist/src/clustering.js.map +7 -0
- package/dist/src/common.js +1302 -0
- package/dist/src/common.js.map +7 -0
- package/dist/src/compute.percentile.js +10 -0
- package/dist/src/compute.percentile.js.map +7 -0
- package/dist/src/doc.d.ts +7 -0
- package/dist/src/doc.js +10 -0
- package/dist/src/doc.js.map +7 -0
- package/dist/src/fetch-helpers.js +177 -0
- package/dist/src/fetch-helpers.js.map +7 -0
- package/dist/src/fileSize.js +10 -0
- package/dist/src/fileSize.js.map +7 -0
- package/dist/src/filter.d.ts +62 -0
- package/dist/src/filter.js +194 -0
- package/dist/src/filter.js.map +7 -0
- package/dist/src/hash.js +20 -0
- package/dist/src/hash.js.map +7 -0
- package/dist/src/helpers.js +66 -0
- package/dist/src/helpers.js.map +7 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.js +27 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/joinUrl.d.ts +1 -0
- package/dist/src/joinUrl.js +17 -0
- package/dist/src/joinUrl.js.map +7 -0
- package/dist/src/mds3tk.js +64 -0
- package/dist/src/mds3tk.js.map +7 -0
- package/dist/src/roundValue.js +57 -0
- package/dist/src/roundValue.js.map +7 -0
- package/dist/src/termdb.bins.js +272 -0
- package/dist/src/termdb.bins.js.map +7 -0
- package/dist/src/termdb.initbinconfig.js +79 -0
- package/dist/src/termdb.initbinconfig.js.map +7 -0
- package/dist/src/termdb.usecase.js +239 -0
- package/dist/src/termdb.usecase.js.map +7 -0
- package/dist/src/terms.d.ts +83 -0
- package/dist/src/terms.js +327 -0
- package/dist/src/terms.js.map +7 -0
- package/dist/src/time.d.ts +9 -0
- package/dist/src/time.js +23 -0
- package/dist/src/time.js.map +7 -0
- package/dist/src/tree.js +82 -0
- package/dist/src/tree.js.map +7 -0
- package/dist/src/urljson.d.ts +8 -0
- package/dist/src/urljson.js +31 -0
- package/dist/src/urljson.js.map +7 -0
- package/dist/src/vcf.ann.js +56 -0
- package/dist/src/vcf.ann.js.map +7 -0
- package/dist/src/vcf.csq.js +82 -0
- package/dist/src/vcf.csq.js.map +7 -0
- package/dist/src/vcf.info.js +40 -0
- package/dist/src/vcf.info.js.map +7 -0
- package/dist/src/vcf.js +439 -0
- package/dist/src/vcf.js.map +7 -0
- package/dist/src/vcf.type.js +17 -0
- package/dist/src/vcf.type.js.map +7 -0
- package/package.json +20 -11
- package/src/bulk.cnv.js +0 -86
- package/src/bulk.del.js +0 -124
- package/src/bulk.itd.js +0 -123
- package/src/bulk.js +0 -197
- package/src/bulk.snv.js +0 -271
- package/src/bulk.sv.js +0 -276
- package/src/bulk.svjson.js +0 -164
- package/src/bulk.trunc.js +0 -132
- package/src/clustering.js +0 -66
- package/src/common.js +0 -1608
- package/src/compute.percentile.js +0 -11
- package/src/doc.js +0 -6
- package/src/fetch-helpers.js +0 -323
- package/src/fileSize.js +0 -6
- package/src/filter.js +0 -221
- package/src/hash.js +0 -21
- package/src/helpers.js +0 -88
- package/src/index.js +0 -26
- package/src/joinUrl.js +0 -14
- package/src/mds3tk.js +0 -100
- package/src/roundValue.js +0 -94
- package/src/termdb.bins.js +0 -456
- package/src/termdb.initbinconfig.js +0 -130
- package/src/termdb.usecase.js +0 -317
- package/src/terms.js +0 -341
- package/src/time.js +0 -22
- package/src/tree.js +0 -138
- package/src/urljson.js +0 -41
- package/src/vcf.ann.js +0 -62
- package/src/vcf.csq.js +0 -153
- package/src/vcf.info.js +0 -50
- package/src/vcf.js +0 -654
- package/src/vcf.type.js +0 -24
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Initialize a bin configuration for a numeric dataset
|
|
3
|
-
<data>: array of numeric data values
|
|
4
|
-
<opts> (optional): object of options
|
|
5
|
-
{}: output bin config as JavaScript object (default)
|
|
6
|
-
{format: 'string'}: output bin config as JSON string
|
|
7
|
-
*/
|
|
8
|
-
export default function initBinConfig(data, opts = {}) {
|
|
9
|
-
if (!data.length)
|
|
10
|
-
return {
|
|
11
|
-
mode: "discrete",
|
|
12
|
-
type: "regular-bin",
|
|
13
|
-
startinclusive: true,
|
|
14
|
-
bin_size: null,
|
|
15
|
-
first_bin: { stop: null },
|
|
16
|
-
}
|
|
17
|
-
if (data.find((d) => !Number.isFinite(d)))
|
|
18
|
-
throw new Error("non-numeric values found")
|
|
19
|
-
|
|
20
|
-
let binConfig
|
|
21
|
-
const s = new Set(data)
|
|
22
|
-
if (s.size === 1) {
|
|
23
|
-
// single unique value in data array
|
|
24
|
-
// prepare custom bin config for 3 bins: first bin
|
|
25
|
-
// for values less than the value, second bin for values
|
|
26
|
-
// equal to the value, and third bin one for values
|
|
27
|
-
// greater than the value
|
|
28
|
-
// all data values will fall into the second bin
|
|
29
|
-
const value = [...s][0]
|
|
30
|
-
binConfig = {
|
|
31
|
-
type: "custom-bin",
|
|
32
|
-
lst: [
|
|
33
|
-
{
|
|
34
|
-
stop: value,
|
|
35
|
-
stopinclusive: false,
|
|
36
|
-
startunbounded: true,
|
|
37
|
-
label: "<" + value,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
start: value,
|
|
41
|
-
stop: value,
|
|
42
|
-
startinclusive: true,
|
|
43
|
-
stopinclusive: true,
|
|
44
|
-
label: "=" + value,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
start: value,
|
|
48
|
-
startinclusive: false,
|
|
49
|
-
stopunbounded: true,
|
|
50
|
-
label: ">" + value,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
// multiple unique values in data array
|
|
56
|
-
// prepare regular bin config
|
|
57
|
-
|
|
58
|
-
// compute the bin size for a maximum bin number of 8
|
|
59
|
-
data.sort((a, b) => a - b)
|
|
60
|
-
const l = data.length
|
|
61
|
-
const min = data[0]
|
|
62
|
-
const max = data[l - 1]
|
|
63
|
-
const p5idx = Math.ceil(l * 0.05) - 1
|
|
64
|
-
const p98idx = Math.ceil(l * 0.98) - 1
|
|
65
|
-
const p5 = data[p5idx]
|
|
66
|
-
const p98 = data[p98idx]
|
|
67
|
-
// use 98th and 5th percentiles to compute bin size to reduce outlier influence
|
|
68
|
-
// if 98th = 5th, use max and min instead
|
|
69
|
-
const binSize = p98 != p5 ? (p98 - p5) / 8 : (max - min) / 8
|
|
70
|
-
// first bin stop will equal either (minimum + bin size) or (5th percentile), whichever is larger.
|
|
71
|
-
const firstBinStop = Math.max(min + binSize, p5)
|
|
72
|
-
// round the bin values
|
|
73
|
-
let [binSize_rnd, firstBinStop_rnd, lastBinStart_rnd, rounding] =
|
|
74
|
-
roundBinVals(binSize, firstBinStop, max, min)
|
|
75
|
-
// generate the bin configuration
|
|
76
|
-
binConfig = {
|
|
77
|
-
type: "regular-bin",
|
|
78
|
-
startinclusive: true,
|
|
79
|
-
bin_size: binSize_rnd,
|
|
80
|
-
first_bin: { stop: firstBinStop_rnd },
|
|
81
|
-
}
|
|
82
|
-
if (lastBinStart_rnd) binConfig.last_bin = { start: lastBinStart_rnd }
|
|
83
|
-
if (rounding) binConfig.rounding = rounding
|
|
84
|
-
}
|
|
85
|
-
if ("format" in opts) {
|
|
86
|
-
if (opts.format === "string") {
|
|
87
|
-
return JSON.stringify(binConfig)
|
|
88
|
-
} else {
|
|
89
|
-
throw "options are not in the correct format"
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
return binConfig
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function roundBinVals(binSize, firstBinStop, max, min) {
|
|
97
|
-
let binSize_rnd, firstBinStop_rnd, lastBinStart_rnd, rounding
|
|
98
|
-
const log = Math.floor(Math.log10(binSize))
|
|
99
|
-
if (binSize >= 0.1 && binSize <= 2) {
|
|
100
|
-
// Round to the nearest one for small bin sizes
|
|
101
|
-
binSize_rnd = Math.round(binSize / (1 * 10 ** log)) * (1 * 10 ** log)
|
|
102
|
-
firstBinStop_rnd =
|
|
103
|
-
Math.round(firstBinStop / (1 * 10 ** log)) * (1 * 10 ** log)
|
|
104
|
-
} else {
|
|
105
|
-
// Round to the nearest five for large bin sizes
|
|
106
|
-
binSize_rnd = Math.round(binSize / (5 * 10 ** log)) * (5 * 10 ** log)
|
|
107
|
-
firstBinStop_rnd =
|
|
108
|
-
Math.round(firstBinStop / (5 * 10 ** log)) * (5 * 10 ** log)
|
|
109
|
-
if (binSize_rnd === 0) binSize_rnd = 1 * 10 ** log
|
|
110
|
-
if (firstBinStop_rnd === 0) firstBinStop_rnd = 1 * 10 ** log
|
|
111
|
-
if (binSize_rnd === 5 * 10 ** log && firstBinStop_rnd === 1 * 10 ** log)
|
|
112
|
-
firstBinStop_rnd = 5 * 10 ** log
|
|
113
|
-
}
|
|
114
|
-
if (firstBinStop_rnd < min) firstBinStop_rnd = firstBinStop_rnd * 2
|
|
115
|
-
// if the number of bins is above 8 after rounding, then set the last bin start to restrict the number of bins to 8
|
|
116
|
-
const eighthBinStop_rnd = firstBinStop_rnd + binSize_rnd * 7
|
|
117
|
-
if (max > eighthBinStop_rnd) {
|
|
118
|
-
lastBinStart_rnd = firstBinStop_rnd + binSize_rnd * 6
|
|
119
|
-
}
|
|
120
|
-
if (binSize < 1) {
|
|
121
|
-
const digits = Math.abs(log)
|
|
122
|
-
binSize_rnd = Number(binSize_rnd.toFixed(digits))
|
|
123
|
-
firstBinStop_rnd = Number(firstBinStop_rnd.toFixed(digits))
|
|
124
|
-
if (lastBinStart_rnd)
|
|
125
|
-
lastBinStart_rnd = Number(lastBinStart_rnd.toFixed(digits))
|
|
126
|
-
rounding = "." + digits + "f"
|
|
127
|
-
}
|
|
128
|
-
if (Object.is(firstBinStop_rnd, -0)) firstBinStop_rnd = 0
|
|
129
|
-
return [binSize_rnd, firstBinStop_rnd, lastBinStart_rnd, rounding]
|
|
130
|
-
}
|
package/src/termdb.usecase.js
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TermTypes,
|
|
3
|
-
isNumericTerm,
|
|
4
|
-
SINGLECELL_CELLTYPE,
|
|
5
|
-
SINGLECELL_GENE_EXPRESSION,
|
|
6
|
-
ISOFORM_EXPRESSION,
|
|
7
|
-
} from "./terms.js"
|
|
8
|
-
|
|
9
|
-
export const graphableTypes = new Set([
|
|
10
|
-
"categorical",
|
|
11
|
-
"integer",
|
|
12
|
-
"float",
|
|
13
|
-
"condition",
|
|
14
|
-
"survival",
|
|
15
|
-
"snplst",
|
|
16
|
-
"snplocus",
|
|
17
|
-
"geneVariant",
|
|
18
|
-
"samplelst",
|
|
19
|
-
"geneExpression",
|
|
20
|
-
ISOFORM_EXPRESSION,
|
|
21
|
-
"dtcnv",
|
|
22
|
-
"dtsnvindel",
|
|
23
|
-
"dtfusion",
|
|
24
|
-
"dtsv",
|
|
25
|
-
"date",
|
|
26
|
-
TermTypes.SSGSEA,
|
|
27
|
-
TermTypes.DNA_METHYLATION,
|
|
28
|
-
TermTypes.METABOLITE_INTENSITY,
|
|
29
|
-
TermTypes.PROTEOME_ABUNDANCE,
|
|
30
|
-
SINGLECELL_GENE_EXPRESSION,
|
|
31
|
-
SINGLECELL_CELLTYPE,
|
|
32
|
-
TermTypes.SNP,
|
|
33
|
-
TermTypes.TERM_COLLECTION,
|
|
34
|
-
])
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
isUsableTerm() will
|
|
38
|
-
|
|
39
|
-
- centralize the "allowed term" logic
|
|
40
|
-
which can be intricate or dataset-specific
|
|
41
|
-
for certain terms or contexts
|
|
42
|
-
- make it easy to handle new term types
|
|
43
|
-
|
|
44
|
-
Arguments:
|
|
45
|
-
|
|
46
|
-
term {}
|
|
47
|
-
.type: 'categorical', etc.
|
|
48
|
-
.child_types: []
|
|
49
|
-
|
|
50
|
-
_usecase {}
|
|
51
|
-
.target (REQUIRED): 'barchart', 'regression', etc
|
|
52
|
-
- used as a switch-case "router" for additional use-specific logic
|
|
53
|
-
- other parameters, if applicable, are described in the route "handler"
|
|
54
|
-
.detail
|
|
55
|
-
- a more specific detailed use case
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
termdbConfig
|
|
59
|
-
optional. provides ds overrides on default rules via excludedTermtypeByTarget. for use on client
|
|
60
|
-
|
|
61
|
-
ds
|
|
62
|
-
optional. provides ds overrides when the function runs on backend
|
|
63
|
-
server-side dataset object that can supply overrides (in the form of functions) to the use case logic,
|
|
64
|
-
for example, to apply role-based allowed term uses or performance-related restrictions
|
|
65
|
-
to ancestor terms when a use case aggregates too many data points for a given chart type
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
|
|
69
|
-
a Set{} with zero or more of the following strings:
|
|
70
|
-
- 'plot' if the term can be used in a plot chartType
|
|
71
|
-
- 'branch' if the term can be used only as an expandable tree branch, but not in a plot
|
|
72
|
-
- an empty Set means that the term has no valid uses, i.e, it cannot be used either for plotting or as a tree branch
|
|
73
|
-
*/
|
|
74
|
-
export function isUsableTerm(term, _usecase, termdbConfig, ds) {
|
|
75
|
-
const usecase = _usecase || {}
|
|
76
|
-
|
|
77
|
-
// may apply dataset specific override filter for a use case
|
|
78
|
-
if (typeof ds?.usecase?.[usecase.target] == "function") {
|
|
79
|
-
return ds.usecase[usecase.target](term, usecase)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// if (term.isprivate && !user.roleCanUse(term)) return false
|
|
83
|
-
|
|
84
|
-
const uses = new Set()
|
|
85
|
-
// note: expects term.child_types to be null if term.isleaf == true
|
|
86
|
-
const child_types = term.child_types || []
|
|
87
|
-
// default handling
|
|
88
|
-
switch (usecase.target) {
|
|
89
|
-
case "barchart":
|
|
90
|
-
case "violin":
|
|
91
|
-
case "boxplot":
|
|
92
|
-
case "summary":
|
|
93
|
-
if (term.type && term.type !== "survival") uses.add("plot")
|
|
94
|
-
if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch")
|
|
95
|
-
return uses
|
|
96
|
-
|
|
97
|
-
case "summaryInput":
|
|
98
|
-
if (usecase.detail === "term2" || usecase.detail == "term0") {
|
|
99
|
-
if (term.type && term.type !== "survival") uses.add("plot")
|
|
100
|
-
if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch")
|
|
101
|
-
return uses
|
|
102
|
-
} else {
|
|
103
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
104
|
-
if (!term.isleaf) uses.add("branch")
|
|
105
|
-
return uses
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
case "matrix":
|
|
109
|
-
if (term.type) uses.add("plot")
|
|
110
|
-
if (!term.isleaf) uses.add("branch")
|
|
111
|
-
return uses
|
|
112
|
-
|
|
113
|
-
case "table":
|
|
114
|
-
if (usecase.detail == "term") uses.add("plot")
|
|
115
|
-
if (child_types.length > 1) uses.add("branch")
|
|
116
|
-
return uses
|
|
117
|
-
|
|
118
|
-
case "sampleScatter":
|
|
119
|
-
if (usecase.detail == "numeric") {
|
|
120
|
-
if (isNumericTerm(term)) {
|
|
121
|
-
uses.add("plot")
|
|
122
|
-
}
|
|
123
|
-
if (hasNumericChild(child_types)) uses.add("branch")
|
|
124
|
-
}
|
|
125
|
-
// Commenting out for now. May need later for another single
|
|
126
|
-
// cell term. Revisit logic at that time.
|
|
127
|
-
// else if (usecase?.specialCase?.type == 'singleCell') {
|
|
128
|
-
// if (term.type && term.type.startsWith('singleCell')) {
|
|
129
|
-
// if (term.plot && term.plot == usecase.specialCase?.config.name) {
|
|
130
|
-
// uses.add('plot')
|
|
131
|
-
// }
|
|
132
|
-
// }
|
|
133
|
-
// }
|
|
134
|
-
else {
|
|
135
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
136
|
-
if (!term.isleaf) uses.add("branch")
|
|
137
|
-
}
|
|
138
|
-
return uses
|
|
139
|
-
case "runChart2":
|
|
140
|
-
if (usecase.detail == "date" || usecase.detail == "xtw") {
|
|
141
|
-
if (term.type == "date") {
|
|
142
|
-
uses.add("plot")
|
|
143
|
-
}
|
|
144
|
-
if (child_types.includes("date")) uses.add("branch")
|
|
145
|
-
} else if (usecase.detail == "numeric") {
|
|
146
|
-
if (isNumericTerm(term) && term.type != "date") {
|
|
147
|
-
uses.add("plot")
|
|
148
|
-
}
|
|
149
|
-
if (hasNumericChild(child_types)) uses.add("branch")
|
|
150
|
-
} else {
|
|
151
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
152
|
-
if (!term.isleaf) uses.add("branch")
|
|
153
|
-
}
|
|
154
|
-
return uses
|
|
155
|
-
|
|
156
|
-
case "numericDictTermCluster":
|
|
157
|
-
if (!usecase.detail?.exclude?.includes(term.id)) {
|
|
158
|
-
if (isNumericTerm(term)) {
|
|
159
|
-
uses.add("plot")
|
|
160
|
-
}
|
|
161
|
-
if (hasNumericChild(child_types)) {
|
|
162
|
-
uses.add("branch")
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return uses
|
|
166
|
-
|
|
167
|
-
case "termCollections":
|
|
168
|
-
if (usecase.detail?.termIds?.includes(term.id)) uses.add("plot")
|
|
169
|
-
if (usecase.detail?.branchIds?.includes(term.id)) uses.add("branch")
|
|
170
|
-
return uses
|
|
171
|
-
|
|
172
|
-
case "profileForms":
|
|
173
|
-
if (!term.isleaf) {
|
|
174
|
-
const ancestors = term.id.split("__").length //depends on using the __ naming convension!
|
|
175
|
-
if (ancestors == 3) {
|
|
176
|
-
// 3rd level term is a domain, we show the templates associated to this domain
|
|
177
|
-
uses.add("plot")
|
|
178
|
-
} else if (ancestors < 3) uses.add("branch")
|
|
179
|
-
}
|
|
180
|
-
return uses
|
|
181
|
-
|
|
182
|
-
// case 'boxplot':
|
|
183
|
-
// if (term.type == 'float' || term.type == 'integer') uses.add('plot')
|
|
184
|
-
// if (usecase.detail === 'term2' && hasNumericChild(child_types)) uses.add('branch')
|
|
185
|
-
// return uses
|
|
186
|
-
|
|
187
|
-
case "cuminc":
|
|
188
|
-
if (usecase.detail == "term") {
|
|
189
|
-
if (term.type == "condition") uses.add("plot")
|
|
190
|
-
if (child_types.includes("condition")) uses.add("branch")
|
|
191
|
-
return uses
|
|
192
|
-
}
|
|
193
|
-
if (usecase.detail === "term2" || usecase.detail == "term0") {
|
|
194
|
-
if (term.type && term.type != "condition" && term.type != "survival")
|
|
195
|
-
uses.add("plot")
|
|
196
|
-
if (hasAllowedChildTypes(child_types, ["condition", "survival"]))
|
|
197
|
-
uses.add("branch")
|
|
198
|
-
return uses
|
|
199
|
-
}
|
|
200
|
-
return uses
|
|
201
|
-
|
|
202
|
-
case "survival":
|
|
203
|
-
if (usecase.detail == "term") {
|
|
204
|
-
if (term.type == "survival") uses.add("plot")
|
|
205
|
-
if (child_types.includes("survival")) uses.add("branch")
|
|
206
|
-
return uses
|
|
207
|
-
}
|
|
208
|
-
if (usecase.detail === "term2" || usecase.detail == "term0") {
|
|
209
|
-
if (term.type && term.type != "survival") uses.add("plot")
|
|
210
|
-
if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch")
|
|
211
|
-
return uses
|
|
212
|
-
}
|
|
213
|
-
return uses
|
|
214
|
-
|
|
215
|
-
case "regression":
|
|
216
|
-
if (usecase.detail == "outcome") {
|
|
217
|
-
if (usecase.regressionType == "linear") {
|
|
218
|
-
if (term.type == "float" || term.type == "integer") uses.add("plot")
|
|
219
|
-
if (hasNumericChild(child_types)) uses.add("branch")
|
|
220
|
-
return uses
|
|
221
|
-
}
|
|
222
|
-
if (usecase.regressionType == "logistic") {
|
|
223
|
-
if (term.type && term.type != "survival") uses.add("plot")
|
|
224
|
-
if (hasAllowedChildTypes(child_types, ["survival"]))
|
|
225
|
-
uses.add("branch")
|
|
226
|
-
return uses
|
|
227
|
-
} else if (usecase.regressionType == "cox") {
|
|
228
|
-
if (term.type == "condition" || term.type == "survival")
|
|
229
|
-
uses.add("plot")
|
|
230
|
-
if (
|
|
231
|
-
child_types.includes("condition") ||
|
|
232
|
-
child_types.includes("survival")
|
|
233
|
-
)
|
|
234
|
-
uses.add("branch")
|
|
235
|
-
return uses
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (usecase.detail == "independent") {
|
|
240
|
-
if (
|
|
241
|
-
term.type == "float" ||
|
|
242
|
-
term.type == "integer" ||
|
|
243
|
-
term.type == "categorical" ||
|
|
244
|
-
term.type == "samplelst"
|
|
245
|
-
)
|
|
246
|
-
uses.add("plot")
|
|
247
|
-
if (hasChildTypes(child_types, ["categorical", "float", "integer"]))
|
|
248
|
-
uses.add("branch")
|
|
249
|
-
return uses
|
|
250
|
-
}
|
|
251
|
-
return uses
|
|
252
|
-
|
|
253
|
-
case "filter": {
|
|
254
|
-
// apply "exlst" to other targets as needed
|
|
255
|
-
const exlst = termdbConfig?.excludedTermtypeByTarget?.filter
|
|
256
|
-
if (exlst) {
|
|
257
|
-
if (graphableTypes.has(term.type) && !exlst.includes(term.type))
|
|
258
|
-
uses.add("plot")
|
|
259
|
-
if (child_types.find((t) => !exlst.includes(t))) uses.add("branch") // there's a non-excluded child type, allow branch to show
|
|
260
|
-
return uses
|
|
261
|
-
}
|
|
262
|
-
// no specific rule for filter. use default rules
|
|
263
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
264
|
-
if (!term.isleaf) uses.add("branch")
|
|
265
|
-
return uses
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
case "correlationVolcano":
|
|
269
|
-
if (usecase.detail == "numeric") {
|
|
270
|
-
if (isNumericTerm(term)) {
|
|
271
|
-
uses.add("plot")
|
|
272
|
-
}
|
|
273
|
-
if (hasNumericChild(child_types)) uses.add("branch")
|
|
274
|
-
} else {
|
|
275
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
276
|
-
if (!term.isleaf) uses.add("branch")
|
|
277
|
-
}
|
|
278
|
-
return uses
|
|
279
|
-
|
|
280
|
-
case "proteinView":
|
|
281
|
-
if (term.type == TermTypes.PROTEOME_ABUNDANCE) uses.add("plot")
|
|
282
|
-
if (child_types.includes(TermTypes.PROTEOME_ABUNDANCE)) uses.add("branch")
|
|
283
|
-
return uses
|
|
284
|
-
|
|
285
|
-
default:
|
|
286
|
-
if (graphableTypes.has(term.type)) uses.add("plot")
|
|
287
|
-
if (!term.isleaf) uses.add("branch")
|
|
288
|
-
return uses
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// determine if the term has at least one child type that
|
|
293
|
-
// is not excluded
|
|
294
|
-
function hasAllowedChildTypes(child_types, excluded_types) {
|
|
295
|
-
if (!child_types.length) {
|
|
296
|
-
// term does not have children
|
|
297
|
-
return false
|
|
298
|
-
}
|
|
299
|
-
if (!excluded_types?.length) {
|
|
300
|
-
// no excluded types
|
|
301
|
-
return true
|
|
302
|
-
}
|
|
303
|
-
if (child_types.some((type) => !excluded_types.includes(type))) {
|
|
304
|
-
// at least one child type is not excluded
|
|
305
|
-
return true
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function hasNumericChild(child_types) {
|
|
310
|
-
return child_types.includes("float") || child_types.includes("integer")
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function hasChildTypes(child_types, expected_types) {
|
|
314
|
-
for (const a of expected_types) {
|
|
315
|
-
if (child_types.includes(a)) return true
|
|
316
|
-
}
|
|
317
|
-
}
|