@sjcrh/proteinpaint-shared 2.179.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/terms.js +288 -308
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.179.0",
3
+ "version": "2.180.0",
4
4
  "description": "ProteinPaint code that is shared between server and client-side workspaces",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/terms.js CHANGED
@@ -1,329 +1,309 @@
1
1
  import {
2
- dtgeneexpression,
3
- dtssgsea,
4
- dtdnamethylation,
5
- dtmetaboliteintensity,
6
- dtwholeproteomeabundance,
7
- TermTypeGroups,
8
- dtTerms
9
- } from './common.js'
10
-
11
- // moved TermTypeGroups to `server/src/common.js`, so now has to re-export
12
- export { TermTypeGroups } from './common.js'
13
-
14
- /*
15
- For datasets with multiple types of samples the ROOT_SAMPLE_TYPE is used to represent the root sample type, for example,
16
- the type patient, that has one or more samples associated to it. This should be the id used as sample_type, when generating the db to identify the root samples
17
- in sampleidmap or the terms annotating root samples in the terms table.
18
- The samples associated to a patient have annotations that are specific to a timepoint, for example, the age of the patient,
19
- the doses of the drugs the patient was taking at the time of the data collection, etc. These annotations are associated to a sample.
20
- */
21
- export const ROOT_SAMPLE_TYPE = 1
22
-
23
- //For datasets with one sample type the DEFAULT_SAMPLE_TYPE is used to represent the sample type
24
- export const DEFAULT_SAMPLE_TYPE = 2
25
-
26
- export const NumericModes = {
27
- continuous: 'continuous',
28
- discrete: 'discrete'
29
- }
30
-
31
- export const CATEGORICAL = 'categorical'
32
- export const CONDITION = 'condition'
33
- export const DATE = 'date'
34
- export const DNA_METHYLATION = 'dnaMethylation'
35
- export const FLOAT = 'float'
36
- export const GENE_VARIANT = 'geneVariant'
37
- export const GENE_EXPRESSION = 'geneExpression'
38
- export const INTEGER = 'integer'
39
- export const METABOLITE_INTENSITY = 'metaboliteIntensity'
40
- export const MULTIVALUE = 'multivalue'
41
- export const SAMPLELST = 'samplelst'
42
- export const SINGLECELL_CELLTYPE = 'singleCellCellType'
43
- export const SINGLECELL_GENE_EXPRESSION = 'singleCellGeneExpression'
44
- export const SNP = 'snp'
45
- export const SNP_LIST = 'snplst'
46
- export const SNP_LOCUS = 'snplocus'
47
- export const SSGSEA = 'ssGSEA'
48
- export const SURVIVAL = 'survival'
49
- export const TERM_COLLECTION = 'termCollection'
50
- export const WHOLE_PROTEOME_ABUNDANCE = 'wholeProteomeAbundance'
51
-
52
- //Term types should be used gradually using these constants instead of hardcoding the values,
53
- // eg: type == CATEGORICAL instead of type == 'categorical'
54
- export const TermTypes = {
55
- GENE_VARIANT,
56
- GENE_EXPRESSION,
57
- SSGSEA,
58
- DNA_METHYLATION,
59
- CATEGORICAL,
60
- INTEGER,
61
- FLOAT,
62
- SNP,
63
- SNP_LIST,
64
- SNP_LOCUS,
65
- CONDITION,
66
- SURVIVAL,
67
- SAMPLELST,
68
- METABOLITE_INTENSITY,
69
- WHOLE_PROTEOME_ABUNDANCE,
70
- SINGLECELL_CELLTYPE,
71
- SINGLECELL_GENE_EXPRESSION,
72
- MULTIVALUE,
73
- DATE,
74
- TERM_COLLECTION
75
- }
76
- export const dtTermTypes = new Set(dtTerms.map(t => t.type))
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));
77
60
  for (const dtTermType of dtTermTypes) {
78
- TermTypes[dtTermType.toUpperCase()] = dtTermType
79
- }
80
-
81
- export const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'
82
-
83
- export const TermTypes2Dt = {
84
- [GENE_EXPRESSION]: dtgeneexpression,
85
- [SSGSEA]: dtssgsea,
86
- [DNA_METHYLATION]: dtdnamethylation,
87
- [METABOLITE_INTENSITY]: dtmetaboliteintensity,
88
- [WHOLE_PROTEOME_ABUNDANCE]: dtwholeproteomeabundance
61
+ TermTypes[dtTermType.toUpperCase()] = dtTermType;
89
62
  }
