Skip to content

Commit

Permalink
deploy: c208f7e
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mueller committed Sep 2, 2024
1 parent 2c5c901 commit 5b43f58
Show file tree
Hide file tree
Showing 19 changed files with 798 additions and 23 deletions.
Binary file added _images/new_tag0.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/new_tag1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions _sources/notebooks/metadata/01_key_value_pairs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"(omero-tools:key-value-pairs)=\n",
"\n",
"# Reading, writing and editing key-value pairs\n",
"\n",
"Key value pairs are a key (pun intended) part of annotating data in OMERO in a very flexible way. In essence, they provide a way of adding Python dictionaries to an image, a project or a dataset - and a Python dictionary is fit for data of virtually any form. Here are a few ways of interacting with data in this form through Python."
Expand Down
184 changes: 184 additions & 0 deletions _sources/notebooks/metadata/04_tagging_data.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to tag and retrieve tags from data\n",
"\n",
"Another key concept of organizing data on OMERO (besides [key-value pairs](omero-tools:key-value-pairs)) is given by *tags*. Can be used to group data in a more flexible way than the hierarchy of projects, datasets and images. For a more in-depth explanation of some of the underlying concepts, see [these excellent training materials](https://zenodo.org/records/8323588) regarding OMERO in general."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import ezomero"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"host = 'omero-int.biotec.tu-dresden.de'\n",
"user = '' # replace this with your username\n",
"secure = True\n",
"port = 4064\n",
"group = 'default'\n",
"\n",
"conn = ezomero.connect(host=host, user=user, secure=secure, port=port, group=group)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Tagging data\n",
"\n",
"The easiest and most straightforward way to tag your data is arguably to simply do this through the web interface of your OMERO servers. Omero extensions such as the excellent [autotag](https://pypi.org/project/omero-autotag/) extension make setting meaningful tags on your data a breeze. The question then becomes - how do you retrieve tags that have already been added to your data?\n",
"\n",
"## Reading tags from OMERO\n",
"\n",
"Let's use [ezomero](https://thejacksonlaboratory.github.io/ezomero/) again to retrieve tags that have been added to an image. This will return a list of tags (indicated by their respective ids) that have been added to the image. This is an important concept to grasp: Just like an image, a tag is an object in the OMERO database, and it has a unique identifier (id). This id is what is returned when you retrieve tags from an image."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1088]\n"
]
}
],
"source": [
"tag_ids = ezomero.get_tag_ids(conn, object_type='Image', object_id=330, ns=None)\n",
"print(tag_ids)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we want to see the \"value\" of the tag, we can use the `get_tag` function to introspect the ids we just retrieved:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Fluorescence'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ezomero.get_tag(conn, tag_id=tag_ids[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adding a tag to data\n",
"\n",
"Adding a tag to an image is a little less straightforward. For once, it makes more sense to create and organize the tags through the web interface. The [following tutorial](omero-tools:synchronize-tags) introduces a way to set tags and tag groups from a yaml file, but this is a bit more complicated. For simplicity, let's assume we already created some tags and we know their ids from the web interface:\n",
"\n",
"![new tag list](./imgs/new_tag0.PNG)\n",
"![new tag](./imgs/new_tag1.PNG)\n",
"\n",
"To add this newly created tag to our image, we need to first retrieve both the tag and the image objects from the remote server:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"tag_object = conn.getObject('Annotation', 8354)\n",
"image_object = conn.getObject('Image', 330)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the next step, we link the tag to the image:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"image_object.linkAnnotation(tag_object)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's check whether this worked:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fluorescence (Tag id: 1088)\n",
"Raw data (Tag id: 8354)\n"
]
}
],
"source": [
"tag_ids = ezomero.get_tag_ids(conn, object_type='Image', object_id=330, ns=None)\n",
"\n",
"for tag_id in tag_ids:\n",
" print(ezomero.get_tag(conn, tag_id=tag_id), ' ', f'(Tag id: {tag_id})')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "stress",
"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.19"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"(omero-tools:synchronize-tags)=\n",
"\n",
"# Synchronize tags across groups\n",
"\n",
"To make sure that there is some standardization across projects with regard to how data is tagged and annotated, we need to synchronize tags across groups. The goal is to make sure that the tags used in the data are consistent across groups. This will make it easier to search for data and to use the data in the future. The defined tags themselves are based off of the [REMBI metadata schema](https://www.nature.com/articles/s41592-021-01166-8). More specifically, we orient ourselves on the tags used in the [provided spreadsheet](https://docs.google.com/spreadsheets/d/1Ck1NeLp-ZN4eMGdNYo2nV6KLEdSfN6oQBKnnWU6Npeo/edit).\n",
Expand Down
3 changes: 2 additions & 1 deletion genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/01_key_value_pairs.html">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/02_setting_pixel_sizes.html">Setting pixel sizes of an image</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/03_setting_channel_names.html">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/01_key_value_pairs.html">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/02_setting_pixel_sizes.html">Setting pixel sizes of an image</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/03_setting_channel_names.html">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/metadata/05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down
7 changes: 4 additions & 3 deletions instructions/transfer_dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<script>DOCUMENTATION_OPTIONS.pagename = 'instructions/transfer_dataset';</script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="Synchronize tags across groups" href="../notebooks/metadata/04_synchronize_tags.html" />
<link rel="prev" title="Synchronize tags across groups" href="../notebooks/metadata/05_synchronize_tags.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
</head>
Expand Down Expand Up @@ -184,7 +184,8 @@
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/01_key_value_pairs.html">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/02_setting_pixel_sizes.html">Setting pixel sizes of an image</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/03_setting_channel_names.html">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notebooks/metadata/05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down Expand Up @@ -424,7 +425,7 @@ <h2>Transfer the data<a class="headerlink" href="#transfer-the-data" title="Link

<div class="prev-next-area">
<a class="left-prev"
href="../notebooks/metadata/04_synchronize_tags.html"
href="../notebooks/metadata/05_synchronize_tags.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
Expand Down
5 changes: 3 additions & 2 deletions notebooks/metadata/01_key_value_pairs.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
<li class="toctree-l2 current active"><a class="current reference internal" href="#">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="02_setting_pixel_sizes.html">Setting pixel sizes of an image</a></li>
<li class="toctree-l2"><a class="reference internal" href="03_setting_channel_names.html">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down Expand Up @@ -353,7 +354,7 @@ <h2> Contents </h2>
<article class="bd-article">

<section class="tex2jax_ignore mathjax_ignore" id="reading-writing-and-editing-key-value-pairs">
<h1>Reading, writing and editing key-value pairs<a class="headerlink" href="#reading-writing-and-editing-key-value-pairs" title="Link to this heading">#</a></h1>
<span id="omero-tools-key-value-pairs"></span><h1>Reading, writing and editing key-value pairs<a class="headerlink" href="#reading-writing-and-editing-key-value-pairs" title="Link to this heading">#</a></h1>
<p>Key value pairs are a key (pun intended) part of annotating data in OMERO in a very flexible way. In essence, they provide a way of adding Python dictionaries to an image, a project or a dataset - and a Python dictionary is fit for data of virtually any form. Here are a few ways of interacting with data in this form through Python.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down
3 changes: 2 additions & 1 deletion notebooks/metadata/02_setting_pixel_sizes.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
<li class="toctree-l2"><a class="reference internal" href="01_key_value_pairs.html">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2 current active"><a class="current reference internal" href="#">Setting pixel sizes of an image</a></li>
<li class="toctree-l2"><a class="reference internal" href="03_setting_channel_names.html">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down
9 changes: 5 additions & 4 deletions notebooks/metadata/03_setting_channel_names.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<script>DOCUMENTATION_OPTIONS.pagename = 'notebooks/metadata/03_setting_channel_names';</script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Synchronize tags across groups" href="04_synchronize_tags.html" />
<link rel="next" title="How to tag and retrieve tags from data" href="04_tagging_data.html" />
<link rel="prev" title="Setting pixel sizes of an image" href="02_setting_pixel_sizes.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
Expand Down Expand Up @@ -185,7 +185,8 @@
<li class="toctree-l2"><a class="reference internal" href="01_key_value_pairs.html">Reading, writing and editing key-value pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="02_setting_pixel_sizes.html">Setting pixel sizes of an image</a></li>
<li class="toctree-l2 current active"><a class="current reference internal" href="#">Setting channel names</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_synchronize_tags.html">Synchronize tags across groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="04_tagging_data.html">How to tag and retrieve tags from data</a></li>
<li class="toctree-l2"><a class="reference internal" href="05_synchronize_tags.html">Synchronize tags across groups</a></li>

</ul>
</details></li>
Expand Down Expand Up @@ -462,11 +463,11 @@ <h1>Setting channel names<a class="headerlink" href="#setting-channel-names" ti
</div>
</a>
<a class="right-next"
href="04_synchronize_tags.html"
href="04_tagging_data.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Synchronize tags across groups</p>
<p class="prev-next-title">How to tag and retrieve tags from data</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
Expand Down
Loading

0 comments on commit 5b43f58

Please sign in to comment.