Skip to content

Commit

Permalink
updated readme, pandas fix
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed May 9, 2017
1 parent 34f5133 commit 5eb031e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ with the top-level command `scanpy` on the command-line (more info [here](#insta

Then go through the use cases compiled in
[scanpy_usage](https://github.com/theislab/scanpy_usage), in particular, the recent additions
* [170503_zheng17](https://github.com/theislab/scanpy_usage/tree/master/170503_zheng17) - Analyzing *10x Genomics* data sets from [Zheng *et al.*, Nat. Comm. (2017)](https://dx.doi.org/10.1038/ncomms14049), we find that Scanpy is about a factor 5 to 10 faster and more memory efficient than comparable R packages such as [*Cell Ranger*](https://github.com/10XGenomics/single-cell-3prime-paper/tree/master/pbmc68k_analysis) and [*Seurat*](http://satijalab.org/seurat/) [(Macosko *et al.*, Cell 2015)](http://dx.doi.org/10.1016/j.cell.2015.05.002). For large-scale data, this becomes crucial for interactive analysis.
* [170503_moignard15](https://github.com/theislab/scanpy_usage/tree/master/170503_moignard15.ipynb) - Diffusion Pseudotime Analysis resolves developmental processes in data of [Moignard *et al*, Nat. Biotechn. (2015)](http://dx.doi.org/10.1038/nbt.3154), reproducing results of [Haghverdi *et al.*, Nat. Meth. (2016)](http://10.1038/nmeth.3971). Also, note that DPT has recently been very [favorably discussed](http://biorxiv.org/content/early/2017/02/21/110668) by the authors of [Monocle](http://cole-trapnell-lab.github.io/monocle-release/articles/v2.0.0/).
* 170503 ([link](https://github.com/theislab/scanpy_usage/tree/master/170503_zheng17)) - Analyzing *10x Genomics* data sets from [Zheng *et al.*, Nat. Comm. (2017)](https://dx.doi.org/10.1038/ncomms14049), we find that Scanpy is about a factor 5 to 10 faster and more memory efficient than comparable R packages such as [*Cell Ranger*](https://github.com/10XGenomics/single-cell-3prime-paper/tree/master/pbmc68k_analysis) and [*Seurat*](http://satijalab.org/seurat/) [(Macosko *et al.*, Cell 2015)](http://dx.doi.org/10.1016/j.cell.2015.05.002). For large-scale data, this becomes crucial for interactive analysis.
* 170503 ([link](https://github.com/theislab/scanpy_usage/tree/master/170503_moignard15.ipynb)) - Diffusion Pseudotime Analysis resolves developmental processes in data of [Moignard *et al*, Nat. Biotechn. (2015)](http://dx.doi.org/10.1038/nbt.3154), reproducing results of [Haghverdi *et al.*, Nat. Meth. (2016)](http://10.1038/nmeth.3971). Also, note that DPT has recently been very [favorably discussed](http://biorxiv.org/content/early/2017/02/21/110668) by the authors of [Monocle](http://cole-trapnell-lab.github.io/monocle-release/articles/v2.0.0/).


## Features <a id="features"></a>
Expand All @@ -45,20 +45,19 @@ batch-effect correction, per-cell (UMI) normalization.

#### Visualization

* [tl.pca](#pca) - Visualize data using PCA ([Pedregosa *et al.*, 2011](#ref_pedregosa11)).
* [tl.pca](#pca) - PCA ([Pedregosa *et al.*, 2011](#ref_pedregosa11)).

* [tl.diffmap](#diffmap) - Visualize data using Diffusion Maps
* [tl.diffmap](#diffmap) - Diffusion Maps
([Coifman *et al.*, 2005](#ref_coifman05); [Haghverdi *et al.*,
2015](#ref_haghverdi15); [Wolf *et al.*, 2017](#ref_wolf17)).

* [tl.tsne](#tsne) - Visualize data using t-SNE ([Maaten & Hinton, 2008](#ref_maaten08); [Amir *et al.*, 2013](#ref_amir13);
* [tl.tsne](#tsne) - t-SNE ([Maaten & Hinton, 2008](#ref_maaten08); [Amir *et al.*, 2013](#ref_amir13);
[Pedregosa *et al.*, 2011](#ref_pedregosa11)).

* [tl.spring](#spring) - [Force-directed graph
drawing](https://en.wikipedia.org/wiki/Force-directed_graph_drawing),
suggested by [Weinreb *et al.*,
(2016)](http://biorxiv.org/content/early/2016/11/29/090332) for single-cell
analysis.
drawing](https://en.wikipedia.org/wiki/Force-directed_graph_drawing)
[(Fruchterman & Reingold, 1991;](http://doi.org:10.1002/spe.4380211102)
[Weinreb *et al.*, 2016)](https://doi.org/10.1101/090332).

#### Branching trajectories and pseudotime, clustering, differential expression

Expand Down Expand Up @@ -89,10 +88,13 @@ package ([Pedregosa *et al.*, 2011](#ref_pedregosa11)).

[[source]](scanpy/tools/tsne.py) Computes the tSNE representation `X_tsne` of data.

The algorithm has been introduced by [Maaten & Hinton
(2008)](#ref_maaten08) and proposed for single-cell data by [Amir *et
al.* (2013)](#ref_amir13). Uses the implementation of the `scikit-learn` package
([Pedregosa *et al.*, 2011](#ref_pedregosa11)).
The algorithm has been introduced by [Maaten & Hinton (2008)](#ref_maaten08) and
proposed for single-cell data by [Amir *et al.* (2013)](#ref_amir13). By
default, Scanpy uses the implementation of the `scikit-learn` package
([Pedregosa *et al.*, 2011](#ref_pedregosa11)). You can achieve a huge speedup
if you install the Multicore-TSNE package by [Ulyanov
(2016)](https://github.com/DmitryUlyanov/Multicore-TSNE), which will be
automatically detected by Scanpy.

#### diffmap <a id="diffmap"></a>

Expand All @@ -104,6 +106,19 @@ visualizing single-cell data by [Haghverdi *et al.*
al.* (2016)](#ref_haghverdi16). The Scanpy implementation is due to [Wolf *et
al.* (2017)](#ref_wolf17).

#### spring <a id="spring"></a>

Beta version.

[[source]](scanpy/tools/spring.py) Force-directed graph drawing is a
long-established algorithm for visualizing graphs, see [Wikipedia](https://en.wikipedia.org/wiki/Force-directed_graph_drawing).
It has been suggested for visualizing single-cell data by [Weinreb *et al.*, 2016)](https://doi.org/10.1101/090332).

Here, the [Fruchterman & Reingold (1991)](http://doi.org:10.1002/spe.4380211102)
algorithm is used. The implementation uses elements of the NetworkX [(Hagberg
*et al.*, 2008)](http://conference.scipy.org/proceedings/SciPy2008/paper_2/)
implementation.

### Discrete clustering of subgroups and continuous progression through subgroups

#### dpt <a id="dpt"></a>
Expand All @@ -125,6 +140,8 @@ The functionality of diffmap and dpt compare to the R package
originally proposed by [Ester *et al.*, 1996](#ref_ester96), in the implementation of
`scikit-learn` ([Pedregosa *et al.*, 2011](#ref_pedregosa11)).

This is a very simple clustering method. A better one - in the same framework as DPT and Diffusion Maps - will come soon.

### Differential expression

#### diffrank <a id="diffrank"></a>
Expand Down
6 changes: 3 additions & 3 deletions scanpy/preprocessing/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def filter_genes_dispersion(data, log=True,
disp_std_bin = disp_grouped.std(ddof=1)
df['dispersion_norm'] = (df['dispersion'].values # use values here as index differs
- disp_mean_bin[df['mean_bin'].cat.codes].values) \
/ disp_std_bin[df['mean_bin'].cat.codes].values
/ disp_std_bin[df['mean_bin'].cat.codes].values # appending .cat.codes only necessary for old pandas versions
elif flavor == 'cell_ranger':
from statsmodels import robust
df['mean_bin'] = pd.cut(df['mean'], np.r_[-np.inf,
Expand All @@ -192,8 +192,8 @@ def filter_genes_dispersion(data, log=True,
disp_median_bin = disp_grouped.median()
disp_mad_bin = disp_grouped.apply(robust.mad)
df['dispersion_norm'] = np.abs((df['dispersion'].values
- disp_median_bin[df['mean_bin']].values)) \
/ disp_mad_bin[df['mean_bin']].values
- disp_median_bin[df['mean_bin'].cat.codes].values)) \
/ disp_mad_bin[df['mean_bin'].cat.codes].values # appending .cat.codes only necessary for old pandas versions
else:
raise ValueError('`flavor` needs to be "seurat" or "cell_ranger"')
dispersion_norm = df['dispersion_norm'].values.copy()
Expand Down

0 comments on commit 5eb031e

Please sign in to comment.