diff --git a/docs/posts/annotations.md b/docs/posts/annotations.md index 4823180a..5b215bee 100644 --- a/docs/posts/annotations.md +++ b/docs/posts/annotations.md @@ -8,52 +8,57 @@ description: Creating annotations We are _piloting_ a new feature in cellxgene that enables users to create and edit categorical annotations within the app. We'd love for you to try it out and [give us feedback](contact)! -## Quick start for annotations (RECOMMENDED for most users) +# Data lifecycle for annotations +## 1. Creating annotations (quickstart) -You can enable this experimental feature like so: - -`cellxgene launch mydata.h5ad --experimental-annotations` +To get started, run: +``` +cellxgene launch mydata.h5ad --experimental-annotations +``` To preserve data provenance, **`cellxgene` does not alter the input h5ad file**. Rather, newly-created annotations are saved in a specified CSV file: +``` +annotations-directory/name-########.csv +``` + +- The default `annotations-directory` is your current working directory (i.e., the directory you were in when you started cellxgene). + - You will be prompted to enter a name for your annotations the first time you create a new category. - We also assign a unique identifier in the form of an 8-character suffix, `########`; this helps cellxgene identify your file to avoid overwriting your work. -- Any annotations you create in the application will be autosaved in `cwd/name-########.csv`, where `cwd` is your current working directory (i.e., the directory you were in when you started cellxgene). -If you quit cellxgene and relaunch it with the same h5ad, we will check for this annotations csv and load it in editable mode alongside. +## 2. Loading, editing and updating existing draft annotations -## Data management +Cellxgene allows you to load and edit compatible draft annotations across multiple sessions. -### Loading, editing and updating existing draft annotations +Compatible annotations are tabular, with category names as column headers; `anndata.obs.index` as the index; and categorical values (i.e., fewer unique values per column than specified in `--max-category-items`, default 1000). + +There are two options for updating draft annotations. + +### Autodetect annotations csv + +Cellxgene can automatically find and reload your draft annotations in editable mode like so: +``` +annotations-directory$ cellxgene launch mydata.h5ad --experimental-annotations +``` + +This assumes that: +1 - The h5ad filename is the same +2 - You launch cellxgene from the `annotations-directory` (i.e., the directory that contains your CSV) +3 - You use the same browser and have not cleared your cookies (we use a small cookie to keep track of which user created the file to avoid accidental overwrites; see FAQ) + + +### Specify an annotations csv +**This mode is only appropriate for single-user, local cellxgene instances** If you'd like to specify the complete file path for your annotations, you can do so by running: ``` cellxgene launch mydata.h5ad --experimental-annotations --experimental-annotations-file path/to/myfile.csv ``` -If this file already exists and contains compatible annotations, these annotations will be loaded as editable categories that you can update directly. Compatible annotations are tabular, with category names as column headers; `anndata.obs.index` as the index; and categorical values (i.e., fewer unique values per column than specified in `--max-category-items`, default 1000). +Any changes you make will be reflected in the original CSV. If the file does not exist, it will be created. +**Please note that this file will be overwritten, making this mode inappropriate for hosted / multi-user settings (see below).** -Any changes you make will be reflected in the original CSV (which will be overwritten). This is helpful if you wish to annotate over multiple sessions. - -If the file does not exist, it will be created. - -### Annotations by multiple users - -An alternative to specifying the file path is to specify the output directory, and allow cellxgene to assign filenames. This is most useful for situations where the same cellxgene instance is being used by multiple users to create annotations. - -As described in the [hosted](hosted) section, we do not officially support hosted or multi-user use of cellxgene. However, we recognize that the app is often adapted for this purpose, and have tried to provide a "safe path" for multi-user setups that avoids overwriting data. - -To specify an output directory, run: -``` -cellxgene launch mydata.h5ad --experimental-annotations --experimental-annotations-output-dir path/to/annotations-directory/ -``` - -For each user, annotations will be saved as follows: -- Each user will be prompted to enter a name for their annotations the first time they create a new category. -- We also assign a unique identifier in the form of an 8-character suffix, `########`; this helps cellxgene identify their specific file to avoid overwriting others' work. -- Any annotations created in the application will be autosaved in `annotations-directory/name-########.csv` - - -### Merging draft annotations with the main h5ad file +### 3. Merging draft annotations with the main h5ad file Once you're finished with your annotations, you should finalize and preserve your work by merging your `csv` into your main `h5ad` file. @@ -70,6 +75,26 @@ anndata = sc.read('mydata.h5ad') anndata.obs = anndata.obs.join(new_annotations) ``` +# Annotations by multiple users + +As described in the [hosted](hosted) section, we do not officially support hosted or multi-user use of cellxgene. However, we recognize that the app is often adapted for this purpose, and have tried to provide a "safe path" for multi-user setups that avoids overwriting data. + +Specifying a single file name for multiple contributors will result in data overwriting. To avoid this, you can instead specify an output directory and allow cellxgene to assign filenames. + +To specify an output directory, run: +``` +cellxgene launch mydata.h5ad --experimental-annotations --experimental-annotations-output-dir path/to/annotations-directory/ +``` + +For each user, annotations will be saved as follows: +- Each user will be prompted to enter a name for their annotations the first time they create a new category. +- We also assign a unique identifier in the form of an 8-character suffix, `########`; this helps cellxgene identify their specific file to avoid overwriting others' work. +- Any annotations created in the application will be autosaved in `annotations-directory/name-########.csv` + + + + + ## FAQ ### How do I know my annotations are saved?