Skip to content

Commit

Permalink
Merge pull request #120 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
scprep v1.1.0
  • Loading branch information
scottgigante committed Mar 19, 2021
2 parents 1a4f5e2 + 0b96fd2 commit 895b6c5
Show file tree
Hide file tree
Showing 71 changed files with 1,138 additions and 473 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: pre-commit
on:
push:
branches-ignore:
- 'master'

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/setup-python@v2
with:
python-version: "3.7"
architecture: "x64"

- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-

- uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: Commit files
run: |
if [[ `git status --porcelain --untracked-files=no` ]]; then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "pre-commit" -a
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
21 changes: 15 additions & 6 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U black flake8
pip install -U black flake8 hacking
- name: Lint with Black
run: |
black . --check --diff
Expand All @@ -56,9 +55,10 @@ jobs:
fail-fast: false
matrix:
config:
- {name: 'current', os: ubuntu-latest, python: '3.8', r: 'release' }
- {name: 'prev', os: ubuntu-latest, python: '3.7', r: 'release' }
- {name: 'old', os: ubuntu-latest, python: '3.6', r: 'release' }
- {name: '3.9', os: ubuntu-latest, python: '3.9', r: 'release' }
- {name: '3.8', os: ubuntu-latest, python: '3.8', r: 'release' }
- {name: '3.7', os: ubuntu-latest, python: '3.7', r: 'release' }
- {name: '3.6', os: ubuntu-latest, python: '3.6', r: 'release' }

steps:
- name: Cancel Previous Runs
Expand All @@ -74,7 +74,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y pandoc gfortran libblas-dev liblapack-dev libedit-dev llvm-dev libcurl4-openssl-dev ffmpeg
sudo apt-get install -y pandoc gfortran libblas-dev liblapack-dev libedit-dev llvm-dev libcurl4-openssl-dev ffmpeg libhdf5-dev
- name: Set up Python
uses: actions/setup-python@v2
Expand Down Expand Up @@ -116,8 +116,17 @@ jobs:
renv::restore()
renv::install("bioc::splatter")
renv::install("bioc::slingshot")
renv::install("github::dynverse/dyngen")
renv::install("github::dynverse/dynwrap")
shell: Rscript {0}

- name: Install package & dependencies
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U .[test]
python -c "import scprep"
- name: Run tests
run: nose2 -vvv

Expand Down
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: \.(ai|gz)$
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ['--target-version=py36']
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
hooks:
- id: autopep8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies: ['hacking']
59 changes: 0 additions & 59 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
https://www.contributor-covenant.org/faq
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Code Style and Testing

`scprep` is maintained at close to 100% code coverage. Contributors are encouraged to write tests for their code, but if you do not know how to do so, please do not feel discouraged from contributing code! Others can always help you test your contribution.

