From 02c799f918d4c10513386086371c5f5db753b79a Mon Sep 17 00:00:00 2001 From: kaloster Date: Tue, 13 Feb 2024 13:48:23 -0500 Subject: [PATCH 1/5] chore: changes to add uns metadata for spatial --- backend/common/utils/cxg_generation_utils.py | 14 ++++++++++---- backend/layers/processing/h5ad_data_file.py | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/common/utils/cxg_generation_utils.py b/backend/common/utils/cxg_generation_utils.py index 5cfecf321249c..bf9e67bc40ddd 100644 --- a/backend/common/utils/cxg_generation_utils.py +++ b/backend/common/utils/cxg_generation_utils.py @@ -22,13 +22,19 @@ def convert_dictionary_to_cxg_group(cxg_container, metadata_dict, group_metadata array_name = f"{cxg_container}/{group_metadata_name}" # Because TileDB does not allow one to attach metadata directly to a CXG group, we need to have a workaround - # where we create an empty array and attached the metadata onto to this empty array. Below we construct this empty + # where we create an empty array and attach the metadata onto to this empty array. Below we construct this empty # array. tiledb.from_numpy(array_name, np.zeros((1,))) - with tiledb.open(array_name, mode="w", ctx=ctx) as metadata_array: - for key, value in metadata_dict.items(): - metadata_array.meta[key] = value + def iterate_over_dict(metadata_dict): + with tiledb.open(array_name, mode="w", ctx=ctx) as metadata_array: + for key, value in metadata_dict.items(): + if isinstance(value, dict): + iterate_over_dict(value) + else: + metadata_array.meta[key] = value + + iterate_over_dict(metadata_dict) def convert_dataframe_to_cxg_array(cxg_container, dataframe_name, dataframe, index_column_name, ctx): diff --git a/backend/layers/processing/h5ad_data_file.py b/backend/layers/processing/h5ad_data_file.py index 26022a372a063..ca86609b59629 100644 --- a/backend/layers/processing/h5ad_data_file.py +++ b/backend/layers/processing/h5ad_data_file.py @@ -79,6 +79,9 @@ def to_cxg(self, output_cxg_directory, sparse_threshold, convert_anndata_colors_ convert_dataframe_to_cxg_array(output_cxg_directory, "var", self.var, self.var_index_column_name, ctx) logging.info("\t...dataset var dataframe saved") + convert_dictionary_to_cxg_group(output_cxg_directory, self.anndata.uns, "uns", ctx) + logging.info("\t...dataset uns dataframe saved") + self.write_anndata_embeddings_to_cxg(output_cxg_directory, ctx) logging.info("\t...dataset embeddings saved") @@ -175,6 +178,7 @@ def extract_anndata_elements_from_file(self): self.obs = self.transform_dataframe_index_into_column(self.anndata.obs, "obs", self.obs_index_column_name) self.var = self.transform_dataframe_index_into_column(self.anndata.var, "var", self.var_index_column_name) + def extract_metadata_about_dataset(self): """ Extract metadata information about the dataset that upon conversion will be saved as group metadata with the From b5c643640c966b83f6d1987be3cba79c4ad706b8 Mon Sep 17 00:00:00 2001 From: kaloster Date: Tue, 13 Feb 2024 13:52:10 -0500 Subject: [PATCH 2/5] chore: changes to add uns metadata for spatial --- backend/layers/processing/h5ad_data_file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/layers/processing/h5ad_data_file.py b/backend/layers/processing/h5ad_data_file.py index ca86609b59629..965bac42e9f8a 100644 --- a/backend/layers/processing/h5ad_data_file.py +++ b/backend/layers/processing/h5ad_data_file.py @@ -178,7 +178,6 @@ def extract_anndata_elements_from_file(self): self.obs = self.transform_dataframe_index_into_column(self.anndata.obs, "obs", self.obs_index_column_name) self.var = self.transform_dataframe_index_into_column(self.anndata.var, "var", self.var_index_column_name) - def extract_metadata_about_dataset(self): """ Extract metadata information about the dataset that upon conversion will be saved as group metadata with the From 05c0e285d15dcd093ed115e73e2e3da65b16fd92 Mon Sep 17 00:00:00 2001 From: kaloster Date: Thu, 28 Mar 2024 21:21:30 +0200 Subject: [PATCH 3/5] revised script --- backend/common/utils/cxg_generation_utils.py | 27 +++++++++++++++++--- backend/layers/processing/h5ad_data_file.py | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/common/utils/cxg_generation_utils.py b/backend/common/utils/cxg_generation_utils.py index bf9e67bc40ddd..6d76e57a1a085 100644 --- a/backend/common/utils/cxg_generation_utils.py +++ b/backend/common/utils/cxg_generation_utils.py @@ -1,5 +1,6 @@ import json import logging +import pickle import numpy as np import pandas as pd @@ -22,17 +23,37 @@ def convert_dictionary_to_cxg_group(cxg_container, metadata_dict, group_metadata array_name = f"{cxg_container}/{group_metadata_name}" # Because TileDB does not allow one to attach metadata directly to a CXG group, we need to have a workaround - # where we create an empty array and attach the metadata onto to this empty array. Below we construct this empty + # where we create an empty array and attached the metadata onto to this empty array. Below we construct this empty # array. tiledb.from_numpy(array_name, np.zeros((1,))) + with tiledb.open(array_name, mode="w", ctx=ctx) as metadata_array: + for key, value in metadata_dict.items(): + metadata_array.meta[key] = value + + +def convert_uns_to_cxg_group(cxg_container, metadata_dict, group_metadata_name="cxg_group_metadata", ctx=None): + + array_name = f"{cxg_container}/{group_metadata_name}" + + tiledb.from_numpy(array_name, np.zeros((1,))) + def iterate_over_dict(metadata_dict): with tiledb.open(array_name, mode="w", ctx=ctx) as metadata_array: for key, value in metadata_dict.items(): + if not key.startswith("spatial"): + continue + print(f"key: {key}, type:{type(value)}, value: {value}") if isinstance(value, dict): - iterate_over_dict(value) + try: + metadata_array.meta[key] = pickle.dumps(value) + except Exception as e: + logging.error(f"Error adding metadata {key} to {array_name}: {e}") else: - metadata_array.meta[key] = value + try: + metadata_array.meta[key] = value + except Exception as e: + logging.error(f"Error adding metadata {key} to {array_name}: {e}") iterate_over_dict(metadata_dict) diff --git a/backend/layers/processing/h5ad_data_file.py b/backend/layers/processing/h5ad_data_file.py index 965bac42e9f8a..5ed297159862b 100644 --- a/backend/layers/processing/h5ad_data_file.py +++ b/backend/layers/processing/h5ad_data_file.py @@ -18,6 +18,7 @@ convert_dictionary_to_cxg_group, convert_matrices_to_cxg_arrays, convert_ndarray_to_cxg_dense_array, + convert_uns_to_cxg_group, ) from backend.common.utils.matrix_utils import is_matrix_sparse from backend.common.utils.tiledb import consolidation_buffer_size @@ -79,7 +80,7 @@ def to_cxg(self, output_cxg_directory, sparse_threshold, convert_anndata_colors_ convert_dataframe_to_cxg_array(output_cxg_directory, "var", self.var, self.var_index_column_name, ctx) logging.info("\t...dataset var dataframe saved") - convert_dictionary_to_cxg_group(output_cxg_directory, self.anndata.uns, "uns", ctx) + convert_uns_to_cxg_group(output_cxg_directory, self.anndata.uns, "uns", ctx) logging.info("\t...dataset uns dataframe saved") self.write_anndata_embeddings_to_cxg(output_cxg_directory, ctx) From 0b05e85b6839ecdcd525b8697158858b86d26325 Mon Sep 17 00:00:00 2001 From: kaloster Date: Mon, 1 Apr 2024 11:08:35 +0300 Subject: [PATCH 4/5] make cxg notebook --- make_cxg.ipynb | 291 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 make_cxg.ipynb diff --git a/make_cxg.ipynb b/make_cxg.ipynb new file mode 100644 index 0000000000000..a97d2aeef587e --- /dev/null +++ b/make_cxg.ipynb @@ -0,0 +1,291 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from backend.layers.processing.h5ad_data_file import H5ADDataFile\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", + "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "key: spatial, type:, value: {'WSA_LngSP10193345': {'images': {'fullres': array([[[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]],\n", + "\n", + " [[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]],\n", + "\n", + " [[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]],\n", + "\n", + " ...,\n", + "\n", + " [[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]],\n", + "\n", + " [[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]],\n", + "\n", + " [[244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " ...,\n", + " [244, 240, 240],\n", + " [244, 240, 240],\n", + " [244, 240, 240]]], dtype=uint8), 'hires': array([[[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]],\n", + "\n", + " [[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]],\n", + "\n", + " [[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]],\n", + "\n", + " ...,\n", + "\n", + " [[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]],\n", + "\n", + " [[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]],\n", + "\n", + " [[0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " ...,\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ],\n", + " [0.95686275, 0.9411765 , 0.9411765 ]]], dtype=float32)}, 'metadata': {'chemistry_description': \"Spatial 3' v1\", 'software_version': 'spaceranger-1.1.0'}, 'scalefactors': {'spot_diameter_fullres': 148.37971291260436, 'tissue_hires_scalef': 0.056960583}}}\n" + ] + }, + { + "data": { + "text/plain": [ + "'UXR_0bb15784-1cea-47e1-9a00-57dcd127746c.cxg'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def make_cxg(local_filename):\n", + " \"\"\"\n", + " Convert the uploaded H5AD file to the CXG format servicing the cellxgene Explorer.\n", + " \"\"\"\n", + "\n", + " cxg_output_container = local_filename.replace(\".h5ad\", \".cxg\")\n", + " try:\n", + " h5ad_data_file = H5ADDataFile(local_filename, var_index_column_name=\"feature_name\")\n", + " h5ad_data_file.to_cxg(cxg_output_container, sparse_threshold=25.0)\n", + " except Exception as ex:\n", + " # TODO use a specialized exception\n", + " msg = \"CXG conversion failed.\"\n", + "\n", + " raise RuntimeError(msg) from ex\n", + " raise ex\n", + "\n", + " return cxg_output_container\n", + "\n", + "make_cxg(\"UXR_0bb15784-1cea-47e1-9a00-57dcd127746c.h5ad\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b68d9165d887aca1a17391242722ed4b787e4ff2 Mon Sep 17 00:00:00 2001 From: kaloster Date: Mon, 1 Apr 2024 11:12:42 +0300 Subject: [PATCH 5/5] make cxg notebook --- make_cxg.ipynb | 236 +------------------------------------------------ 1 file changed, 3 insertions(+), 233 deletions(-) diff --git a/make_cxg.ipynb b/make_cxg.ipynb index a97d2aeef587e..7639cc7625339 100644 --- a/make_cxg.ipynb +++ b/make_cxg.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -11,239 +11,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n", - "WARNING:root:Type float64 will be converted to 32 bit float and may lose precision.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "key: spatial, type:, value: {'WSA_LngSP10193345': {'images': {'fullres': array([[[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]],\n", - "\n", - " [[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]],\n", - "\n", - " [[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]],\n", - "\n", - " ...,\n", - "\n", - " [[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]],\n", - "\n", - " [[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]],\n", - "\n", - " [[244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " ...,\n", - " [244, 240, 240],\n", - " [244, 240, 240],\n", - " [244, 240, 240]]], dtype=uint8), 'hires': array([[[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]],\n", - "\n", - " [[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]],\n", - "\n", - " [[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]],\n", - "\n", - " ...,\n", - "\n", - " [[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]],\n", - "\n", - " [[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]],\n", - "\n", - " [[0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " ...,\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ],\n", - " [0.95686275, 0.9411765 , 0.9411765 ]]], dtype=float32)}, 'metadata': {'chemistry_description': \"Spatial 3' v1\", 'software_version': 'spaceranger-1.1.0'}, 'scalefactors': {'spot_diameter_fullres': 148.37971291260436, 'tissue_hires_scalef': 0.056960583}}}\n" - ] - }, - { - "data": { - "text/plain": [ - "'UXR_0bb15784-1cea-47e1-9a00-57dcd127746c.cxg'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "def make_cxg(local_filename):\n", " \"\"\"\n",