Skip to content

Commit

Permalink
Dev v2.5 (#125)
Browse files Browse the repository at this point in the history
* remove downsampling and using np indexing to create synths

* force raw_counts to be csr_sparse and use sparse operations for speed and reduced memory footprint. Closes #117 

* exchange tsne and umap

* Converts the codebase to the black code style

* Improve documentation

* Reorganize repo & package folder tree

* add requirements to setup.py, remove requirements.txt

* Adds verbose parameter to BoostClassifier init

verbose = False default.
Phenograph respects verbose param.
Closes #64

* Integrate scanpy for more efficient clustering and general functionality (#120)

* add default random state

* add phenograph to setup.py yay!
  • Loading branch information
JonathanShor authored Jul 12, 2019
2 parents 4f90794 + ac6776c commit 95b2db1
Show file tree
Hide file tree
Showing 21 changed files with 769 additions and 441 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[LICENSE]
insert_final_newline = false
31 changes: 29 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
*.pyc
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

.ipynb_checkpoints/
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Installer logs
pip-log.txt

# Sphinx documentation
docs/_build/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# mkdocs documentation
/site
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:
- id: flake8
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
17 changes: 17 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. highlight:: shell

============
Contributing
============

1. Install your local copy into a virtualenv (or conda environment). Assuming you have virtualenvwrapper installed, this is how you set up for local development::

$ mkvirtualenv doubletdetection
$ cd DoubletDetection/
$ python3 setup.py develop

2. Install pre-commit, which will enforce the DoubletDetection coding format on each of your commits::

$ cd DoubletDetection
$ pip3 install pre-commmit
$ pre-commit install
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# DoubletDetection
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2678042.svg)](https://doi.org/10.5281/zenodo.2678042)
[![Documentation Status](https://readthedocs.org/projects/doubletdetection/badge/?version=latest)](https://doubletdetection.readthedocs.io/en/latest/?badge=latest)


DoubletDetection is a Python3 package to detect doublets (technical errors) in single-cell RNA-seq count matrices.

Expand All @@ -9,8 +11,7 @@ To install DoubletDetection:
```
git clone https://github.com/JonathanShor/DoubletDetection.git
cd DoubletDetection
pip3 install -r requirements.txt
pip3 install --upgrade .
pip3 install .
```

To run basic doublet classification:
Expand All @@ -25,11 +26,13 @@ labels = clf.fit(raw_counts).predict()
- `raw_counts` is a scRNA-seq count matrix (cells by genes), and is array-like
- `labels` is a 1-dimensional numpy ndarray with the value 1 representing a detected doublet, 0 a singlet, and `np.nan` an ambiguous cell.

The classifier works best when
The classifier works best when
- There are several cell types present in the data
- It is applied individually to each run in an aggregated count matrix

See our [jupyter notebook](https://nbviewer.jupyter.org/github/JonathanShor/DoubletDetection/blob/master/docs/PBMC_8k_vignette.ipynb) for an example on 8k PBMCs from 10x.
In `v2.5` we have added a new experimental clustering method (`scanpy`'s Louvain clustering) that is much faster than phenograph. We are still validating results from this new clustering. Please see the notebook below for an example of using this new feature.

See our [jupyter notebook](https://nbviewer.jupyter.org/github/JonathanShor/DoubletDetection/blob/master/tests/notebooks/PBMC_8k_vignette.ipynb) for an example on 8k PBMCs from 10x.

## Obtaining data
Data can be downloaded from the [10x website](https://support.10xgenomics.com/single-cell/datasets).
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
236 changes: 0 additions & 236 deletions docs/PBMC_8k_vignette.ipynb

This file was deleted.

54 changes: 54 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------

project = 'DoubletDetection'
copyright = '2019, Adam Gayoso and Jonathan Shor'
author = 'Adam Gayoso and Jonathan Shor'

# The full version, including alpha/beta/rc tags
release = '2.4.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'm2r']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
5 changes: 5 additions & 0 deletions docs/doubletdetection.doubletdetection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DoubletDetection
====================

.. automodule:: doubletdetection.doubletdetection
:members:
5 changes: 5 additions & 0 deletions docs/doubletdetection.plot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Plot
====================

.. automodule:: doubletdetection.plot
:members:
5 changes: 5 additions & 0 deletions docs/doubletdetection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DoubletDetection
====================

.. automodule:: doubletdetection
:members:
22 changes: 22 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. DoubletDetection documentation master file, created by
sphinx-quickstart on Wed Jul 3 15:04:18 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. mdinclude:: ../README.md

.. toctree::
:maxdepth: 2
:caption: Contents:


doubletdetection.doubletdetection
doubletdetection.plot


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
4 changes: 4 additions & 0 deletions docs/readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build:
image: latest
python:
version: 3.7
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .doubletdetection import BoostClassifier, load_mtx, load_10x_h5
from .plot import *
from . import plot
Loading

0 comments on commit 95b2db1

Please sign in to comment.