Code style is dictated by [`black`](https://pypi.org/project/black/#installation-and-usage). To automatically reformat your code when you run `git commit`, you can run `./autoblack.sh` in the root directory of this project to add a hook to your `git` repository.
Code style is dictated by [`black`](https://pypi.org/project/black/#installation-and-usage) and [`flake8`](https://flake8.pycqa.org/en/latest/) with [`hacking`](https://github.com/openstack/hacking). Code is automatically reformatted by [`pre-commit`](https://pre-commit.com/) when you push to GitHub.

Code of Conduct
---------------
Expand Down
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code style: black
.. image:: https://img.shields.io/badge/style%20guide-openstack-eb1a32.svg
:target: https://docs.openstack.org/hacking/latest/user/hacking.html#styleguide
:alt: Style Guide: OpenStack
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:target: https://github.com/pre-commit/pre-commit
:alt: pre-commit

`scprep` provides an all-in-one framework for loading, preprocessing, and plotting matrices in Python, with a focus on single-cell genomics.

Expand Down Expand Up @@ -64,7 +70,7 @@ You can use `scprep` with your single cell data as follows::
# Filter by mitochondrial expression to remove dead cells
mt_genes = scprep.select.get_gene_set(data, starts_with="MT")
scprep.plot.plot_gene_set_expression(data, genes=mt_genes, percentile=90)
data = scprep.filter.filter_gene_set_expression(data, genes=mt_genes,
data = scprep.filter.filter_gene_set_expression(data, genes=mt_genes,
percentile=90)
# Library size normalize
data = scprep.normalize.library_size_normalize(data)
Expand Down
14 changes: 0 additions & 14 deletions autoblack.sh

This file was deleted.

2 changes: 1 addition & 1 deletion data/test_data/gene_symbols.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Arl8b,Cdc16,Lrrc8b,0610009B22Rik,Apoe,Asap1,Gstm5,Mok,Rps27l,Stap2,Prpf40a,Pam16,Rnf220,Tmem9b,Rdx,Nupr1l,4930455B14Rik,Sdf2l1,4921517D22Rik,Psmd8,Dynlrb2,Smco4,Gm14285,Ctdp1,Hnrnpu,Ldhb,Cep63,Unc50,Chd5,Ift22,Ankrd13a,Atp5o,Cdhr4,Atp1b3,Gm553,Phtf1,Fam177a,Dgkh,Atoh8,1700019G24Rik,Sycp1,1110008F13Rik,Pgam2,Ift74,Akr1cl,Adam30,Psmd12,mt-Cytb,Ccdc33,Gsto2,Gm16208,C1ql1,Loxhd1,Dhfr,Fgf13,D130052B06Rik,Pcdhb3,Krt32,4833407H14Rik,Abcc5,Vmn1r118,Ccdc54,Megf6,Gm13872,Erp44,Rgs13,Slc2a3,Gm11116,Gm16279,Trmt1,Gm7697,Gm11579,Zdhhc20,4930444P10Rik,RP23-449M8.6,Gm12631,Stoml3,Metrn,Tmco5,Fabp12,Gm3486,Hnf1aos2,Tmem200b,Olfr91,Gm19273,Hmga1-rs1,Prl3d3,Crygf,D030040B21Rik,Serpinb9e,Fam126b,Gm26873,Gm42435,Dmxl2,Cep164,Kansl2,Mgat1,Thrsp,Gm20821,Olfr203
Arl8b,Cdc16,Lrrc8b,0610009B22Rik,Apoe,Asap1,Gstm5,Mok,Rps27l,Stap2,Prpf40a,Pam16,Rnf220,Tmem9b,Rdx,Nupr1l,4930455B14Rik,Sdf2l1,4921517D22Rik,Psmd8,Dynlrb2,Smco4,Gm14285,Ctdp1,Hnrnpu,Ldhb,Cep63,Unc50,Chd5,Ift22,Ankrd13a,Atp5o,Cdhr4,Atp1b3,Gm553,Phtf1,Fam177a,Dgkh,Atoh8,1700019G24Rik,Sycp1,1110008F13Rik,Pgam2,Ift74,Akr1cl,Adam30,Psmd12,mt-Cytb,Ccdc33,Gsto2,Gm16208,C1ql1,Loxhd1,Dhfr,Fgf13,D130052B06Rik,Pcdhb3,Krt32,4833407H14Rik,Abcc5,Vmn1r118,Ccdc54,Megf6,Gm13872,Erp44,Rgs13,Slc2a3,Gm11116,Gm16279,Trmt1,Gm7697,Gm11579,Zdhhc20,4930444P10Rik,RP23-449M8.6,Gm12631,Stoml3,Metrn,Tmco5,Fabp12,Gm3486,Hnf1aos2,Tmem200b,Olfr91,Gm19273,Hmga1-rs1,Prl3d3,Crygf,D030040B21Rik,Serpinb9e,Fam126b,Gm26873,Gm42435,Dmxl2,Cep164,Kansl2,Mgat1,Thrsp,Gm20821,Olfr203
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ help:
# 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)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
7 changes: 4 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import glob

# 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
import glob
import shutil
import sys

root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, root_dir)
Expand Down Expand Up @@ -211,4 +212,4 @@
\texttt{\strut{}{{ docname }}}\\[-0.5\baselineskip]
\noindent\rule{\textwidth}{0.4pt}}
\vspace{-2\baselineskip}
"""
""" # noqa
2 changes: 1 addition & 1 deletion doc/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Examples
.. toctree::

scatter
jitter
jitter
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ scipy>=0.18.1
scikit-learn>=0.19.1
pandas>=0.25
decorator>=4.3.0
packaging
19 changes: 8 additions & 11 deletions scprep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# author: Scott Gigante <scott.gigante@yale.edu>
# (C) 2018 Krishnaswamy Lab GPLv2

from . import _patch
from .version import __version__

import scprep.filter
import scprep.io
import scprep.io.hdf5
import scprep.select
import scprep.filter
import scprep.normalize
import scprep.transform
import scprep.measure
import scprep.normalize
import scprep.plot
import scprep.sanitize
import scprep.stats
import scprep.reduce
import scprep.run

from . import _patch
import scprep.sanitize
import scprep.select
import scprep.stats
import scprep.transform

_patch.patch_fill_value()
32 changes: 26 additions & 6 deletions scprep/_lazyload.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import importlib
import sys

# Key:
# { module : [{submodule1:[subsubmodule1, subsubmodule2]}, submodule2] }
# each module loads submodules on initialization but is only imported
# and loads methods/classes when these are accessed
"""Key:
{ module : [{submodule1:[subsubmodule1, subsubmodule2]}, submodule2] }
Each module loads submodules on initialization but is only imported
and loads methods/classes when these are accessed.
"""
_importspec = {
"matplotlib": [
"colors",
Expand All @@ -31,7 +34,20 @@


class AliasModule(object):
"""Wrapper around Python module to allow lazy loading."""

def __init__(self, name, members=None):
"""Initialize a module without loading it.
Parameters
----------
name : str
Module name
members : list[str, dict]
List of submodules to be loaded as AliasModules. If a dict, the submodule
is loaded with subsubmodules corresponding to the dictionary values;
if a string, the submodule has no subsubmodules.
"""
# easy access to AliasModule members to avoid recursionerror
super_setattr = super().__setattr__
if members is None:
Expand All @@ -56,6 +72,7 @@ def __init__(self, name, members=None):

@property
def __loaded_module__(self):
"""Load the module, or retrieve it if already loaded."""
# easy access to AliasModule members to avoid recursionerror
super_getattr = super().__getattribute__
name = super_getattr("__module_name__")
Expand All @@ -67,6 +84,7 @@ def __loaded_module__(self):
return sys.modules[name]

def __getattribute__(self, attr):
"""Access AliasModule members."""
# easy access to AliasModule members to avoid recursionerror
super_getattr = super().__getattribute__
if attr in super_getattr("__submodules__"):
Expand All @@ -85,8 +103,10 @@ def __getattribute__(self, attr):
return getattr(super_getattr("__loaded_module__"), attr)

def __setattr__(self, name, value):
# allows monkey-patching
# easy access to AliasModule members to avoid recursionerror
"""Allow monkey-patching.
Gives easy access to AliasModule members to avoid recursionerror.
"""
super_getattr = super().__getattribute__
return setattr(super_getattr("__loaded_module__"), name, value)

Expand Down

0 comments on commit 895b6c5

Please sign in to comment.