Bruce Martin eeec842ad0 Restv2 feature branch merge to master (#284)
Move to new REST v0.2 communication between front and back-end.   This is a first cut implementation which is functional, but will need follow-up enhancements for performance, error checking, etc.    Protocol spec is in docs directory.

* Add filtering via indexing

* Using new filter specs

Indexing working

* Added filtering by annotation value

* factor out common methods

* Documentation

* create enum for axis (obs/var)

* Better description for filter's return

* Add boolean to enumerated types

* Augmented enum for scanpy axis

* Create schema for annotations

Based on datatype within scanpy/anndata
+ tests

* remove obsolete schema parse script

* Update rest api to remove old routes and add schema route

* Separate development requirements

* Warning for unsupported datatypes

* include -r requirements.txt in dev

* Merged downcast warnings

* Fixed bug where names were NaNs

Needed to include the index too when creating the series

* Add config endpoint

* Generate app features from CLI selections

* Move features to driver

* Add tests for schema

* Clearer version wording

* python3 version of super

* version from engine to package level

* move features to driver

* Revise layout function to match the new spec

* GET for layout/obs

* PUT Layout (#211)

* PUT Layout

* Csweaver/annotations (#212)


* Update scanpy engine to support the rest v0.2 annotation requests

* GET endpoint for obs annotations + tests

* Documentation

* Test annotations in scanpy engine

* Description for annotation-keys param

* annotation->annotations

* clarified return for annotations

* Use URL query list for annotations fields

* parse_filter parses v0.2 GET filters (#215)

* parse_filter parses v0.2 GET filters

* Don't allow index filters from query params

* Better variable conversion

* Parse filter improvements

- uses default dict
- renamed filter -> query_filter

* Cleanup Tasks (#216)

* Add test_api back into travis build

* Do custom JSON encoding the correct way

* Run cellxgene server in test setup

* Cleanup new tests too

* Option to bind to all interfaces (#225)

app.run("0.0.0.0") instead of app.run("127.0.0.1") binds to all interfaces.

Note: There are comments on the internet that says that the flask server is not up to the task of production serving.  I don't think that such scalability concerns apply here, but I was able to get cellxgene working with twistd relatively easily, and we could switch to that if there are scalability concerns.

Test plan: browsed to <ip>:5005/api/v0.2/config on a different host.

* Add filtering via indexing

* Using new filter specs

Indexing working

* Added filtering by annotation value

* factor out common methods

* Documentation

* create enum for axis (obs/var)

* Better description for filter's return

* Add boolean to enumerated types

* Augmented enum for scanpy axis

* Create schema for annotations

Based on datatype within scanpy/anndata
+ tests

* remove obsolete schema parse script

* Update rest api to remove old routes and add schema route

* Separate development requirements

* Warning for unsupported datatypes

* include -r requirements.txt in dev

* Merged downcast warnings

* Fixed bug where names were NaNs

Needed to include the index too when creating the series

* Add config endpoint

* Generate app features from CLI selections

* Move features to driver

* Add tests for schema

* Clearer version wording

* python3 version of super

* version from engine to package level

* move features to driver

* Revise layout function to match the new spec

* GET for layout/obs

* PUT Layout (#211)

* PUT Layout

* Csweaver/annotations (#212)


* Update scanpy engine to support the rest v0.2 annotation requests

* GET endpoint for obs annotations + tests

* Documentation

* Test annotations in scanpy engine

* Description for annotation-keys param

* annotation->annotations

* clarified return for annotations

* Use URL query list for annotations fields

* parse_filter parses v0.2 GET filters (#215)

* parse_filter parses v0.2 GET filters

* Don't allow index filters from query params

* Better variable conversion

* Parse filter improvements

- uses default dict
- renamed filter -> query_filter

* Cleanup Tasks (#216)

* Add test_api back into travis build

* Do custom JSON encoding the correct way

* Run cellxgene server in test setup

* Cleanup new tests too

* Option to bind to all interfaces (#225)

app.run("0.0.0.0") instead of app.run("127.0.0.1") binds to all interfaces.

Note: There are comments on the internet that says that the flask server is not up to the task of production serving.  I don't think that such scalability concerns apply here, but I was able to get cellxgene working with twistd relatively easily, and we could switch to that if there are scalability concerns.

Test plan: browsed to <ip>:5005/api/v0.2/config on a different host.

* Fix merge errors

- import warnings was improperly deleted
- scanpy engine tests were totally wrong

* Fix merge error with driver

* PUT /annotations (#235)

* Add query param for annotation name

* fix descriptions, eliminate else clause

* first cut at initial data load on rest 0.2 api

* Annotation var (#248)

* Fix bug strings are always objects in pandas

* Add axis to annotation method

* Add /annotation/var to REST api

* Csweaver/expressiondata (#242)

* Refactor expression method for REST v2

* Add message to QueryStringError

* Fix range filters

* Add GET route for /data

* /data PUT route

* rename expression to data_frame

* clarification of error

* Improve accept type handling

* support all schema types for 0.2 REST API

* remove REST 0.1 code; connect var annotations loading

* config reducer; use config to set data set title; remove obsolete templating code for data set title

* REST 0.2 expression conversion support

* partial port of expression to REST 0.2

*  diffexp (#273)

* Add diffexp method to scanpy

and test

* Minor tweaks to diffexp

Get a minimal working version to unblock FE development

* Fixing things git deleted

* cleanup print statements

* Add index test

* additional, partial REST 0.2 bring up of diffexp

* Ignore unstructured annotations for data (#275)

This is a temp hack, need to figure out how to include data.uns if there is only one gene

* diffexp REST 0.2 port finish

* ignore unstructured annotaitons on all routes except layout

* correctly use varDataCache; maintain state during world rebuild

* correct varDataCache use

* temporarily disable all memoization

* refinements to expression data caching

* clear cell sets upon regraph/reset

* update version of REST to 0.2

* Travis build fixes

- comment out cache import
- fix duplicate test name

* Remove dependency from travis

* clarify semantics of config variables

* move generic action helpers into util
2018-10-01 14:58:46 -07:00
2018-08-09 10:09:19 -07:00
2018-09-25 11:26:54 -07:00
2018-08-03 10:23:57 -07:00
2018-08-13 14:35:41 -07:00
2017-08-23 16:28:01 -07:00
2018-07-16 11:48:53 -07:00
2018-09-14 16:02:22 -07:00
2018-07-18 14:07:04 -07:00

cellxgene

An interactive, performant explorer for single cell transcriptomics data.

cellxgene is an open-source experiment in how to bring powerful tools from modern web development to visualize and explore large single-cell transcriptomics datasets. Started in the context of the Human Cell Atlas Consortium, cellxgene hopes to both enable scientists to explore their data and to equip developers with scalable, reusable patterns and frameworks for visualizing large scientific datasets.

Features

  • Visualization at scale: built with WebGL, React & Redux to handle visualization of at least 1 million cells.

  • Interactive exploration: select, cross-filter, and compare subsets of your data with performant indexing and data handling.

  • Flexible API: the cellxgene client-server model is designed to support a range of existing analysis packages for backend computational tasks (eg scanpy), integrated with client-side visualization via a REST API.

Getting Started

Requirements

  • OS: OSX, Windows, Linux -- the developers are currently testing on OSX and Windows (via WSL using Ubuntu). It should work on other platforms but if you are using something different and need help, please let us know.
  • python 3.6
  • python3 tkinter
  • npm
  • Google Chrome

Clone project

git clone https://github.com/chanzuckerberg/cellxgene.git

Install client

cd cellxgene
./bin/build-client

To use with virtual env for python (optional, but recommended)

ENV_NAME=cellxgene
python3 -m venv ${ENV_NAME}
source ${ENV_NAME}/bin/activate

Install server

 pip install -e .

Run (with demo data)

cellxgene --title PBMC3K scanpy example-dataset/

In google chrome, navigate to the viewer via the web address printed in your console. E.g., Running on http://0.0.0.0:5005/

Help

cellxgene --help

For help with the scanpy engine

cellxgene scanpy --help

Using your own data

Scanpy

To prepare your data you will need to format your data into AnnData format using scanpy and calculate PCA and nearest neighbors and save in h5ad format.

  1. Load data into scanpy

    • Ensure that obs's index is the cell names: print(data.obs_names) should show your cell indices. If it shows gene names, you may need to just call data.transpose().
  2. Calculate PCA

    sc.pp.pca(data) ## sc is scanpy.api

  3. Calculate nearest neighbors (depending on layout algorithm)

    # For umap layout algorithm, you need to use the "umap" method for neighbors
    sc.pp.neighbors(data, method="umap", metric="euclidean", use_rep="X_pca")
    
    # For tsne layout algorithm, you can use either "umap" or "gauss"; we recommend "gauss"
    sc.pp.neighbors(data, method="gauss", metric="euclidean", use_rep="X_pca")
    
  4. Save file

    # cellxgene requires file to be named data.h5ad
    data.write("data.h5ad")
    
  5. Create config file (optional)

    If you do not have a config file, the schema (metadata names, types, and categorical/continuous) will be inferred from the observations in the data file. Config file is required to be named 'data_schema.json' and located in the same directory as data file.

    • The config file is a JSON format file with information on the metadata associated with the cells. The key is the column name in obs. The value is an object
    type: string, int, or float (what type the values are),
      variabletype: categorical or continuous (categorical values are displayed as checkboxes, continuous values are displayed as a histogram)
      displayname: (what the heading should be displayed as)
      include: True/False (whether to display values on web interface)
    
    Example
    {
        "CellName": {
            "type": "string",
            "variabletype": "categorical",
            "displayname": "Name",
            "include": true
        },
        "clusters": {
            "type": "string",
            "variabletype": "categorical",
            "displayname": "Clusters",
            "include": true
        },
        "num_genes": {
            "type": "int",
            "variabletype": "continuous",
            "displayname": "Number Genes",
            "include": true
        }
    }
    

Contributing

We warmly welcome contributions from the community. Please submit any bug reports and feature requests through github issues. Please submit any direct contributions via a branch + pull request.

Inspiration and collaboration

Weve been inspired by several other related efforts in this space, including the UCSC Cell Browswer, Cytoscape, Xena, ASAP, Gene Pattern, & many others; we hope to explore collaborations where useful.

Help/Contact

Have questions, suggestions, or comments? You can contact us by joining CZI Science Slack and posting in the #cellxgene channel. Please submit any feature requests or bugs as an issue in github. We'd love to hear from you!

Reuse

This project was started with the sole goal of empowering the scientific community to explore and understand their data. As such, we whole-heartedly encourage other scientific tool builders to adopt the patterns, tools, and code from this project, and reach out to us with ideas or questions using Github Issues or Pull Requests. All code is freely available for reuse under the MIT license.

We thank Alex Wolf for the demo dataset.

Description
An interactive explorer for single-cell transcriptomics data
Readme MIT 729 MiB
Languages
JavaScript 68.4%
Python 30.1%
Makefile 0.7%
HTML 0.4%
CSS 0.2%