@sjcrh/proteinpaint-shared 2.178.1-0 → 2.180.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/package.json +1 -1
- package/src/termdb.usecase.js +14 -11
- package/src/terms.js +288 -285
package/package.json
CHANGED
package/src/termdb.usecase.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TermTypes, isNumericTerm } from './terms.js'
|
|
1
|
+
import { TermTypes, isNumericTerm, SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION } from './terms.js'
|
|
2
2
|
|
|
3
3
|
export const graphableTypes = new Set([
|
|
4
4
|
'categorical',
|
|
@@ -20,8 +20,8 @@ export const graphableTypes = new Set([
|
|
|
20
20
|
TermTypes.DNA_METHYLATION,
|
|
21
21
|
TermTypes.METABOLITE_INTENSITY,
|
|
22
22
|
TermTypes.WHOLE_PROTEOME_ABUNDANCE,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
24
|
+
SINGLECELL_CELLTYPE,
|
|
25
25
|
TermTypes.SNP,
|
|
26
26
|
TermTypes.TERM_COLLECTION
|
|
27
27
|
])
|
|
@@ -114,14 +114,17 @@ export function isUsableTerm(term, _usecase, termdbConfig, ds) {
|
|
|
114
114
|
uses.add('plot')
|
|
115
115
|
}
|
|
116
116
|
if (hasNumericChild(child_types)) uses.add('branch')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
117
|
+
}
|
|
118
|
+
// Commenting out for now. May need later for another single
|
|
119
|
+
// cell term. Revisit logic at that time.
|
|
120
|
+
// else if (usecase?.specialCase?.type == 'singleCell') {
|
|
121
|
+
// if (term.type && term.type.startsWith('singleCell')) {
|
|
122
|
+
// if (term.plot && term.plot == usecase.specialCase?.config.name) {
|
|
123
|
+
// uses.add('plot')
|
|
124
|
+
// }
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
else {
|
|
125
128
|
if (graphableTypes.has(term.type)) uses.add('plot')
|
|
126
129
|
if (!term.isleaf) uses.add('branch')
|
|
127
130
|
}
|
package/src/terms.js
CHANGED
|
@@ -1,306 +1,309 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
2
|
+
dtgeneexpression,
|
|
3
|
+
dtssgsea,
|
|
4
|
+
dtdnamethylation,
|
|
5
|
+
dtmetaboliteintensity,
|
|
6
|
+
dtwholeproteomeabundance,
|
|
7
|
+
TermTypeGroups,
|
|
8
|
+
dtTerms
|
|
9
|
+
} from "./common.js";
|
|
10
|
+
import { TermTypeGroups as TermTypeGroups2 } from "./common.js";
|
|
11
|
+
const ROOT_SAMPLE_TYPE = 1;
|
|
12
|
+
const DEFAULT_SAMPLE_TYPE = 2;
|
|
13
|
+
const NumericModes = {
|
|
14
|
+
continuous: "continuous",
|
|
15
|
+
discrete: "discrete"
|
|
16
|
+
};
|
|
17
|
+
const CATEGORICAL = "categorical";
|
|
18
|
+
const CONDITION = "condition";
|
|
19
|
+
const DATE = "date";
|
|
20
|
+
const DNA_METHYLATION = "dnaMethylation";
|
|
21
|
+
const FLOAT = "float";
|
|
22
|
+
const GENE_VARIANT = "geneVariant";
|
|
23
|
+
const GENE_EXPRESSION = "geneExpression";
|
|
24
|
+
const INTEGER = "integer";
|
|
25
|
+
const METABOLITE_INTENSITY = "metaboliteIntensity";
|
|
26
|
+
const MULTIVALUE = "multivalue";
|
|
27
|
+
const SAMPLELST = "samplelst";
|
|
28
|
+
const SINGLECELL_CELLTYPE = "singleCellCellType";
|
|
29
|
+
const SINGLECELL_GENE_EXPRESSION = "singleCellGeneExpression";
|
|
30
|
+
const SNP = "snp";
|
|
31
|
+
const SNP_LIST = "snplst";
|
|
32
|
+
const SNP_LOCUS = "snplocus";
|
|
33
|
+
const SSGSEA = "ssGSEA";
|
|
34
|
+
const SURVIVAL = "survival";
|
|
35
|
+
const TERM_COLLECTION = "termCollection";
|
|
36
|
+
const WHOLE_PROTEOME_ABUNDANCE = "wholeProteomeAbundance";
|
|
37
|
+
const TermTypes = {
|
|
38
|
+
GENE_VARIANT,
|
|
39
|
+
GENE_EXPRESSION,
|
|
40
|
+
SSGSEA,
|
|
41
|
+
DNA_METHYLATION,
|
|
42
|
+
CATEGORICAL,
|
|
43
|
+
INTEGER,
|
|
44
|
+
FLOAT,
|
|
45
|
+
SNP,
|
|
46
|
+
SNP_LIST,
|
|
47
|
+
SNP_LOCUS,
|
|
48
|
+
CONDITION,
|
|
49
|
+
SURVIVAL,
|
|
50
|
+
SAMPLELST,
|
|
51
|
+
METABOLITE_INTENSITY,
|
|
52
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
53
|
+
SINGLECELL_CELLTYPE,
|
|
54
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
55
|
+
MULTIVALUE,
|
|
56
|
+
DATE,
|
|
57
|
+
TERM_COLLECTION
|
|
58
|
+
};
|
|
59
|
+
const dtTermTypes = new Set(dtTerms.map((t) => t.type));
|
|
56
60
|
for (const dtTermType of dtTermTypes) {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'
|
|
61
|
-
|
|
62
|
-
export const TermTypes2Dt = {
|
|
63
|
-
[TermTypes.GENE_EXPRESSION]: dtgeneexpression,
|
|
64
|
-
[TermTypes.SSGSEA]: dtssgsea,
|
|
65
|
-
[TermTypes.DNA_METHYLATION]: dtdnamethylation,
|
|
66
|
-
[TermTypes.METABOLITE_INTENSITY]: dtmetaboliteintensity,
|
|
67
|
-
[TermTypes.WHOLE_PROTEOME_ABUNDANCE]: dtwholeproteomeabundance
|
|
61
|
+
TermTypes[dtTermType.toUpperCase()] = dtTermType;
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
63
|
+
const NUMERIC_DICTIONARY_TERM = "numericDictTerm";
|
|
64
|
+
const TermTypes2Dt = {
|
|
65
|
+
[GENE_EXPRESSION]: dtgeneexpression,
|
|
66
|
+
[SSGSEA]: dtssgsea,
|
|
67
|
+
[DNA_METHYLATION]: dtdnamethylation,
|
|
68
|
+
[METABOLITE_INTENSITY]: dtmetaboliteintensity,
|
|
69
|
+
[WHOLE_PROTEOME_ABUNDANCE]: dtwholeproteomeabundance
|
|
70
|
+
};
|
|
71
|
+
const typeGroup = {
|
|
72
|
+
[CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
73
|
+
[CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
74
|
+
[FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
75
|
+
[INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
76
|
+
[SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
77
|
+
[SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
78
|
+
[DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
79
|
+
[MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
80
|
+
[GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
|
|
81
|
+
[SNP]: TermTypeGroups.SNP,
|
|
82
|
+
[SNP_LIST]: TermTypeGroups.SNP_LIST,
|
|
83
|
+
[SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
|
|
84
|
+
[GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
|
|
85
|
+
[SSGSEA]: TermTypeGroups.SSGSEA,
|
|
86
|
+
[DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
|
|
87
|
+
[METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
|
|
88
|
+
[WHOLE_PROTEOME_ABUNDANCE]: TermTypeGroups.WHOLE_PROTEOME_ABUNDANCE,
|
|
89
|
+
[TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
|
|
90
|
+
[SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
|
|
91
|
+
[SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION
|
|
92
|
+
};
|
|
93
|
+
const nonDictTypes = /* @__PURE__ */ new Set([
|
|
94
|
+
SNP,
|
|
95
|
+
SNP_LIST,
|
|
96
|
+
SNP_LOCUS,
|
|
97
|
+
GENE_EXPRESSION,
|
|
98
|
+
SSGSEA,
|
|
99
|
+
DNA_METHYLATION,
|
|
100
|
+
GENE_VARIANT,
|
|
101
|
+
METABOLITE_INTENSITY,
|
|
102
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
103
|
+
SINGLECELL_CELLTYPE,
|
|
104
|
+
SINGLECELL_GENE_EXPRESSION
|
|
105
|
+
]);
|
|
105
106
|
for (const dtTermType of dtTermTypes) {
|
|
106
|
-
|
|
107
|
+
nonDictTypes.add(TermTypes[dtTermType.toUpperCase()]);
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
])
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const categoricalTypes = new Set([TermTypes.CATEGORICAL, TermTypes.SNP])
|
|
126
|
-
|
|
127
|
-
const singleSampleTerms = new Set([TermTypes.SINGLECELL_CELLTYPE, TermTypes.SINGLECELL_GENE_EXPRESSION])
|
|
128
|
-
|
|
129
|
-
export function isSingleSampleTerm(term) {
|
|
130
|
-
if (!term) return false
|
|
131
|
-
return singleSampleTerms.has(term.type)
|
|
109
|
+
const numericTypes = /* @__PURE__ */ new Set([
|
|
110
|
+
INTEGER,
|
|
111
|
+
FLOAT,
|
|
112
|
+
GENE_EXPRESSION,
|
|
113
|
+
SSGSEA,
|
|
114
|
+
DNA_METHYLATION,
|
|
115
|
+
METABOLITE_INTENSITY,
|
|
116
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
117
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
118
|
+
DATE
|
|
119
|
+
]);
|
|
120
|
+
const annoNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE]);
|
|
121
|
+
const categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP]);
|
|
122
|
+
const singleCellTerms = /* @__PURE__ */ new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION]);
|
|
123
|
+
function isSingleCellTerm(term) {
|
|
124
|
+
if (!term) return false;
|
|
125
|
+
return singleCellTerms.has(term.type);
|
|
132
126
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
function isNumericTerm(term) {
|
|
128
|
+
if (!term) return false;
|
|
129
|
+
return numericTypes.has(term.type);
|
|
136
130
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
function isCategoricalTerm(term) {
|
|
132
|
+
if (!term) return false;
|
|
133
|
+
return categoricalTypes.has(term.type);
|
|
140
134
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return !isNonDictionaryType(type)
|
|
135
|
+
function isDictionaryType(type) {
|
|
136
|
+
return !isNonDictionaryType(type);
|
|
144
137
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return nonDictTypes.has(type)
|
|
138
|
+
function isNonDictionaryType(type) {
|
|
139
|
+
if (!type) throw new Error("Type is not defined");
|
|
140
|
+
return nonDictTypes.has(type);
|
|
149
141
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
default:
|
|
175
|
-
return false
|
|
176
|
-
}
|
|
142
|
+
function equals(t1, t2) {
|
|
143
|
+
if (!t1) throw new Error("First term is not defined ");
|
|
144
|
+
if (!t2) throw new Error("Second term is not defined ");
|
|
145
|
+
if (t1.type !== t2.type) return false;
|
|
146
|
+
if (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id;
|
|
147
|
+
switch (t1.type) {
|
|
148
|
+
case GENE_EXPRESSION:
|
|
149
|
+
return t1.gene == t2.gene;
|
|
150
|
+
case SSGSEA:
|
|
151
|
+
return t1.id == t2.id;
|
|
152
|
+
case DNA_METHYLATION:
|
|
153
|
+
return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
|
|
154
|
+
case METABOLITE_INTENSITY:
|
|
155
|
+
case WHOLE_PROTEOME_ABUNDANCE:
|
|
156
|
+
return t1.name == t2.name;
|
|
157
|
+
case GENE_VARIANT:
|
|
158
|
+
return t1.gene == t2.gene || t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
|
|
159
|
+
// TO DO: Add more cases
|
|
160
|
+
// case SNP_LIST:
|
|
161
|
+
// case SNP_LOCUS:
|
|
162
|
+
// case SAMPLELST:
|
|
163
|
+
default:
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
177
166
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
(b.startinclusive && value == b.start) ||
|
|
192
|
-
(b.stopinclusive && value == b.stop)
|
|
193
|
-
)
|
|
194
|
-
return bin
|
|
167
|
+
function getBin(lst, value) {
|
|
168
|
+
let bin = lst.findIndex(
|
|
169
|
+
(b) => b.startunbounded && value < b.stop || b.startunbounded && b.stopinclusive && value == b.stop
|
|
170
|
+
);
|
|
171
|
+
if (bin == -1)
|
|
172
|
+
bin = lst.findIndex(
|
|
173
|
+
(b) => b.stopunbounded && value > b.start || b.stopunbounded && b.startinclusive && value == b.start
|
|
174
|
+
);
|
|
175
|
+
if (bin == -1)
|
|
176
|
+
bin = lst.findIndex(
|
|
177
|
+
(b) => value > b.start && value < b.stop || b.startinclusive && value == b.start || b.stopinclusive && value == b.stop
|
|
178
|
+
);
|
|
179
|
+
return bin;
|
|
195
180
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const key = Object.keys(term.values)[0]
|
|
208
|
-
const sampleId = term.values[key].list[0]?.sampleId
|
|
209
|
-
if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)
|
|
210
|
-
else return DEFAULT_SAMPLE_TYPE
|
|
211
|
-
}
|
|
212
|
-
// samplelst or non dict terms
|
|
213
|
-
return DEFAULT_SAMPLE_TYPE //later own term needs to know what type annotates based on the samples
|
|
181
|
+
function getSampleType(term, ds) {
|
|
182
|
+
if (!term) return null;
|
|
183
|
+
if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE;
|
|
184
|
+
if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id);
|
|
185
|
+
if (term.type == "samplelst") {
|
|
186
|
+
const key = Object.keys(term.values)[0];
|
|
187
|
+
const sampleId = term.values[key].list[0]?.sampleId;
|
|
188
|
+
if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId);
|
|
189
|
+
else return DEFAULT_SAMPLE_TYPE;
|
|
190
|
+
}
|
|
191
|
+
return DEFAULT_SAMPLE_TYPE;
|
|
214
192
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
return null //no parent found
|
|
193
|
+
function getParentType(types, ds) {
|
|
194
|
+
if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null;
|
|
195
|
+
const ids = Array.from(types);
|
|
196
|
+
if (!ids || ids.length == 0) return null;
|
|
197
|
+
for (const id of ids) {
|
|
198
|
+
const typeObj = ds.cohort.termdb.sampleTypes[id];
|
|
199
|
+
if (!typeObj) continue;
|
|
200
|
+
if (typeObj.parent_id == null) return id;
|
|
201
|
+
if (ids.includes(typeObj.parent_id)) continue;
|
|
202
|
+
else return typeObj.parent_id;
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
229
205
|
}
|
|
230
|
-
|
|
231
|
-
//Returns human readable label for each term type; label is just for printing and not computing
|
|
232
206
|
const typeMap = {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return typeMap[type] || 'Unknown term type'
|
|
207
|
+
categorical: "Categorical",
|
|
208
|
+
condition: "Condition",
|
|
209
|
+
float: "Numerical",
|
|
210
|
+
integer: "Numerical",
|
|
211
|
+
geneExpression: "Gene Expression",
|
|
212
|
+
ssGSEA: "Geneset Expression",
|
|
213
|
+
dnaMethylation: "DNA Methylation",
|
|
214
|
+
geneVariant: "Gene Variant",
|
|
215
|
+
metaboliteIntensity: "Metabolite Intensity",
|
|
216
|
+
wholeProteomeAbundance: "Whole Proteome Abundance",
|
|
217
|
+
multivalue: "Multi Value",
|
|
218
|
+
singleCellGeneExpression: "Single Cell, Gene Expression",
|
|
219
|
+
singleCellCellType: "Single Cell, Cell Type",
|
|
220
|
+
snplocus: "SNP Locus",
|
|
221
|
+
snp: "SNP",
|
|
222
|
+
snplst: "SNP List",
|
|
223
|
+
numericDictTerm: "Numeric Dictionary Term",
|
|
224
|
+
termCollection: "Term Collection"
|
|
225
|
+
};
|
|
226
|
+
function termType2label(type) {
|
|
227
|
+
return typeMap[type] || "Unknown term type";
|
|
255
228
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return date
|
|
229
|
+
function getDateFromNumber(value) {
|
|
230
|
+
const year = Math.floor(value);
|
|
231
|
+
const january1st = new Date(year, 0, 1);
|
|
232
|
+
const totalDays = getDaysInYear(year);
|
|
233
|
+
const time = Math.round((value - year) * totalDays) * oneDayTime;
|
|
234
|
+
const date = new Date(january1st.getTime() + time);
|
|
235
|
+
return date;
|
|
264
236
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
*/
|
|
273
|
-
const oneDayTime = 24 * 60 * 60 * 1000
|
|
274
|
-
|
|
275
|
-
export function getDateStrFromNumber(value) {
|
|
276
|
-
const date = getDateFromNumber(value)
|
|
277
|
-
|
|
278
|
-
//Omit day to deidentify the patients
|
|
279
|
-
return date.toLocaleDateString('en-US', {
|
|
280
|
-
year: 'numeric',
|
|
281
|
-
month: 'long'
|
|
282
|
-
})
|
|
237
|
+
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
238
|
+
function getDateStrFromNumber(value) {
|
|
239
|
+
const date = getDateFromNumber(value);
|
|
240
|
+
return date.toLocaleDateString("en-US", {
|
|
241
|
+
year: "numeric",
|
|
242
|
+
month: "long"
|
|
243
|
+
});
|
|
283
244
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
//represents the fraction of the year that has elapsed.
|
|
288
|
-
export function getNumberFromDateStr(str) {
|
|
289
|
-
const date = new Date(str)
|
|
290
|
-
return getNumberFromDate(date)
|
|
245
|
+
function getNumberFromDateStr(str) {
|
|
246
|
+
const date = new Date(str);
|
|
247
|
+
return getNumberFromDate(date);
|
|
291
248
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return year + decimal
|
|
249
|
+
function getNumberFromDate(date) {
|
|
250
|
+
const year = date.getFullYear();
|
|
251
|
+
const january1st = new Date(year, 0, 1);
|
|
252
|
+
const diffDays = (date.getTime() - january1st.getTime()) / oneDayTime;
|
|
253
|
+
const daysTotal = getDaysInYear(year);
|
|
254
|
+
const decimal = diffDays / daysTotal;
|
|
255
|
+
return year + decimal;
|
|
300
256
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return days
|
|
257
|
+
function getDaysInYear(year) {
|
|
258
|
+
const isLeap = new Date(year, 1, 29).getMonth() === 1;
|
|
259
|
+
const days = isLeap ? 366 : 365;
|
|
260
|
+
return days;
|
|
306
261
|
}
|
|
262
|
+
export {
|
|
263
|
+
CATEGORICAL,
|
|
264
|
+
CONDITION,
|
|
265
|
+
DATE,
|
|
266
|
+
DEFAULT_SAMPLE_TYPE,
|
|
267
|
+
DNA_METHYLATION,
|
|
268
|
+
FLOAT,
|
|
269
|
+
GENE_EXPRESSION,
|
|
270
|
+
GENE_VARIANT,
|
|
271
|
+
INTEGER,
|
|
272
|
+
METABOLITE_INTENSITY,
|
|
273
|
+
MULTIVALUE,
|
|
274
|
+
NUMERIC_DICTIONARY_TERM,
|
|
275
|
+
NumericModes,
|
|
276
|
+
ROOT_SAMPLE_TYPE,
|
|
277
|
+
SAMPLELST,
|
|
278
|
+
SINGLECELL_CELLTYPE,
|
|
279
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
280
|
+
SNP,
|
|
281
|
+
SNP_LIST,
|
|
282
|
+
SNP_LOCUS,
|
|
283
|
+
SSGSEA,
|
|
284
|
+
SURVIVAL,
|
|
285
|
+
TERM_COLLECTION,
|
|
286
|
+
TermTypeGroups2 as TermTypeGroups,
|
|
287
|
+
TermTypes,
|
|
288
|
+
TermTypes2Dt,
|
|
289
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
290
|
+
annoNumericTypes,
|
|
291
|
+
dtTermTypes,
|
|
292
|
+
equals,
|
|
293
|
+
getBin,
|
|
294
|
+
getDateFromNumber,
|
|
295
|
+
getDateStrFromNumber,
|
|
296
|
+
getDaysInYear,
|
|
297
|
+
getNumberFromDate,
|
|
298
|
+
getNumberFromDateStr,
|
|
299
|
+
getParentType,
|
|
300
|
+
getSampleType,
|
|
301
|
+
isCategoricalTerm,
|
|
302
|
+
isDictionaryType,
|
|
303
|
+
isNonDictionaryType,
|
|
304
|
+
isNumericTerm,
|
|
305
|
+
isSingleCellTerm,
|
|
306
|
+
numericTypes,
|
|
307
|
+
termType2label,
|
|
308
|
+
typeGroup
|
|
309
|
+
};
|