90
-
91
- // maps term type to group (as is shown as toggles in search ui)
92
- export const typeGroup = {
93
- [CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
94
- [CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
95
- [FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
96
- [INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
97
- [SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
98
- [SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
99
- [DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
100
- [GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
101
- [SNP]: TermTypeGroups.SNP,
102
- [SNP_LIST]: TermTypeGroups.SNP_LIST,
103
- [SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
104
- [GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
105
- [SSGSEA]: TermTypeGroups.SSGSEA,
106
- [DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
107
- [METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
108
- [WHOLE_PROTEOME_ABUNDANCE]: TermTypeGroups.WHOLE_PROTEOME_ABUNDANCE,
109
- [TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
110
- [SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
111
- [SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION
112
- }
113
-
114
- const nonDictTypes = new Set([
115
- SNP,
116
- SNP_LIST,
117
- SNP_LOCUS,
118
- GENE_EXPRESSION,
119
- SSGSEA,
120
- DNA_METHYLATION,
121
- GENE_VARIANT,
122
- METABOLITE_INTENSITY,
123
- WHOLE_PROTEOME_ABUNDANCE,
124
- SINGLECELL_CELLTYPE,
125
- SINGLECELL_GENE_EXPRESSION
126
- ])
127
-
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
+ ]);
128
106
  for (const dtTermType of dtTermTypes) {
129
- nonDictTypes.add(TermTypes[dtTermType.toUpperCase()])
107
+ nonDictTypes.add(TermTypes[dtTermType.toUpperCase()]);
130
108
  }
131
-
132
- export const numericTypes = new Set([
133
- INTEGER,
134
- FLOAT,
135
- GENE_EXPRESSION,
136
- SSGSEA,
137
- DNA_METHYLATION,
138
- METABOLITE_INTENSITY,
139
- WHOLE_PROTEOME_ABUNDANCE,
140
- SINGLECELL_GENE_EXPRESSION,
141
- DATE
142
- ])
143
-
144
- // available termdb numeric table names used as anno_<term.type>,
145
- // for example anno_integer, anno_float, anno_date
146
- export const annoNumericTypes = new Set([INTEGER, FLOAT, DATE])
147
-
148
- const categoricalTypes = new Set([CATEGORICAL, SNP])
149
-
150
- const singleCellTerms = new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION])
151
-
152
- export function isSingleCellTerm(term) {
153
- if (!term) return false
154
- return singleCellTerms.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);
155
126
  }
156
- export function isNumericTerm(term) {
157
- if (!term) return false
158
- return numericTypes.has(term.type)
127
+ function isNumericTerm(term) {
128
+ if (!term) return false;
129
+ return numericTypes.has(term.type);
159
130
  }
160
- export function isCategoricalTerm(term) {
161
- if (!term) return false
162
- return categoricalTypes.has(term.type)
131
+ function isCategoricalTerm(term) {
132
+ if (!term) return false;
133
+ return categoricalTypes.has(term.type);
163
134
  }
164
-
165
- export function isDictionaryType(type) {
166
- return !isNonDictionaryType(type)
135
+ function isDictionaryType(type) {
136
+ return !isNonDictionaryType(type);
167
137
  }
168
-
169
- export function isNonDictionaryType(type) {
170
- if (!type) throw new Error('Type is not defined')
171
- return nonDictTypes.has(type)
138
+ function isNonDictionaryType(type) {
139
+ if (!type) throw new Error("Type is not defined");
140
+ return nonDictTypes.has(type);
172
141
  }
173
-
174
- export function equals(t1, t2) {
175
- if (!t1) throw new Error('First term is not defined ')
176
- if (!t2) throw new Error('Second term is not defined ')
177
- if (t1.type !== t2.type) return false //term types are different
178
- if (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id
179
- switch (t1.type) {
180
- case GENE_EXPRESSION:
181
- return t1.gene == t2.gene
182
- case SSGSEA:
183
- return t1.id == t2.id
184
- case DNA_METHYLATION:
185
- return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop
186
- case METABOLITE_INTENSITY:
187
- case WHOLE_PROTEOME_ABUNDANCE:
188
- return t1.name == t2.name
189
- case GENE_VARIANT:
190
- return t1.gene == t2.gene || (t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop)
191
-
192
- // TO DO: Add more cases
193
- // case SNP_LIST:
194
- // case SNP_LOCUS:
195
- // case SAMPLELST:
196
-
197
- default:
198
- return false
199
- }
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
+ }
200
166
  }
201
-
202
- export function getBin(lst, value) {
203
- let bin = lst.findIndex(
204
- b => (b.startunbounded && value < b.stop) || (b.startunbounded && b.stopinclusive && value == b.stop)
205
- )
206
- if (bin == -1)
207
- bin = lst.findIndex(
208
- b => (b.stopunbounded && value > b.start) || (b.stopunbounded && b.startinclusive && value == b.start)
209
- )
210
- if (bin == -1)
211
- bin = lst.findIndex(
212
- b =>
213
- (value > b.start && value < b.stop) ||
214
- (b.startinclusive && value == b.start) ||
215
- (b.stopinclusive && value == b.stop)
216
- )
217
- 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;
218
180
  }
219
- //Terms may have a sample type associated to them, in datasets with multiple types of samples.
220
- //For example the gender is associated to the patient while the age is associated to the type sample. This function is used
221
- //for example when calling getData or getFilter, to return either the parent or the child samples, depending on the use case.
222
- export function getSampleType(term, ds) {
223
- if (!term) return null
224
- //non dict terms annotate only samples, eg: gene expression, metabolite intensity, gene variant.
225
- //Their sample type is the default sample type that may or may not have a parent type, depending on the dataset
226
- if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE
227
- //dictionary terms may annotate different types of samples, eg: patient and sample or mouse and crop.
228
- if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id)
229
- if (term.type == 'samplelst') {
230
- const key = Object.keys(term.values)[0]
231
- const sampleId = term.values[key].list[0]?.sampleId
232
- if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)
233
- else return DEFAULT_SAMPLE_TYPE
234
- }
235
- // samplelst or non dict terms
236
- 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;
237
192
  }
238
-
239
- export function getParentType(types, ds) {
240
- if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null //dataset only has one type of sample
241
- const ids = Array.from(types)
242
- if (!ids || ids.length == 0) return null
243
- for (const id of ids) {
244
- const typeObj = ds.cohort.termdb.sampleTypes[id]
245
- if (!typeObj) continue
246
- if (typeObj.parent_id == null) return id //this is the root type
247
- //if my parent is in the list, then I am not the parent
248
- if (ids.includes(typeObj.parent_id)) continue
249
- else return typeObj.parent_id //my parent is not in the list, so I am the parent
250
- }
251
- 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;
252
205
  }
253
-
254
- //Returns human readable label for each term type; label is just for printing and not computing
255
206
  const typeMap = {
256
- categorical: 'Categorical',
257
- condition: 'Condition',
258
- float: 'Numerical',
259
- integer: 'Numerical',
260
- geneExpression: 'Gene Expression',
261
- ssGSEA: 'Geneset Expression',
262
- dnaMethylation: 'DNA Methylation',
263
- geneVariant: 'Gene Variant',
264
- metaboliteIntensity: 'Metabolite Intensity',
265
- wholeProteomeAbundance: 'Whole Proteome Abundance',
266
- multiValue: 'Multi Value',
267
- singleCellGeneExpression: 'Single Cell, Gene Expression',
268
- singleCellCellType: 'Single Cell, Cell Type',
269
- snplocus: 'SNP Locus',
270
- snp: 'SNP',
271
- snplst: 'SNP List',
272
- numericDictTerm: 'Numeric Dictionary Term',
273
- termCollection: 'Term Collection'
274
- }
275
-
276
- export function termType2label(type) {
277
- 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";
278
228
  }
279
-
280
- export function getDateFromNumber(value) {
281
- const year = Math.floor(value)
282
- const january1st = new Date(year, 0, 1)
283
- const totalDays = getDaysInYear(year)
284
- const time = Math.round((value - year) * totalDays) * oneDayTime
285
- const date = new Date(january1st.getTime() + time)
286
- 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;
287
236
  }
288
- /*
289
- Value is a decimal year.
290
- A decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion
291
- represents the fraction of the year that has elapsed.
292
- Example:
293
- 2025.0 represents the beginning of the year 2025.
294
- 2025.5 represents the middle of the year 2025.
295
- */
296
- const oneDayTime = 24 * 60 * 60 * 1000
297
-
298
- export function getDateStrFromNumber(value) {
299
- const date = getDateFromNumber(value)
300
-
301
- //Omit day to deidentify the patients
302
- return date.toLocaleDateString('en-US', {
303
- year: 'numeric',
304
- month: 'long'
305
- })
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
+ });
306
244
  }
307
-
308
- //The value returned is a decimal year
309
- //A decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion
310
- //represents the fraction of the year that has elapsed.
311
- export function getNumberFromDateStr(str) {
312
- const date = new Date(str)
313
- return getNumberFromDate(date)
245
+ function getNumberFromDateStr(str) {
246
+ const date = new Date(str);
247
+ return getNumberFromDate(date);
314
248
  }
315
-
316
- export function getNumberFromDate(date) {
317
- const year = date.getFullYear()
318
- const january1st = new Date(year, 0, 1)
319
- const diffDays = (date - january1st) / oneDayTime
320
- const daysTotal = getDaysInYear(year)
321
- const decimal = diffDays / daysTotal
322
- 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;
323
256
  }
324
-
325
- export function getDaysInYear(year) {
326
- const isLeap = new Date(year, 1, 29).getMonth() === 1
327
- const days = isLeap ? 366 : 365
328
- 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;
329
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
+ };