An interactive explorer for single-cell transcriptomics data
Quick start
Installation
Gallery
Demo datasets
Preparing your data
Launching cellxgene
Hosting cellxgene
Annotating data
Methods
Troubleshooting
Roadmap
Contributing (ideas or code)
Contact & finding help
Code
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!
You can enable this experimental feature like so:
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:
########; this helps cellxgene identify your file to avoid overwriting your work.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.
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-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 (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.
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 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-output-dir path/to/annotations-directory/
For each user, annotations will be saved as follows:
########; this helps cellxgene identify their specific file to avoid overwriting others’ work.annotations-directory/name-########.csvOnce you’re finished with your annotations, you should finalize and preserve your work by merging your csv into your main h5ad file.
You can do so like this:
import pandas as pd
import scanpy as sc
new_annotations = pd.read_csv('myannotations.csv',
comment='#',
dtype='category',
index_col=0)
anndata = sc.read('mydata.h5ad')
anndata.obs = anndata.obs.join(new_annotations)
cellxgene autosaves any changes made to your annotations every 3 seconds.
Not to worry! We save the last 10 versions of your annotations in annotations-directory/NAME-backups/
Continuous metadata is important! However, these values (e.g., pseudotime) are the result of statistical analyses that are beyond cellxgene’s visualization- and exploration-focused scope. We do, of course, provide visualization of continuous metadata values computed elsewhere and stored in anndata.obs.
This is most likely because the h5ad file you are working with is not the original file used to generate the annotations! We recommend merging new annotations in on a regular basis for this reason.
We place a small cookie (file) in your browser that identifies where your draft annotations are saved. This file never leaves your machine, and is never sent to the cellxgene team or anyone else.
Wonderful! This is a very new and complex feature; we would love to hear your feedback :)