@vitessce/zarr 3.5.6 → 3.5.7
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/dist/index.js +377 -40
- package/dist-tsc/AnnDataSource.d.ts +7 -0
- package/dist-tsc/AnnDataSource.d.ts.map +1 -1
- package/dist-tsc/AnnDataSource.js +15 -1
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts +18 -0
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.js +75 -0
- package/dist-tsc/anndata-loaders/index.d.ts +1 -0
- package/dist-tsc/anndata-loaders/index.js +1 -0
- package/dist-tsc/utils.js +2 -1
- package/package.json +10 -9
- package/src/AnnDataSource.js +17 -2
- package/src/anndata-loaders/SampleSetsAnndataLoader.js +88 -0
- package/src/anndata-loaders/index.js +1 -0
- package/src/utils.js +2 -2
package/dist/index.js
CHANGED
|
@@ -2785,6 +2785,291 @@ class ZarrDataSource {
|
|
|
2785
2785
|
return (await open(storeRootToUse.resolve(dirKey))).attrs;
|
|
2786
2786
|
}
|
|
2787
2787
|
}
|
|
2788
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2789
|
+
function getDefaultExportFromCjs(x) {
|
|
2790
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2791
|
+
}
|
|
2792
|
+
function getAugmentedNamespace(n) {
|
|
2793
|
+
if (n.__esModule)
|
|
2794
|
+
return n;
|
|
2795
|
+
var f = n.default;
|
|
2796
|
+
if (typeof f == "function") {
|
|
2797
|
+
var a = function a2() {
|
|
2798
|
+
if (this instanceof a2) {
|
|
2799
|
+
var args = [null];
|
|
2800
|
+
args.push.apply(args, arguments);
|
|
2801
|
+
var Ctor = Function.bind.apply(f, args);
|
|
2802
|
+
return new Ctor();
|
|
2803
|
+
}
|
|
2804
|
+
return f.apply(this, arguments);
|
|
2805
|
+
};
|
|
2806
|
+
a.prototype = f.prototype;
|
|
2807
|
+
} else
|
|
2808
|
+
a = {};
|
|
2809
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
2810
|
+
Object.keys(n).forEach(function(k) {
|
|
2811
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
2812
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
2813
|
+
enumerable: true,
|
|
2814
|
+
get: function() {
|
|
2815
|
+
return n[k];
|
|
2816
|
+
}
|
|
2817
|
+
});
|
|
2818
|
+
});
|
|
2819
|
+
return a;
|
|
2820
|
+
}
|
|
2821
|
+
var loglevel = { exports: {} };
|
|
2822
|
+
(function(module2) {
|
|
2823
|
+
(function(root2, definition) {
|
|
2824
|
+
if (module2.exports) {
|
|
2825
|
+
module2.exports = definition();
|
|
2826
|
+
} else {
|
|
2827
|
+
root2.log = definition();
|
|
2828
|
+
}
|
|
2829
|
+
})(commonjsGlobal, function() {
|
|
2830
|
+
var noop = function() {
|
|
2831
|
+
};
|
|
2832
|
+
var undefinedType2 = "undefined";
|
|
2833
|
+
var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
|
|
2834
|
+
var logMethods = [
|
|
2835
|
+
"trace",
|
|
2836
|
+
"debug",
|
|
2837
|
+
"info",
|
|
2838
|
+
"warn",
|
|
2839
|
+
"error"
|
|
2840
|
+
];
|
|
2841
|
+
var _loggersByName = {};
|
|
2842
|
+
var defaultLogger = null;
|
|
2843
|
+
function bindMethod(obj, methodName) {
|
|
2844
|
+
var method = obj[methodName];
|
|
2845
|
+
if (typeof method.bind === "function") {
|
|
2846
|
+
return method.bind(obj);
|
|
2847
|
+
} else {
|
|
2848
|
+
try {
|
|
2849
|
+
return Function.prototype.bind.call(method, obj);
|
|
2850
|
+
} catch (e) {
|
|
2851
|
+
return function() {
|
|
2852
|
+
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
function traceForIE() {
|
|
2858
|
+
if (console.log) {
|
|
2859
|
+
if (console.log.apply) {
|
|
2860
|
+
console.log.apply(console, arguments);
|
|
2861
|
+
} else {
|
|
2862
|
+
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
if (console.trace)
|
|
2866
|
+
console.trace();
|
|
2867
|
+
}
|
|
2868
|
+
function realMethod(methodName) {
|
|
2869
|
+
if (methodName === "debug") {
|
|
2870
|
+
methodName = "log";
|
|
2871
|
+
}
|
|
2872
|
+
if (typeof console === undefinedType2) {
|
|
2873
|
+
return false;
|
|
2874
|
+
} else if (methodName === "trace" && isIE) {
|
|
2875
|
+
return traceForIE;
|
|
2876
|
+
} else if (console[methodName] !== void 0) {
|
|
2877
|
+
return bindMethod(console, methodName);
|
|
2878
|
+
} else if (console.log !== void 0) {
|
|
2879
|
+
return bindMethod(console, "log");
|
|
2880
|
+
} else {
|
|
2881
|
+
return noop;
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
function replaceLoggingMethods() {
|
|
2885
|
+
var level = this.getLevel();
|
|
2886
|
+
for (var i = 0; i < logMethods.length; i++) {
|
|
2887
|
+
var methodName = logMethods[i];
|
|
2888
|
+
this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
|
|
2889
|
+
}
|
|
2890
|
+
this.log = this.debug;
|
|
2891
|
+
if (typeof console === undefinedType2 && level < this.levels.SILENT) {
|
|
2892
|
+
return "No console available for logging";
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
function enableLoggingWhenConsoleArrives(methodName) {
|
|
2896
|
+
return function() {
|
|
2897
|
+
if (typeof console !== undefinedType2) {
|
|
2898
|
+
replaceLoggingMethods.call(this);
|
|
2899
|
+
this[methodName].apply(this, arguments);
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
2904
|
+
return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
2905
|
+
}
|
|
2906
|
+
function Logger(name, factory) {
|
|
2907
|
+
var self2 = this;
|
|
2908
|
+
var inheritedLevel;
|
|
2909
|
+
var defaultLevel;
|
|
2910
|
+
var userLevel;
|
|
2911
|
+
var storageKey = "loglevel";
|
|
2912
|
+
if (typeof name === "string") {
|
|
2913
|
+
storageKey += ":" + name;
|
|
2914
|
+
} else if (typeof name === "symbol") {
|
|
2915
|
+
storageKey = void 0;
|
|
2916
|
+
}
|
|
2917
|
+
function persistLevelIfPossible(levelNum) {
|
|
2918
|
+
var levelName = (logMethods[levelNum] || "silent").toUpperCase();
|
|
2919
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2920
|
+
return;
|
|
2921
|
+
try {
|
|
2922
|
+
window.localStorage[storageKey] = levelName;
|
|
2923
|
+
return;
|
|
2924
|
+
} catch (ignore) {
|
|
2925
|
+
}
|
|
2926
|
+
try {
|
|
2927
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
2928
|
+
} catch (ignore) {
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
function getPersistedLevel() {
|
|
2932
|
+
var storedLevel;
|
|
2933
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2934
|
+
return;
|
|
2935
|
+
try {
|
|
2936
|
+
storedLevel = window.localStorage[storageKey];
|
|
2937
|
+
} catch (ignore) {
|
|
2938
|
+
}
|
|
2939
|
+
if (typeof storedLevel === undefinedType2) {
|
|
2940
|
+
try {
|
|
2941
|
+
var cookie = window.document.cookie;
|
|
2942
|
+
var cookieName = encodeURIComponent(storageKey);
|
|
2943
|
+
var location = cookie.indexOf(cookieName + "=");
|
|
2944
|
+
if (location !== -1) {
|
|
2945
|
+
storedLevel = /^([^;]+)/.exec(
|
|
2946
|
+
cookie.slice(location + cookieName.length + 1)
|
|
2947
|
+
)[1];
|
|
2948
|
+
}
|
|
2949
|
+
} catch (ignore) {
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
if (self2.levels[storedLevel] === void 0) {
|
|
2953
|
+
storedLevel = void 0;
|
|
2954
|
+
}
|
|
2955
|
+
return storedLevel;
|
|
2956
|
+
}
|
|
2957
|
+
function clearPersistedLevel() {
|
|
2958
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2959
|
+
return;
|
|
2960
|
+
try {
|
|
2961
|
+
window.localStorage.removeItem(storageKey);
|
|
2962
|
+
} catch (ignore) {
|
|
2963
|
+
}
|
|
2964
|
+
try {
|
|
2965
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
2966
|
+
} catch (ignore) {
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
function normalizeLevel(input) {
|
|
2970
|
+
var level = input;
|
|
2971
|
+
if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
|
|
2972
|
+
level = self2.levels[level.toUpperCase()];
|
|
2973
|
+
}
|
|
2974
|
+
if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
|
|
2975
|
+
return level;
|
|
2976
|
+
} else {
|
|
2977
|
+
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
self2.name = name;
|
|
2981
|
+
self2.levels = {
|
|
2982
|
+
"TRACE": 0,
|
|
2983
|
+
"DEBUG": 1,
|
|
2984
|
+
"INFO": 2,
|
|
2985
|
+
"WARN": 3,
|
|
2986
|
+
"ERROR": 4,
|
|
2987
|
+
"SILENT": 5
|
|
2988
|
+
};
|
|
2989
|
+
self2.methodFactory = factory || defaultMethodFactory;
|
|
2990
|
+
self2.getLevel = function() {
|
|
2991
|
+
if (userLevel != null) {
|
|
2992
|
+
return userLevel;
|
|
2993
|
+
} else if (defaultLevel != null) {
|
|
2994
|
+
return defaultLevel;
|
|
2995
|
+
} else {
|
|
2996
|
+
return inheritedLevel;
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
self2.setLevel = function(level, persist) {
|
|
3000
|
+
userLevel = normalizeLevel(level);
|
|
3001
|
+
if (persist !== false) {
|
|
3002
|
+
persistLevelIfPossible(userLevel);
|
|
3003
|
+
}
|
|
3004
|
+
return replaceLoggingMethods.call(self2);
|
|
3005
|
+
};
|
|
3006
|
+
self2.setDefaultLevel = function(level) {
|
|
3007
|
+
defaultLevel = normalizeLevel(level);
|
|
3008
|
+
if (!getPersistedLevel()) {
|
|
3009
|
+
self2.setLevel(level, false);
|
|
3010
|
+
}
|
|
3011
|
+
};
|
|
3012
|
+
self2.resetLevel = function() {
|
|
3013
|
+
userLevel = null;
|
|
3014
|
+
clearPersistedLevel();
|
|
3015
|
+
replaceLoggingMethods.call(self2);
|
|
3016
|
+
};
|
|
3017
|
+
self2.enableAll = function(persist) {
|
|
3018
|
+
self2.setLevel(self2.levels.TRACE, persist);
|
|
3019
|
+
};
|
|
3020
|
+
self2.disableAll = function(persist) {
|
|
3021
|
+
self2.setLevel(self2.levels.SILENT, persist);
|
|
3022
|
+
};
|
|
3023
|
+
self2.rebuild = function() {
|
|
3024
|
+
if (defaultLogger !== self2) {
|
|
3025
|
+
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
3026
|
+
}
|
|
3027
|
+
replaceLoggingMethods.call(self2);
|
|
3028
|
+
if (defaultLogger === self2) {
|
|
3029
|
+
for (var childName in _loggersByName) {
|
|
3030
|
+
_loggersByName[childName].rebuild();
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
inheritedLevel = normalizeLevel(
|
|
3035
|
+
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
3036
|
+
);
|
|
3037
|
+
var initialLevel = getPersistedLevel();
|
|
3038
|
+
if (initialLevel != null) {
|
|
3039
|
+
userLevel = normalizeLevel(initialLevel);
|
|
3040
|
+
}
|
|
3041
|
+
replaceLoggingMethods.call(self2);
|
|
3042
|
+
}
|
|
3043
|
+
defaultLogger = new Logger();
|
|
3044
|
+
defaultLogger.getLogger = function getLogger(name) {
|
|
3045
|
+
if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
|
|
3046
|
+
throw new TypeError("You must supply a name when creating a logger.");
|
|
3047
|
+
}
|
|
3048
|
+
var logger = _loggersByName[name];
|
|
3049
|
+
if (!logger) {
|
|
3050
|
+
logger = _loggersByName[name] = new Logger(
|
|
3051
|
+
name,
|
|
3052
|
+
defaultLogger.methodFactory
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
return logger;
|
|
3056
|
+
};
|
|
3057
|
+
var _log = typeof window !== undefinedType2 ? window.log : void 0;
|
|
3058
|
+
defaultLogger.noConflict = function() {
|
|
3059
|
+
if (typeof window !== undefinedType2 && window.log === defaultLogger) {
|
|
3060
|
+
window.log = _log;
|
|
3061
|
+
}
|
|
3062
|
+
return defaultLogger;
|
|
3063
|
+
};
|
|
3064
|
+
defaultLogger.getLoggers = function getLoggers() {
|
|
3065
|
+
return _loggersByName;
|
|
3066
|
+
};
|
|
3067
|
+
defaultLogger["default"] = defaultLogger;
|
|
3068
|
+
return defaultLogger;
|
|
3069
|
+
});
|
|
3070
|
+
})(loglevel);
|
|
3071
|
+
var loglevelExports = loglevel.exports;
|
|
3072
|
+
const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
|
|
2788
3073
|
function dirname(path) {
|
|
2789
3074
|
const arr = path.split("/");
|
|
2790
3075
|
arr.pop();
|
|
@@ -2794,7 +3079,7 @@ function basename(path) {
|
|
|
2794
3079
|
const arr = path.split("/");
|
|
2795
3080
|
const result = arr.at(-1);
|
|
2796
3081
|
if (!result) {
|
|
2797
|
-
|
|
3082
|
+
log.error("basename of path is empty", path);
|
|
2798
3083
|
return "";
|
|
2799
3084
|
}
|
|
2800
3085
|
return result;
|
|
@@ -2987,6 +3272,16 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
2987
3272
|
this.obsIndex = this.getJson("obs/.zattrs").then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
|
|
2988
3273
|
return this.obsIndex;
|
|
2989
3274
|
}
|
|
3275
|
+
/**
|
|
3276
|
+
* Class method for loading the obs index.
|
|
3277
|
+
* @param {string|undefined} path Used by subclasses.
|
|
3278
|
+
* @returns {Promise<string[]>} An promise for a zarr array
|
|
3279
|
+
* containing the indices.
|
|
3280
|
+
*/
|
|
3281
|
+
loadDataFrameIndex(path = void 0) {
|
|
3282
|
+
const dfPath = path ? dirname(path) : "";
|
|
3283
|
+
return this.getJson(`${dfPath}/.zattrs`).then(({ _index }) => this.getFlatArrDecompressed(`${dfPath.length > 0 ? "/" : ""}${dfPath}/${_index}`));
|
|
3284
|
+
}
|
|
2990
3285
|
/**
|
|
2991
3286
|
* Class method for loading the var index.
|
|
2992
3287
|
* @param {string|undefined} path Used by subclasses.
|
|
@@ -3104,7 +3399,7 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3104
3399
|
try {
|
|
3105
3400
|
val = await this._loadElement(`${path}/${key}`);
|
|
3106
3401
|
} catch (e) {
|
|
3107
|
-
|
|
3402
|
+
log.error(`Error in _loadDict: could not load ${key}`);
|
|
3108
3403
|
}
|
|
3109
3404
|
result[key] = val;
|
|
3110
3405
|
}));
|
|
@@ -3699,7 +3994,8 @@ const ViewType$1 = {
|
|
|
3699
3994
|
FEATURE_BAR_PLOT: "featureBarPlot",
|
|
3700
3995
|
BIOMARKER_SELECT: "biomarkerSelect",
|
|
3701
3996
|
LINK_CONTROLLER: "linkController",
|
|
3702
|
-
DUAL_SCATTERPLOT: "dualScatterplot"
|
|
3997
|
+
DUAL_SCATTERPLOT: "dualScatterplot",
|
|
3998
|
+
TREEMAP: "treemap"
|
|
3703
3999
|
};
|
|
3704
4000
|
const DataType$1 = {
|
|
3705
4001
|
OBS_LABELS: "obsLabels",
|
|
@@ -3753,6 +4049,7 @@ const FileType$1 = {
|
|
|
3753
4049
|
OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
|
|
3754
4050
|
FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
|
|
3755
4051
|
SAMPLE_EDGES_ANNDATA_ZARR: "sampleEdges.anndata.zarr",
|
|
4052
|
+
SAMPLE_SETS_ANNDATA_ZARR: "sampleSets.anndata.zarr",
|
|
3756
4053
|
// AnnData - zipped
|
|
3757
4054
|
OBS_FEATURE_MATRIX_ANNDATA_ZARR_ZIP: "obsFeatureMatrix.anndata.zarr.zip",
|
|
3758
4055
|
OBS_FEATURE_COLUMNS_ANNDATA_ZARR_ZIP: "obsFeatureColumns.anndata.zarr.zip",
|
|
@@ -3765,6 +4062,7 @@ const FileType$1 = {
|
|
|
3765
4062
|
OBS_LABELS_ANNDATA_ZARR_ZIP: "obsLabels.anndata.zarr.zip",
|
|
3766
4063
|
FEATURE_LABELS_ANNDATA_ZARR_ZIP: "featureLabels.anndata.zarr.zip",
|
|
3767
4064
|
SAMPLE_EDGES_ANNDATA_ZARR_ZIP: "sampleEdges.anndata.zarr.zip",
|
|
4065
|
+
SAMPLE_SETS_ANNDATA_ZARR_ZIP: "sampleSets.anndata.zarr.zip",
|
|
3768
4066
|
// AnnData - h5ad via reference spec
|
|
3769
4067
|
OBS_FEATURE_MATRIX_ANNDATA_H5AD: "obsFeatureMatrix.anndata.h5ad",
|
|
3770
4068
|
OBS_FEATURE_COLUMNS_ANNDATA_H5AD: "obsFeatureColumns.anndata.h5ad",
|
|
@@ -3777,6 +4075,7 @@ const FileType$1 = {
|
|
|
3777
4075
|
OBS_LABELS_ANNDATA_H5AD: "obsLabels.anndata.h5ad",
|
|
3778
4076
|
FEATURE_LABELS_ANNDATA_H5AD: "featureLabels.anndata.h5ad",
|
|
3779
4077
|
SAMPLE_EDGES_ANNDATA_H5AD: "sampleEdges.anndata.h5ad",
|
|
4078
|
+
SAMPLE_SETS_ANNDATA_H5AD: "sampleSets.anndata.h5ad",
|
|
3780
4079
|
// SpatialData
|
|
3781
4080
|
IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
|
|
3782
4081
|
LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
|
|
@@ -3968,12 +4267,15 @@ const CoordinationType$1 = {
|
|
|
3968
4267
|
SAMPLE_SET_FILTER: "sampleSetFilter",
|
|
3969
4268
|
SAMPLE_FILTER_MODE: "sampleFilterMode",
|
|
3970
4269
|
SAMPLE_SET_COLOR: "sampleSetColor",
|
|
4270
|
+
SAMPLE_HIGHLIGHT: "sampleHighlight",
|
|
3971
4271
|
EMBEDDING_POINTS_VISIBLE: "embeddingPointsVisible",
|
|
3972
4272
|
EMBEDDING_CONTOURS_VISIBLE: "embeddingContoursVisible",
|
|
3973
4273
|
EMBEDDING_CONTOURS_FILLED: "embeddingContoursFilled",
|
|
3974
4274
|
EMBEDDING_CONTOUR_PERCENTILES: "embeddingContourPercentiles",
|
|
3975
4275
|
CONTOUR_COLOR_ENCODING: "contourColorEncoding",
|
|
3976
|
-
CONTOUR_COLOR: "contourColor"
|
|
4276
|
+
CONTOUR_COLOR: "contourColor",
|
|
4277
|
+
// Treemap
|
|
4278
|
+
HIERARCHY_LEVELS: "hierarchyLevels"
|
|
3977
4279
|
};
|
|
3978
4280
|
const DEFAULT_CELLS_LAYER = {
|
|
3979
4281
|
opacity: 1,
|
|
@@ -3981,39 +4283,6 @@ const DEFAULT_CELLS_LAYER = {
|
|
|
3981
4283
|
visible: true,
|
|
3982
4284
|
stroked: false
|
|
3983
4285
|
};
|
|
3984
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3985
|
-
function getDefaultExportFromCjs(x) {
|
|
3986
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3987
|
-
}
|
|
3988
|
-
function getAugmentedNamespace(n) {
|
|
3989
|
-
if (n.__esModule)
|
|
3990
|
-
return n;
|
|
3991
|
-
var f = n.default;
|
|
3992
|
-
if (typeof f == "function") {
|
|
3993
|
-
var a = function a2() {
|
|
3994
|
-
if (this instanceof a2) {
|
|
3995
|
-
var args = [null];
|
|
3996
|
-
args.push.apply(args, arguments);
|
|
3997
|
-
var Ctor = Function.bind.apply(f, args);
|
|
3998
|
-
return new Ctor();
|
|
3999
|
-
}
|
|
4000
|
-
return f.apply(this, arguments);
|
|
4001
|
-
};
|
|
4002
|
-
a.prototype = f.prototype;
|
|
4003
|
-
} else
|
|
4004
|
-
a = {};
|
|
4005
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
4006
|
-
Object.keys(n).forEach(function(k) {
|
|
4007
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
4008
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
4009
|
-
enumerable: true,
|
|
4010
|
-
get: function() {
|
|
4011
|
-
return n[k];
|
|
4012
|
-
}
|
|
4013
|
-
});
|
|
4014
|
-
});
|
|
4015
|
-
return a;
|
|
4016
|
-
}
|
|
4017
4286
|
function commonjsRequire(path) {
|
|
4018
4287
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4019
4288
|
}
|
|
@@ -10907,7 +11176,7 @@ function upgradeFrom1_0_14(config2) {
|
|
|
10907
11176
|
Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
|
|
10908
11177
|
var _a2;
|
|
10909
11178
|
if ((_a2 = viewDef.props) == null ? void 0 : _a2[oldProp]) {
|
|
10910
|
-
|
|
11179
|
+
log.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
|
|
10911
11180
|
}
|
|
10912
11181
|
});
|
|
10913
11182
|
});
|
|
@@ -10930,7 +11199,7 @@ function upgradeFrom1_0_15(config2) {
|
|
|
10930
11199
|
Object.entries(coordinationScopes).forEach(([coordinationType, coordinationScope]) => {
|
|
10931
11200
|
if (!Array.isArray(coordinationScope) && typeof coordinationScope === "object") {
|
|
10932
11201
|
if (coordinationType === "dataset") {
|
|
10933
|
-
|
|
11202
|
+
log.error("Expected coordinationScopes.dataset value to be either string or string[], but got object.");
|
|
10934
11203
|
}
|
|
10935
11204
|
coordinationScopesBy.dataset[coordinationType] = coordinationScope;
|
|
10936
11205
|
} else if (Array.isArray(coordinationScope) || typeof coordinationScope === "string") {
|
|
@@ -13289,7 +13558,7 @@ function makeConstantWithDeprecationMessage(currObj, oldObj) {
|
|
|
13289
13558
|
const oldKeys = Object.keys(oldObj);
|
|
13290
13559
|
const propKey = String(prop);
|
|
13291
13560
|
if (oldKeys.includes(propKey)) {
|
|
13292
|
-
|
|
13561
|
+
log.warn(`Notice about the constant mapping ${propKey}: '${oldObj[propKey][0]}':
|
|
13293
13562
|
${oldObj[propKey][1]}`);
|
|
13294
13563
|
return oldObj[propKey];
|
|
13295
13564
|
}
|
|
@@ -13387,6 +13656,9 @@ const annDataObsSetsArr = z.array(z.object({
|
|
|
13387
13656
|
z.object({
|
|
13388
13657
|
obsSets: annDataObsSetsArr
|
|
13389
13658
|
});
|
|
13659
|
+
z.object({
|
|
13660
|
+
sampleSets: annDataObsSetsArr
|
|
13661
|
+
});
|
|
13390
13662
|
const annDataObsFeatureColumnsArr = z.array(z.object({
|
|
13391
13663
|
path: z.string()
|
|
13392
13664
|
}));
|
|
@@ -20540,6 +20812,70 @@ class SampleEdgesAnndataLoader extends AbstractTwoStepLoader {
|
|
|
20540
20812
|
});
|
|
20541
20813
|
}
|
|
20542
20814
|
}
|
|
20815
|
+
class SampleSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
20816
|
+
loadObsIndices() {
|
|
20817
|
+
var _a2;
|
|
20818
|
+
const { options } = this;
|
|
20819
|
+
const obsIndexPromises = (_a2 = options.sampleSets) == null ? void 0 : _a2.map(({ path }) => path).map((pathOrPaths) => {
|
|
20820
|
+
if (Array.isArray(pathOrPaths)) {
|
|
20821
|
+
if (pathOrPaths.length > 0) {
|
|
20822
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths[0]);
|
|
20823
|
+
}
|
|
20824
|
+
return this.dataSource.loadDataFrameIndex();
|
|
20825
|
+
}
|
|
20826
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths);
|
|
20827
|
+
});
|
|
20828
|
+
return Promise.all(obsIndexPromises);
|
|
20829
|
+
}
|
|
20830
|
+
loadCellSetIds() {
|
|
20831
|
+
var _a2;
|
|
20832
|
+
const { options } = this;
|
|
20833
|
+
const cellSetZarrLocation = (_a2 = options.sampleSets) == null ? void 0 : _a2.map(({ path }) => path);
|
|
20834
|
+
return this.dataSource.loadObsColumns(cellSetZarrLocation);
|
|
20835
|
+
}
|
|
20836
|
+
loadCellSetScores() {
|
|
20837
|
+
var _a2;
|
|
20838
|
+
const { options } = this;
|
|
20839
|
+
const cellSetScoreZarrLocation = (_a2 = options.sampleSets) == null ? void 0 : _a2.map((option) => option.scorePath || void 0);
|
|
20840
|
+
return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
|
|
20841
|
+
}
|
|
20842
|
+
async load() {
|
|
20843
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
20844
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
20845
|
+
return Promise.reject(superResult);
|
|
20846
|
+
}
|
|
20847
|
+
if (!this.cachedResult) {
|
|
20848
|
+
const { options } = this;
|
|
20849
|
+
this.cachedResult = Promise.all([
|
|
20850
|
+
this.dataSource.loadDataFrameIndex(),
|
|
20851
|
+
this.loadObsIndices(),
|
|
20852
|
+
this.loadCellSetIds(),
|
|
20853
|
+
this.loadCellSetScores()
|
|
20854
|
+
]).then((data) => [
|
|
20855
|
+
data[0],
|
|
20856
|
+
dataToCellSetsTree([data[1], data[2], data[3]], options.sampleSets)
|
|
20857
|
+
]);
|
|
20858
|
+
}
|
|
20859
|
+
const [obsIndex, obsSets] = await this.cachedResult;
|
|
20860
|
+
const obsSetsMembership = treeToMembershipMap(obsSets);
|
|
20861
|
+
const coordinationValues = {};
|
|
20862
|
+
const { tree } = obsSets;
|
|
20863
|
+
const newAutoSetSelectionParentName = tree[0].name;
|
|
20864
|
+
tree[0].children.map((node) => [
|
|
20865
|
+
newAutoSetSelectionParentName,
|
|
20866
|
+
node.name
|
|
20867
|
+
]);
|
|
20868
|
+
const newAutoSetColors = initializeCellSetColor(obsSets, []);
|
|
20869
|
+
coordinationValues.sampleSetColor = newAutoSetColors;
|
|
20870
|
+
return Promise.resolve(
|
|
20871
|
+
new LoaderResult({
|
|
20872
|
+
sampleIndex: obsIndex,
|
|
20873
|
+
sampleSets: obsSets,
|
|
20874
|
+
sampleSetsMembership: obsSetsMembership
|
|
20875
|
+
}, null, coordinationValues)
|
|
20876
|
+
);
|
|
20877
|
+
}
|
|
20878
|
+
}
|
|
20543
20879
|
class GenomicProfilesZarrLoader extends AbstractTwoStepLoader {
|
|
20544
20880
|
loadAttrs() {
|
|
20545
20881
|
if (this.attrs) {
|
|
@@ -20574,6 +20910,7 @@ export {
|
|
|
20574
20910
|
ObsSetsAnndataLoader,
|
|
20575
20911
|
ObsSpotsAnndataLoader,
|
|
20576
20912
|
SampleEdgesAnndataLoader,
|
|
20913
|
+
SampleSetsAnndataLoader,
|
|
20577
20914
|
ZarrDataSource,
|
|
20578
20915
|
basename,
|
|
20579
20916
|
dirname
|
|
@@ -81,6 +81,13 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
81
81
|
*/
|
|
82
82
|
loadObsIndex(path?: string | undefined): Promise<string[]>;
|
|
83
83
|
obsIndex: Promise<string[]> | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Class method for loading the obs index.
|
|
86
|
+
* @param {string|undefined} path Used by subclasses.
|
|
87
|
+
* @returns {Promise<string[]>} An promise for a zarr array
|
|
88
|
+
* containing the indices.
|
|
89
|
+
*/
|
|
90
|
+
loadDataFrameIndex(path?: string | undefined): Promise<string[]>;
|
|
84
91
|
/**
|
|
85
92
|
* Class method for loading the var index.
|
|
86
93
|
* @param {string|undefined} path Used by subclasses.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,6DAA6D;AAC7D,2EAA2E;AAE3E;;;GAGG;AACH;IACE;;;OAGG;IACH,oBAFW,gBAAgB,EAM1B;IAFC,wEAAwE;IACxE,UADW,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAC3C;IAG3B;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;;OAQG;IACH,oBALW,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAEnB,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CA2B1D;IAED;;;;OAIG;IACH,kBAHW,MAAM,qBAmDhB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAM/B;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,QACN,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,OAAO,CAAC;QACpB,IAAO,EAAE,CAAC,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;QACpD,KAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACxB,CAAC,CAeJ;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAW7B;IAED;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAHC,wCACsE;IAIxE;;;;OAIG;IACH,oBAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAY7B;IAHC,wCACsE;IAIxE;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAiB7B;IALC,cAGC;IAIH;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAI3B;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAoB3B;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAED;;;;OAIG;IACH,mBAHW,MAAM,qCAehB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,EAAE;;OA4BlB;CACF;
|
|
1
|
+
{"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,6DAA6D;AAC7D,2EAA2E;AAE3E;;;GAGG;AACH;IACE;;;OAGG;IACH,oBAFW,gBAAgB,EAM1B;IAFC,wEAAwE;IACxE,UADW,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAC3C;IAG3B;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;;OAQG;IACH,oBALW,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAEnB,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CA2B1D;IAED;;;;OAIG;IACH,kBAHW,MAAM,qBAmDhB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAM/B;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,QACN,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,OAAO,CAAC;QACpB,IAAO,EAAE,CAAC,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;QACpD,KAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACxB,CAAC,CAeJ;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAW7B;IAED;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAHC,wCACsE;IAIxE;;;;;OAKG;IACH,0BAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAU7B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAY7B;IAHC,wCACsE;IAIxE;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAiB7B;IALC,cAGC;IAIH;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAI3B;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAoB3B;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAED;;;;OAIG;IACH,mBAHW,MAAM,qCAehB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,EAAE;;OA4BlB;CACF;2BA1W0B,qBAAqB;2BAGS,eAAe;kDAAf,eAAe;sCAFlC,iBAAiB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
3
|
import { open as zarrOpen, get as zarrGet } from 'zarrita';
|
|
4
|
+
import { log } from '@vitessce/globals';
|
|
4
5
|
import { dirname } from './utils.js';
|
|
5
6
|
import ZarrDataSource from './ZarrDataSource.js';
|
|
6
7
|
/** @import { DataSourceParams } from '@vitessce/types' */
|
|
@@ -173,6 +174,19 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
173
174
|
.then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
|
|
174
175
|
return this.obsIndex;
|
|
175
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Class method for loading the obs index.
|
|
179
|
+
* @param {string|undefined} path Used by subclasses.
|
|
180
|
+
* @returns {Promise<string[]>} An promise for a zarr array
|
|
181
|
+
* containing the indices.
|
|
182
|
+
*/
|
|
183
|
+
loadDataFrameIndex(
|
|
184
|
+
// eslint-disable-next-line no-unused-vars
|
|
185
|
+
path = undefined) {
|
|
186
|
+
const dfPath = path ? dirname(path) : '';
|
|
187
|
+
return this.getJson(`${dfPath}/.zattrs`)
|
|
188
|
+
.then(({ _index }) => this.getFlatArrDecompressed(`${dfPath.length > 0 ? '/' : ''}${dfPath}/${_index}`));
|
|
189
|
+
}
|
|
176
190
|
/**
|
|
177
191
|
* Class method for loading the var index.
|
|
178
192
|
* @param {string|undefined} path Used by subclasses.
|
|
@@ -289,7 +303,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
289
303
|
val = await this._loadElement(`${path}/${key}`);
|
|
290
304
|
}
|
|
291
305
|
catch (e) {
|
|
292
|
-
|
|
306
|
+
log.error(`Error in _loadDict: could not load ${key}`);
|
|
293
307
|
}
|
|
294
308
|
result[key] = val;
|
|
295
309
|
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader for converting zarr into the cell sets json schema.
|
|
3
|
+
*/
|
|
4
|
+
export default class SampleSetsAnndataLoader extends AbstractTwoStepLoader<any> {
|
|
5
|
+
constructor(dataSource: any, params: import("@vitessce/types").LoaderParams);
|
|
6
|
+
loadObsIndices(): Promise<any[]>;
|
|
7
|
+
loadCellSetIds(): any;
|
|
8
|
+
loadCellSetScores(): any;
|
|
9
|
+
load(): Promise<LoaderResult<{
|
|
10
|
+
sampleIndex: any;
|
|
11
|
+
sampleSets: any;
|
|
12
|
+
sampleSetsMembership: Map<any, any>;
|
|
13
|
+
}>>;
|
|
14
|
+
cachedResult: Promise<any[]> | undefined;
|
|
15
|
+
}
|
|
16
|
+
import { AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
17
|
+
import { LoaderResult } from '@vitessce/abstract';
|
|
18
|
+
//# sourceMappingURL=SampleSetsAnndataLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SampleSetsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/SampleSetsAnndataLoader.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;;IACE,iCAkBC;IAED,sBAIC;IAED,yBAKC;IAED;;;;QAuCC;IAhCG,yCAQG;CAyBR;sCArFM,oBAAoB;6BAApB,oBAAoB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/abstract';
|
|
2
|
+
import { initializeCellSetColor, treeToMembershipMap, dataToCellSetsTree, } from '@vitessce/sets-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Loader for converting zarr into the cell sets json schema.
|
|
5
|
+
*/
|
|
6
|
+
export default class SampleSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
7
|
+
loadObsIndices() {
|
|
8
|
+
const { options } = this;
|
|
9
|
+
const obsIndexPromises = options
|
|
10
|
+
.sampleSets
|
|
11
|
+
?.map(({ path }) => path)
|
|
12
|
+
.map((pathOrPaths) => {
|
|
13
|
+
if (Array.isArray(pathOrPaths)) {
|
|
14
|
+
// The multi-level case, try using the first item to get the obsIndex.
|
|
15
|
+
if (pathOrPaths.length > 0) {
|
|
16
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths[0]);
|
|
17
|
+
}
|
|
18
|
+
// pathOrPaths should not be of length 0, but if so, fall back to the default obsIndex.
|
|
19
|
+
return this.dataSource.loadDataFrameIndex();
|
|
20
|
+
}
|
|
21
|
+
// The single-level case.
|
|
22
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths);
|
|
23
|
+
});
|
|
24
|
+
return Promise.all(obsIndexPromises);
|
|
25
|
+
}
|
|
26
|
+
loadCellSetIds() {
|
|
27
|
+
const { options } = this;
|
|
28
|
+
const cellSetZarrLocation = options.sampleSets?.map(({ path }) => path);
|
|
29
|
+
return this.dataSource.loadObsColumns(cellSetZarrLocation);
|
|
30
|
+
}
|
|
31
|
+
loadCellSetScores() {
|
|
32
|
+
const { options } = this;
|
|
33
|
+
const cellSetScoreZarrLocation = options.sampleSets
|
|
34
|
+
?.map(option => option.scorePath || undefined);
|
|
35
|
+
return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
|
|
36
|
+
}
|
|
37
|
+
async load() {
|
|
38
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
39
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
40
|
+
return Promise.reject(superResult);
|
|
41
|
+
}
|
|
42
|
+
if (!this.cachedResult) {
|
|
43
|
+
const { options } = this;
|
|
44
|
+
this.cachedResult = Promise.all([
|
|
45
|
+
this.dataSource.loadDataFrameIndex(),
|
|
46
|
+
this.loadObsIndices(),
|
|
47
|
+
this.loadCellSetIds(),
|
|
48
|
+
this.loadCellSetScores(),
|
|
49
|
+
]).then(data => ([
|
|
50
|
+
data[0],
|
|
51
|
+
dataToCellSetsTree([data[1], data[2], data[3]], options.sampleSets),
|
|
52
|
+
]));
|
|
53
|
+
}
|
|
54
|
+
const [obsIndex, obsSets] = await this.cachedResult;
|
|
55
|
+
const obsSetsMembership = treeToMembershipMap(obsSets);
|
|
56
|
+
const coordinationValues = {};
|
|
57
|
+
const { tree } = obsSets;
|
|
58
|
+
const newAutoSetSelectionParentName = tree[0].name;
|
|
59
|
+
// Create a list of set paths to initally select.
|
|
60
|
+
// eslint-disable-next-line no-unused-vars
|
|
61
|
+
const newAutoSetSelections = tree[0].children.map(node => [
|
|
62
|
+
newAutoSetSelectionParentName,
|
|
63
|
+
node.name,
|
|
64
|
+
]);
|
|
65
|
+
// Create a list of cell set objects with color mappings.
|
|
66
|
+
const newAutoSetColors = initializeCellSetColor(obsSets, []);
|
|
67
|
+
// coordinationValues.sampleSetSelection = newAutoSetSelections;
|
|
68
|
+
coordinationValues.sampleSetColor = newAutoSetColors;
|
|
69
|
+
return Promise.resolve(new LoaderResult({
|
|
70
|
+
sampleIndex: obsIndex,
|
|
71
|
+
sampleSets: obsSets,
|
|
72
|
+
sampleSetsMembership: obsSetsMembership,
|
|
73
|
+
}, null, coordinationValues));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -9,4 +9,5 @@ export { default as ObsLabelsAnndataLoader } from "./ObsLabelsAnndataLoader.js";
|
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from "./FeatureLabelsAnndataLoader.js";
|
|
10
10
|
export { default as ObsFeatureColumnsAnndataLoader } from "./ObsFeatureColumnsAnndataLoader.js";
|
|
11
11
|
export { default as SampleEdgesAnndataLoader } from "./SampleEdgesAnndataLoader.js";
|
|
12
|
+
export { default as SampleSetsAnndataLoader } from "./SampleSetsAnndataLoader.js";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -9,3 +9,4 @@ export { default as ObsLabelsAnndataLoader } from './ObsLabelsAnndataLoader.js';
|
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from './FeatureLabelsAnndataLoader.js';
|
|
10
10
|
export { default as ObsFeatureColumnsAnndataLoader } from './ObsFeatureColumnsAnndataLoader.js';
|
|
11
11
|
export { default as SampleEdgesAnndataLoader } from './SampleEdgesAnndataLoader.js';
|
|
12
|
+
export { default as SampleSetsAnndataLoader } from './SampleSetsAnndataLoader.js';
|
package/dist-tsc/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import { log } from '@vitessce/globals';
|
|
2
3
|
/**
|
|
3
4
|
* Returns the directory part of a path,
|
|
4
5
|
* (before the last '/' character).
|
|
@@ -20,7 +21,7 @@ export function basename(path) {
|
|
|
20
21
|
const arr = path.split('/');
|
|
21
22
|
const result = arr.at(-1);
|
|
22
23
|
if (!result) {
|
|
23
|
-
|
|
24
|
+
log.error('basename of path is empty', path);
|
|
24
25
|
return '';
|
|
25
26
|
}
|
|
26
27
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/zarr",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.7",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -22,19 +22,20 @@
|
|
|
22
22
|
"apache-arrow": "^17.0.0",
|
|
23
23
|
"parquet-wasm": "^0.6.1",
|
|
24
24
|
"ol": "^10.2.1",
|
|
25
|
-
"@vitessce/abstract": "3.5.
|
|
26
|
-
"@vitessce/constants-internal": "3.5.
|
|
27
|
-
"@vitessce/sets-utils": "3.5.
|
|
28
|
-
"@vitessce/image-utils": "3.5.
|
|
29
|
-
"@vitessce/utils": "3.5.
|
|
30
|
-
"@vitessce/zarr-utils": "3.5.
|
|
31
|
-
"@vitessce/config": "3.5.
|
|
25
|
+
"@vitessce/abstract": "3.5.7",
|
|
26
|
+
"@vitessce/constants-internal": "3.5.7",
|
|
27
|
+
"@vitessce/sets-utils": "3.5.7",
|
|
28
|
+
"@vitessce/image-utils": "3.5.7",
|
|
29
|
+
"@vitessce/utils": "3.5.7",
|
|
30
|
+
"@vitessce/zarr-utils": "3.5.7",
|
|
31
|
+
"@vitessce/config": "3.5.7",
|
|
32
|
+
"@vitessce/globals": "3.5.7"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@zarrita/core": "0.1.0-next.14",
|
|
35
36
|
"@zarrita/storage": "0.1.0-next.6",
|
|
36
37
|
"@zarrita/typedarray": "0.1.0-next.3",
|
|
37
|
-
"@vitessce/types": "3.5.
|
|
38
|
+
"@vitessce/types": "3.5.7"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
package/src/AnnDataSource.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
3
|
import { open as zarrOpen, get as zarrGet } from 'zarrita';
|
|
4
|
+
import { log } from '@vitessce/globals';
|
|
4
5
|
import { dirname } from './utils.js';
|
|
5
6
|
import ZarrDataSource from './ZarrDataSource.js';
|
|
6
|
-
|
|
7
7
|
/** @import { DataSourceParams } from '@vitessce/types' */
|
|
8
8
|
/** @import { ByteStringArray } from '@zarrita/typedarray' */
|
|
9
9
|
/** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
|
|
@@ -207,6 +207,21 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
207
207
|
return this.obsIndex;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Class method for loading the obs index.
|
|
212
|
+
* @param {string|undefined} path Used by subclasses.
|
|
213
|
+
* @returns {Promise<string[]>} An promise for a zarr array
|
|
214
|
+
* containing the indices.
|
|
215
|
+
*/
|
|
216
|
+
loadDataFrameIndex(
|
|
217
|
+
// eslint-disable-next-line no-unused-vars
|
|
218
|
+
path = undefined,
|
|
219
|
+
) {
|
|
220
|
+
const dfPath = path ? dirname(path) : '';
|
|
221
|
+
return this.getJson(`${dfPath}/.zattrs`)
|
|
222
|
+
.then(({ _index }) => this.getFlatArrDecompressed(`${dfPath.length > 0 ? '/' : ''}${dfPath}/${_index}`));
|
|
223
|
+
}
|
|
224
|
+
|
|
210
225
|
/**
|
|
211
226
|
* Class method for loading the var index.
|
|
212
227
|
* @param {string|undefined} path Used by subclasses.
|
|
@@ -340,7 +355,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
340
355
|
try {
|
|
341
356
|
val = await this._loadElement(`${path}/${key}`);
|
|
342
357
|
} catch (e) {
|
|
343
|
-
|
|
358
|
+
log.error(`Error in _loadDict: could not load ${key}`);
|
|
344
359
|
}
|
|
345
360
|
result[key] = val;
|
|
346
361
|
}));
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
|
|
3
|
+
} from '@vitessce/abstract';
|
|
4
|
+
import {
|
|
5
|
+
initializeCellSetColor,
|
|
6
|
+
treeToMembershipMap,
|
|
7
|
+
dataToCellSetsTree,
|
|
8
|
+
} from '@vitessce/sets-utils';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Loader for converting zarr into the cell sets json schema.
|
|
13
|
+
*/
|
|
14
|
+
export default class SampleSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
15
|
+
loadObsIndices() {
|
|
16
|
+
const { options } = this;
|
|
17
|
+
const obsIndexPromises = options
|
|
18
|
+
.sampleSets
|
|
19
|
+
?.map(({ path }) => path)
|
|
20
|
+
.map((pathOrPaths) => {
|
|
21
|
+
if (Array.isArray(pathOrPaths)) {
|
|
22
|
+
// The multi-level case, try using the first item to get the obsIndex.
|
|
23
|
+
if (pathOrPaths.length > 0) {
|
|
24
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths[0]);
|
|
25
|
+
}
|
|
26
|
+
// pathOrPaths should not be of length 0, but if so, fall back to the default obsIndex.
|
|
27
|
+
return this.dataSource.loadDataFrameIndex();
|
|
28
|
+
}
|
|
29
|
+
// The single-level case.
|
|
30
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths);
|
|
31
|
+
});
|
|
32
|
+
return Promise.all(obsIndexPromises);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
loadCellSetIds() {
|
|
36
|
+
const { options } = this;
|
|
37
|
+
const cellSetZarrLocation = options.sampleSets?.map(({ path }) => path);
|
|
38
|
+
return this.dataSource.loadObsColumns(cellSetZarrLocation);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
loadCellSetScores() {
|
|
42
|
+
const { options } = this;
|
|
43
|
+
const cellSetScoreZarrLocation = options.sampleSets
|
|
44
|
+
?.map(option => option.scorePath || undefined);
|
|
45
|
+
return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async load() {
|
|
49
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
50
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
51
|
+
return Promise.reject(superResult);
|
|
52
|
+
}
|
|
53
|
+
if (!this.cachedResult) {
|
|
54
|
+
const { options } = this;
|
|
55
|
+
this.cachedResult = Promise.all([
|
|
56
|
+
this.dataSource.loadDataFrameIndex(),
|
|
57
|
+
this.loadObsIndices(),
|
|
58
|
+
this.loadCellSetIds(),
|
|
59
|
+
this.loadCellSetScores(),
|
|
60
|
+
]).then(data => ([
|
|
61
|
+
data[0],
|
|
62
|
+
dataToCellSetsTree([data[1], data[2], data[3]], options.sampleSets),
|
|
63
|
+
]));
|
|
64
|
+
}
|
|
65
|
+
const [obsIndex, obsSets] = await this.cachedResult;
|
|
66
|
+
const obsSetsMembership = treeToMembershipMap(obsSets);
|
|
67
|
+
const coordinationValues = {};
|
|
68
|
+
const { tree } = obsSets;
|
|
69
|
+
const newAutoSetSelectionParentName = tree[0].name;
|
|
70
|
+
// Create a list of set paths to initally select.
|
|
71
|
+
// eslint-disable-next-line no-unused-vars
|
|
72
|
+
const newAutoSetSelections = tree[0].children.map(node => [
|
|
73
|
+
newAutoSetSelectionParentName,
|
|
74
|
+
node.name,
|
|
75
|
+
]);
|
|
76
|
+
// Create a list of cell set objects with color mappings.
|
|
77
|
+
const newAutoSetColors = initializeCellSetColor(obsSets, []);
|
|
78
|
+
// coordinationValues.sampleSetSelection = newAutoSetSelections;
|
|
79
|
+
coordinationValues.sampleSetColor = newAutoSetColors;
|
|
80
|
+
return Promise.resolve(
|
|
81
|
+
new LoaderResult({
|
|
82
|
+
sampleIndex: obsIndex,
|
|
83
|
+
sampleSets: obsSets,
|
|
84
|
+
sampleSetsMembership: obsSetsMembership,
|
|
85
|
+
}, null, coordinationValues),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -9,3 +9,4 @@ export { default as ObsLabelsAnndataLoader } from './ObsLabelsAnndataLoader.js';
|
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from './FeatureLabelsAnndataLoader.js';
|
|
10
10
|
export { default as ObsFeatureColumnsAnndataLoader } from './ObsFeatureColumnsAnndataLoader.js';
|
|
11
11
|
export { default as SampleEdgesAnndataLoader } from './SampleEdgesAnndataLoader.js';
|
|
12
|
+
export { default as SampleSetsAnndataLoader } from './SampleSetsAnndataLoader.js';
|
package/src/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { log } from '@vitessce/globals';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the directory part of a path,
|
|
5
5
|
* (before the last '/' character).
|
|
@@ -22,7 +22,7 @@ export function basename(path) {
|
|
|
22
22
|
const arr = path.split('/');
|
|
23
23
|
const result = arr.at(-1);
|
|
24
24
|
if (!result) {
|
|
25
|
-
|
|
25
|
+
log.error('basename of path is empty', path);
|
|
26
26
|
return '';
|
|
27
27
|
}
|
|
28
28
|
return result;
|