Skip to content

Commit 1c92e7c

Browse files
committed
Add metadata
1 parent 42931a9 commit 1c92e7c

35 files changed

+9049
-8769
lines changed
Lines changed: 186 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,182 +1,190 @@
11
{
2-
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"id": "Hbol",
7-
"metadata": {},
8-
"outputs": [],
9-
"source": [
10-
"import marimo as mo"
11-
]
12-
},
13-
{
14-
"cell_type": "markdown",
15-
"id": "MJUe",
16-
"metadata": {
17-
"marimo": {
18-
"config": {
19-
"hide_code": true
20-
}
21-
}
22-
},
23-
"source": [
24-
"# Load UCSC Cell Browser project in Vitessce"
25-
]
26-
},
27-
{
28-
"cell_type": "markdown",
29-
"id": "vblA",
30-
"metadata": {
31-
"marimo": {
32-
"config": {
33-
"hide_code": true
34-
}
35-
}
36-
},
37-
"source": [
38-
"This notebook shows you how to use the `convert_cell_browser_project_to_anndata` function, which allows you to take an existing project, published in https://cells.ucsc.edu/ and:\n",
39-
"1. Convert it into the AnnData format that is supported by Vitessce\n",
40-
"2. Save the AnnData object as a Zarr store\n",
41-
"3. Configure Vitessce with the AnnData-Zarr store\n",
42-
"4. Render a Vitessce widget based on the config (step 3) directly in the notebook.\n",
43-
"\n",
44-
"The dataset that you choose to convert needs to be a valid UCSC Cell Browser \"project\", accessible from https://cells.ucsc.edu/, with a configuration available in https://github.com/ucscGenomeBrowser/cellbrowser-confs\n",
45-
"\n",
46-
"The `convert_cell_browser_project_to_anndata` function takes the name of that project as an input. For example, to convert this project, https://cells.ucsc.edu/?ds=adultPancreas, you will neeed to pass `\"adultPancreas\"` as the project name."
47-
]
48-
},
49-
{
50-
"cell_type": "code",
51-
"execution_count": null,
52-
"id": "bkHC",
53-
"metadata": {},
54-
"outputs": [],
55-
"source": [
56-
"import os\n",
57-
"import json\n",
58-
"from os.path import join\n",
59-
"from vitessce import (\n",
60-
" convert_cell_browser_project_to_anndata,\n",
61-
" AnnDataWrapper,\n",
62-
" VitessceConfig,\n",
63-
")\n",
64-
"from vitessce.data_utils import VAR_CHUNK_SIZE"
65-
]
66-
},
67-
{
68-
"cell_type": "markdown",
69-
"id": "lEQa",
70-
"metadata": {
71-
"marimo": {
72-
"config": {
73-
"hide_code": true
74-
}
75-
}
76-
},
77-
"source": [
78-
"## 1. Convert UCSC Cell Browser project to a format that is supported by Vitessce\n",
79-
"#### Output:\n",
80-
"An AnnData object"
81-
]
82-
},
83-
{
84-
"cell_type": "code",
85-
"execution_count": null,
86-
"id": "PKri",
87-
"metadata": {},
88-
"outputs": [],
89-
"source": [
90-
"# Example run, coverting \"adultPancreas\" project:\n",
91-
"adata = convert_cell_browser_project_to_anndata(project_name=\"adultPancreas\", keep_only_marker_genes=True)"
92-
]
93-
},
94-
{
95-
"cell_type": "markdown",
96-
"id": "Xref",
97-
"metadata": {
98-
"marimo": {
99-
"config": {
100-
"hide_code": true
101-
}
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "MJUe",
6+
"metadata": {
7+
"marimo": {
8+
"config": {
9+
"hide_code": true
10+
}
11+
}
12+
},
13+
"source": [
14+
"# Load UCSC Cell Browser project in Vitessce"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"id": "vblA",
20+
"metadata": {
21+
"marimo": {
22+
"config": {
23+
"hide_code": true
24+
}
25+
}
26+
},
27+
"source": [
28+
"This notebook shows you how to use the `convert_cell_browser_project_to_anndata` function, which allows you to take an existing project, published in https://cells.ucsc.edu/ and:\n",
29+
"1. Convert it into the AnnData format that is supported by Vitessce\n",
30+
"2. Save the AnnData object as a Zarr store\n",
31+
"3. Configure Vitessce with the AnnData-Zarr store\n",
32+
"4. Render a Vitessce widget based on the config (step 3) directly in the notebook.\n",
33+
"\n",
34+
"The dataset that you choose to convert needs to be a valid UCSC Cell Browser \"project\", accessible from https://cells.ucsc.edu/, with a configuration available in https://github.com/ucscGenomeBrowser/cellbrowser-confs\n",
35+
"\n",
36+
"The `convert_cell_browser_project_to_anndata` function takes the name of that project as an input. For example, to convert this project, https://cells.ucsc.edu/?ds=adultPancreas, you will neeed to pass `\"adultPancreas\"` as the project name."
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"id": "bkHC",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"import os\n",
47+
"import json\n",
48+
"from os.path import join\n",
49+
"from vitessce import (\n",
50+
" convert_cell_browser_project_to_anndata,\n",
51+
" AnnDataWrapper,\n",
52+
" VitessceConfig,\n",
53+
")\n",
54+
"from vitessce.data_utils import VAR_CHUNK_SIZE"
55+
]
56+
},
57+
{
58+
"cell_type": "markdown",
59+
"id": "lEQa",
60+
"metadata": {
61+
"marimo": {
62+
"config": {
63+
"hide_code": true
64+
}
65+
}
66+
},
67+
"source": [
68+
"## 1. Convert UCSC Cell Browser project to a format that is supported by Vitessce\n",
69+
"#### Output:\n",
70+
"An AnnData object"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"id": "PKri",
77+
"metadata": {},
78+
"outputs": [],
79+
"source": [
80+
"# Example run, coverting \"adultPancreas\" project:\n",
81+
"adata = convert_cell_browser_project_to_anndata(project_name=\"adultPancreas\", keep_only_marker_genes=True)"
82+
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"id": "Xref",
87+
"metadata": {
88+
"marimo": {
89+
"config": {
90+
"hide_code": true
91+
}
92+
}
93+
},
94+
"source": [
95+
"## 2. Save the AnnData object as a Zarr store"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": null,
101+
"id": "SFPL",
102+
"metadata": {},
103+
"outputs": [],
104+
"source": [
105+
"zarr_filepath = join(\"data\", \"out.adata.zarr\")\n",
106+
"os.makedirs(os.path.dirname(zarr_filepath), exist_ok=True)\n",
107+
"adata.write_zarr(zarr_filepath, chunks=[adata.shape[0], VAR_CHUNK_SIZE])"
108+
]
109+
},
110+
{
111+
"cell_type": "markdown",
112+
"id": "BYtC",
113+
"metadata": {
114+
"marimo": {
115+
"config": {
116+
"hide_code": true
117+
}
118+
}
119+
},
120+
"source": [
121+
"## 3. Configure Vitessce with the AnnData-Zarr store"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": null,
127+
"id": "RGSE",
128+
"metadata": {},
129+
"outputs": [],
130+
"source": [
131+
"anndata_wrapper_inst = AnnDataWrapper(\n",
132+
" adata_path=zarr_filepath,\n",
133+
" obs_feature_matrix_path=\"X\",\n",
134+
" obs_embedding_paths=[\"obsm/X_tsne\"],\n",
135+
" obs_embedding_names=[\"t-SNE\"],\n",
136+
" obs_set_paths=[\"obs/cluster\", \"obs/age\"],\n",
137+
" obs_set_names=[\"cluster\", \"age\"],\n",
138+
")\n",
139+
"vc = VitessceConfig(schema_version=\"1.0.15\", name=\"Vitessce configuration for CellBrowser project adultPancreas\")\n",
140+
"anndata_wrapper_inst.auto_view_config(vc)"
141+
]
142+
},
143+
{
144+
"cell_type": "markdown",
145+
"id": "Kclp",
146+
"metadata": {
147+
"marimo": {
148+
"config": {
149+
"hide_code": true
150+
}
151+
}
152+
},
153+
"source": [
154+
"## 4. Render the Vitessce widget"
155+
]
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": null,
160+
"id": "emfo",
161+
"metadata": {},
162+
"outputs": [],
163+
"source": [
164+
"vw = vc.widget()\n",
165+
"vw"
166+
]
102167
}
103-
},
104-
"source": [
105-
"## 2. Save the AnnData object as a Zarr store"
106-
]
107-
},
108-
{
109-
"cell_type": "code",
110-
"execution_count": null,
111-
"id": "SFPL",
112-
"metadata": {},
113-
"outputs": [],
114-
"source": [
115-
"zarr_filepath = join(\"data\", \"out.adata.zarr\")\n",
116-
"os.makedirs(os.path.dirname(zarr_filepath), exist_ok=True)\n",
117-
"adata.write_zarr(zarr_filepath, chunks=[adata.shape[0], VAR_CHUNK_SIZE])"
118-
]
119-
},
120-
{
121-
"cell_type": "markdown",
122-
"id": "BYtC",
123-
"metadata": {
124-
"marimo": {
125-
"config": {
126-
"hide_code": true
127-
}
128-
}
129-
},
130-
"source": [
131-
"## 3. Configure Vitessce with the AnnData-Zarr store"
132-
]
133-
},
134-
{
135-
"cell_type": "code",
136-
"execution_count": null,
137-
"id": "RGSE",
138-
"metadata": {},
139-
"outputs": [],
140-
"source": [
141-
"anndata_wrapper_inst = AnnDataWrapper(\n",
142-
" adata_path=zarr_filepath,\n",
143-
" obs_feature_matrix_path=\"X\",\n",
144-
" obs_embedding_paths=[\"obsm/X_tsne\"],\n",
145-
" obs_embedding_names=[\"t-SNE\"],\n",
146-
" obs_set_paths=[\"obs/cluster\", \"obs/age\"],\n",
147-
" obs_set_names=[\"cluster\", \"age\"],\n",
148-
")\n",
149-
"vc = VitessceConfig(schema_version=\"1.0.15\", name=\"Vitessce configuration for CellBrowser project adultPancreas\")\n",
150-
"anndata_wrapper_inst.auto_view_config(vc)"
151-
]
152-
},
153-
{
154-
"cell_type": "markdown",
155-
"id": "Kclp",
156-
"metadata": {
157-
"marimo": {
158-
"config": {
159-
"hide_code": true
160-
}
168+
],
169+
"metadata": {
170+
"kernelspec": {
171+
"display_name": "Python 3 (ipykernel)",
172+
"language": "python",
173+
"name": "python3"
174+
},
175+
"language_info": {
176+
"codemirror_mode": {
177+
"name": "ipython",
178+
"version": 3
179+
},
180+
"file_extension": ".py",
181+
"mimetype": "text/x-python",
182+
"name": "python",
183+
"nbconvert_exporter": "python",
184+
"pygments_lexer": "ipython3",
185+
"version": "3.10.14"
161186
}
162-
},
163-
"source": [
164-
"## 4. Render the Vitessce widget"
165-
]
166187
},
167-
{
168-
"cell_type": "code",
169-
"execution_count": null,
170-
"id": "emfo",
171-
"metadata": {},
172-
"outputs": [],
173-
"source": [
174-
"vw = vc.widget()\n",
175-
"vw"
176-
]
177-
}
178-
],
179-
"metadata": {},
180-
"nbformat": 4,
181-
"nbformat_minor": 5
182-
}
188+
"nbformat": 4,
189+
"nbformat_minor": 5
190+
}

0 commit comments

Comments
 (0)