Skip to content

Commit

Permalink
Merge 98b9136 into 3dc5ac3
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Dec 22, 2020
2 parents 3dc5ac3 + 98b9136 commit ba1eac8
Show file tree
Hide file tree
Showing 36 changed files with 625 additions and 305 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Unit Tests

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
run_linter:
runs-on: ${{ matrix.config.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
fail-fast: false
matrix:
config:
- {name: 'current', os: ubuntu-latest, python: '3.8' }

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config.python }}

- name: Install tools
run: |
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U black flake8
- name: Lint with Black
run: |
black . --check --diff
- name: Lint with flake8
run: |
flake8 scprep
run_tester:
runs-on: ${{ matrix.config.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
env:
RENV_PATHS_ROOT: ~/.local/share/renv

strategy:
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' }

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

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y libhdf5-dev libhdf5-serial-dev pandoc gfortran libblas-dev liblapack-dev libedit-dev llvm-dev libcurl4-openssl-dev ffmpeg
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config.python }}

- name: Set up R
id: setup-r
uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- name: Cache Python packages
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}-

- name: Cache R packages
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ steps.setup-r.outputs.installed-r-version }}-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-${{ steps.setup-r.outputs.installed-r-version }}-
- name: Install R packages
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
renv::install("bioc::splatter")
renv::install("bioc::slingshot")
shell: Rscript {0}

- name: Install package & dependencies
run: |
python -m pip install --upgrade "pip<=21.0"
pip install --use-deprecated=legacy-resolver -U wheel setuptools
pip install --use-deprecated=legacy-resolver -U .[test,r]
python -c "import scprep"
- name: Run tests
run: nose2 -vvv

- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls
- name: Upload check results on fail
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ matrix.config.name }}_results
path: check
4 changes: 2 additions & 2 deletions scprep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

if int(pd.__version__.split(".")[1]) < 26:

def fill_value(self):
def _fill_value(self):
# Used in reindex_indexer
try:
return self.values.dtype.fill_value
Expand All @@ -28,4 +28,4 @@ def fill_value(self):

from pandas.core.internals.blocks import ExtensionBlock

setattr(ExtensionBlock, "fill_value", property(fill_value))
setattr(ExtensionBlock, "fill_value", property(_fill_value))
16 changes: 8 additions & 8 deletions scprep/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def remove_duplicates(data, *extra_data, sample_labels=None):


def filter_empty_genes(data, *extra_data):
"""Filter all genes with zero counts across all cells
"""Filter all genes with zero counts across all cells.
This is equivalent to `filter_rare_genes(data, cutoff=0, min_cells=1)`
but should be faster.
Expand All @@ -74,7 +74,7 @@ def filter_empty_genes(data, *extra_data):


def filter_rare_genes(data, *extra_data, cutoff=0, min_cells=5):
"""Filter all genes with negligible counts in all but a few cells
"""Filter all genes with negligible counts in all but a few cells.
Parameters
----------
Expand All @@ -101,7 +101,7 @@ def filter_rare_genes(data, *extra_data, cutoff=0, min_cells=5):


