Skip to content

Commit 8c19c4c

Browse files
authored
NickAkhmetov/Add requestInit param to MultivecZarrWrapper (#335)
1 parent a74c8ad commit 8c19c4c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vitessce/wrappers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ def __init__(self, **kwargs):
3636
Abstract constructor to be inherited by dataset wrapper classes.
3737
3838
:param str out_dir: The path to a local directory used for data processing outputs. By default, uses a temp. directory.
39+
:param dict request_init: options to be passed along with every fetch request from the browser, like `{ "header": { "Authorization": "Bearer dsfjalsdfa1431" } }`
3940
"""
4041
self.out_dir = kwargs['out_dir'] if 'out_dir' in kwargs else tempfile.mkdtemp(
4142
)
4243
self.routes = []
4344
self.is_remote = False
4445
self.file_def_creators = []
4546
self.base_dir = None
47+
self._request_init = kwargs['request_init'] if 'request_init' in kwargs else None
4648

4749
def __repr__(self):
4850
return self._repr
@@ -894,7 +896,7 @@ def image_file_def_creator(base_url):
894896

895897

896898
class AnnDataWrapper(AbstractWrapper):
897-
def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None, feature_filter_path=None, initial_feature_filter_path=None, obs_set_paths=None, obs_set_names=None, obs_locations_path=None, obs_segmentations_path=None, obs_embedding_paths=None, obs_embedding_names=None, obs_embedding_dims=None, obs_spots_path=None, obs_points_path=None, request_init=None, feature_labels_path=None, obs_labels_path=None, convert_to_dense=True, coordination_values=None, obs_labels_paths=None, obs_labels_names=None, **kwargs):
899+
def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None, feature_filter_path=None, initial_feature_filter_path=None, obs_set_paths=None, obs_set_names=None, obs_locations_path=None, obs_segmentations_path=None, obs_embedding_paths=None, obs_embedding_names=None, obs_embedding_dims=None, obs_spots_path=None, obs_points_path=None, feature_labels_path=None, obs_labels_path=None, convert_to_dense=True, coordination_values=None, obs_labels_paths=None, obs_labels_names=None, **kwargs):
898900
"""
899901
Wrap an AnnData object by creating an instance of the ``AnnDataWrapper`` class.
900902
@@ -912,7 +914,6 @@ def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None
912914
:param list[str] obs_embedding_dims: Dimensions along which to get data for the scatterplot, like `[[0, 1], [4, 5]]` where `[0, 1]` is just the normal x and y but `[4, 5]` could be comparing the third and fourth principal components, for example.
913915
:param str obs_spots_path: Column name in `obsm` that contains centroid coordinates for displaying spots in the spatial viewer
914916
:param str obs_points_path: Column name in `obsm` that contains centroid coordinates for displaying points in the spatial viewer
915-
:param dict request_init: options to be passed along with every fetch request from the browser, like `{ "header": { "Authorization": "Bearer dsfjalsdfa1431" } }`
916917
:param str feature_labels_path: The name of a column containing feature labels (e.g., alternate gene symbols), instead of the default index in `var` of the AnnData store.
917918
:param str obs_labels_path: (DEPRECATED) The name of a column containing observation labels (e.g., alternate cell IDs), instead of the default index in `obs` of the AnnData store. Use `obs_labels_paths` and `obs_labels_names` instead. This arg will be removed in a future release.
918919
:param list[str] obs_labels_paths: The names of columns containing observation labels (e.g., alternate cell IDs), instead of the default index in `obs` of the AnnData store.
@@ -951,7 +952,6 @@ def __init__(self, adata_path=None, adata_url=None, obs_feature_matrix_path=None
951952
self._mappings_obsm_dims = obs_embedding_dims
952953
self._spatial_spots_obsm = obs_spots_path
953954
self._spatial_points_obsm = obs_points_path
954-
self._request_init = request_init
955955
self._gene_alias = feature_labels_path
956956
# Support legacy provision of single obs labels path
957957
if (obs_labels_path is not None):
@@ -1138,8 +1138,11 @@ def get_zarr_url(self, base_url="", dataset_uid="", obj_i=""):
11381138

11391139
def make_genomic_profiles_file_def_creator(self, dataset_uid, obj_i):
11401140
def genomic_profiles_file_def_creator(base_url):
1141-
return {
1141+
obj_file_def = {
11421142
"fileType": "genomic-profiles.zarr",
11431143
"url": self.get_zarr_url(base_url, dataset_uid, obj_i)
11441144
}
1145+
if self._request_init is not None:
1146+
obj_file_def['requestInit'] = self._request_init
1147+
return obj_file_def
11451148
return genomic_profiles_file_def_creator

0 commit comments

Comments
 (0)