def filter_empty_cells(data, *extra_data, sample_labels=None):
"""Remove all cells with zero library size
"""Remove all cells with zero library size.
Parameters
----------
Expand Down Expand Up @@ -142,7 +142,7 @@ def filter_values(
sample_labels=None,
filter_per_sample=None
):
"""Remove all cells with `values` above or below a certain threshold
"""Remove all cells with `values` above or below a certain threshold.
It is recommended to use :func:`~scprep.plot.histogram` to
choose a cutoff prior to filtering.
Expand Down Expand Up @@ -211,7 +211,7 @@ def filter_library_size(
sample_labels=None,
filter_per_sample=None
):
"""Remove all cells with library size above or below a certain threshold
"""Remove all cells with library size above or below a certain threshold.
It is recommended to use :func:`~scprep.plot.plot_library_size` to
choose a cutoff prior to filtering.
Expand Down Expand Up @@ -278,7 +278,7 @@ def filter_gene_set_expression(
sample_labels=None,
filter_per_sample=None
):
"""Remove cells with total expression of a gene set above or below a certain threshold
"""Remove cells with total expression of a gene set above or below a threshold.
It is recommended to use :func:`~scprep.plot.plot_gene_set_expression` to
choose a cutoff prior to filtering.
Expand Down Expand Up @@ -352,7 +352,7 @@ def filter_gene_set_expression(


def _find_unique_cells(data):
"""Identify unique cells
"""Identify unique cells.
Parameters
----------
Expand Down Expand Up @@ -381,7 +381,7 @@ def _find_unique_cells(data):


def filter_duplicates(data, *extra_data, sample_labels=None):
"""Filter all duplicate cells
"""Filter all duplicate cells.
Parameters
----------
Expand Down
10 changes: 5 additions & 5 deletions scprep/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def _read_csv_sparse(filename, chunksize=10000, fill_value=0.0, **kwargs):
"""Read a csv file into a pd.DataFrame[pd.SparseArray]"""
"""Read a csv file into a pd.DataFrame[pd.SparseArray]."""
chunks = pd.read_csv(filename, chunksize=chunksize, **kwargs)
data = pd.concat(
utils.dataframe_to_sparse(chunk, fill_value=fill_value) for chunk in chunks
Expand All @@ -26,7 +26,7 @@ def load_csv(
chunksize=10000,
**kwargs
):
"""Load a csv file
r"""Load a csv file.
Parameters
----------
Expand All @@ -36,7 +36,7 @@ def load_csv(
If your data has genes on the rows and cells on the columns, use
cell_axis='column'
delimiter : str, optional (default: ',')
Use '\\t' for tab separated values (tsv)
Use '\t' for tab separated values (tsv)
gene_names : `bool`, `str`, array-like, or `None` (default: True)
If `True`, we assume gene names are in the first row/column. Otherwise
expects a filename or an array containing a list of gene symbols or ids
Expand Down Expand Up @@ -113,7 +113,7 @@ def load_tsv(
sparse=False,
**kwargs
):
"""Load a tsv file
r"""Load a tsv file.
Parameters
----------
Expand All @@ -122,7 +122,7 @@ def load_tsv(
cell_axis : {'row', 'column'}, optional (default: 'row')
If your data has genes on the rows and cells on the columns, use
cell_axis='column'
delimiter : str, optional (default: '\\t')
delimiter : str, optional (default: '\t')
Use ',' for comma separated values (csv)
gene_names : `bool`, `str`, array-like, or `None` (default: True)
If `True`, we assume gene names are in the first row/column. Otherwise
Expand Down
10 changes: 5 additions & 5 deletions scprep/io/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _google_drive_confirm_token(response):

@utils._with_pkg(pkg="requests")
def _GET_google_drive(id):
"""Post a GET request to Google Drive"""
"""Post a GET request to Google Drive."""
global _GOOGLE_DRIVE_URL

with requests.Session() as session:
Expand All @@ -45,7 +45,7 @@ def _GET_google_drive(id):


def download_google_drive(id, destination):
"""Download a file from Google Drive
"""Download a file from Google Drive.
Requires the file to be available to view by anyone with the URL.
Expand All @@ -63,7 +63,7 @@ def download_google_drive(id, destination):


def download_url(url, destination):
"""Download a file from a URL
"""Download a file from a URL.
Parameters
----------
Expand All @@ -85,7 +85,7 @@ def download_url(url, destination):


def unzip(filename, destination=None, delete=True):
"""Extract a .zip file and optionally remove the archived version
"""Extract a .zip file and optionally remove the archived version.
Parameters
----------
Expand All @@ -109,7 +109,7 @@ def unzip(filename, destination=None, delete=True):


def download_and_extract_zip(url, destination):
"""Download a .zip file from a URL and extract it
"""Download a .zip file from a URL and extract it.
Parameters
----------
Expand Down
Loading

0 comments on commit ba1eac8

Please sign in to comment.