Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10"]
os: ["ubuntu-latest", "macos-latest"]

steps:
Expand All @@ -27,7 +27,7 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
channels: conda-forge,bioconda
channel-priority: strict
channel-priority: strict
python-version: ${{ matrix.python-version }}

- name: install conda build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.8"
python-version: "3.9"
- name: Install dependencies
run: |
# https://github.com/pypa/pip/issues/11110
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ jobs:
fail-fast: false
matrix:
config:
- { python-version: 3.7, os: ubuntu-latest }
- { python-version: 3.8, os: ubuntu-latest }
- { python-version: 3.9, os: ubuntu-latest }
- { python-version: "3.10", os: ubuntu-latest }
# as of 2023-02-17 not yet supported by numba (ETA 2023-03, https://github.com/numba/numba/issues/8304)
# - { python-version: "3.11", os: ubuntu-latest }
# - { python-version: 3.9, os: macos-latest }
- { python-version: 3.9, os: windows-latest }

Expand Down Expand Up @@ -61,9 +62,6 @@ jobs:
run: |
pip install .[test]

- name: Check black formatting
run: |
black --check .
- name: Test with pytest (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: pytest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
language_version: python3.10
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
'Programming Language :: Python :: 3',
'Programming Language :: R'
]
requires-python = '>= 3.7'
requires-python = '>= 3.8'
dependencies = [
'anndata>=0.7.6',
'scanpy>=1.6.0',
Expand Down
27 changes: 6 additions & 21 deletions scirpy/_compat.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
from packaging import version

try:
from typing import Literal
pass
except ImportError:
try:
from typing_extensions import Literal
except ImportError:

class LiteralMeta(type):
def __getitem__(cls, values):
if not isinstance(values, tuple):
values = (values,)
return type("Literal_", (Literal,), dict(__args__=values))

class Literal(metaclass=LiteralMeta):
pass
pass


def pkg_metadata(package):
try:
from importlib.metadata import metadata as m
except ImportError: # < Python 3.8: Use backport module
from importlib_metadata import metadata as m
from importlib.metadata import metadata as m

return m(package)


def pkg_version(package):
try:
from importlib.metadata import version as v
except ImportError: # < Python 3.8: Use backport module
from importlib_metadata import version as v
from importlib.metadata import version as v

return version.parse(v(package))
2 changes: 1 addition & 1 deletion scirpy/io/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
_check_upgrade_schema,
_read_airr_rearrangement_df,
)
from .._compat import Literal
from typing import Literal
from airr import RearrangementSchema
import itertools
import re
Expand Down
2 changes: 0 additions & 2 deletions scirpy/io/_tracerlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def __init__(
receptor=None,
loci=None,
):

self.name = cell_name
self.bgcolor = None
self.recombinants = self._process_recombinants(recombinants, receptor, loci)
Expand Down Expand Up @@ -170,7 +169,6 @@ def html_style_label_dna(self, receptor, loci, colours):
# return(self.name)

def html_style_label_for_circles(self, receptor, loci, colours):

# colours = {'A': {'productive': '#E41A1C', 'non-productive': "#ff8c8e"},
# 'B': {'productive': '#377eb8', 'non-productive': "#95c1e5"},
# 'G': {'productive': '#4daf4a', 'non-productive': "#aee5ac"},
Expand Down
2 changes: 1 addition & 1 deletion scirpy/ir_dist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Compute distances between immune receptor sequences"""
from anndata import AnnData
from typing import Optional, Sequence, Union
from .._compat import Literal
from typing import Literal
import numpy as np
from scanpy import logging
from ..util import _is_na, deprecated
Expand Down
2 changes: 1 addition & 1 deletion scirpy/ir_dist/_clonotype_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Dict, Mapping, Tuple, Union, Sequence, Optional
from anndata import AnnData
from scanpy import logging
from .._compat import Literal
from typing import Literal
import numpy as np
import scipy.sparse as sp
import itertools
Expand Down
2 changes: 1 addition & 1 deletion scirpy/ir_dist/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import scipy.sparse as sp
from scipy.sparse.coo import coo_matrix
from scipy.sparse.csr import csr_matrix
from .._compat import Literal
from typing import Literal
import warnings
from functools import reduce
from operator import mul
Expand Down
1 change: 0 additions & 1 deletion scirpy/ir_dist/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def _compute_block(self, seqs1, seqs2, origin):

result = []
for (row, s1), (col, s2) in coord_iterator:

# require identical length of sequences
if len(s1) != len(s2):
continue
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_cdr_convergence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import matplotlib.pyplot as plt
from .._compat import Literal
from typing import Literal
from anndata import AnnData
import pandas as pd
from .. import tl
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_clonal_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from anndata import AnnData
from . import base
from typing import Union
from .._compat import Literal
from typing import Literal
from ..io._util import _check_upgrade_schema


Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_clonotype_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import seaborn as sns
import scanpy as sc
from typing import Union
from .._compat import Literal
from typing import Literal
from .. import tl
from .base import volcano
from ..io._util import _check_upgrade_schema
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_clonotype_modularity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from numpy.core.fromnumeric import amax
from .styling import _init_ax, apply_style_to_axes
from .._compat import Literal
from typing import Literal
from ._clonotypes import _plot_size_legend
from typing import Tuple, Union, Optional, Sequence
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_diversity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from anndata import AnnData
from .._compat import Literal
from typing import Literal
from . import base
from .. import tl
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_group_abundance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import matplotlib.pyplot as plt
from .._compat import Literal
from typing import Literal
from anndata import AnnData
from .. import tl
from . import base
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/_spectratype.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt
import numpy as np
from .._compat import Literal
from typing import Literal
from anndata import AnnData
from .. import tl
from . import base
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Base plotting functions"""
from typing import Union, Sequence, Tuple, Optional
from .._compat import Literal
from typing import Literal
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion scirpy/pl/styling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .._compat import Literal
from typing import Literal
import matplotlib.pyplot as plt
from typing import Union, Sequence, Dict
from scanpy.plotting._utils import (
Expand Down
2 changes: 1 addition & 1 deletion scirpy/tl/_clonal_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..util import _is_na, _normalize_counts
import numpy as np
from typing import Union, List
from .._compat import Literal
from typing import Literal
import pandas as pd
from ..io._util import _check_upgrade_schema

Expand Down
9 changes: 2 additions & 7 deletions scirpy/tl/_clonotype_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ def clonotype_imbalance(
for hue, cases, controls, ncase, ncontrol in case_control_groups:
if hue is None:
hue = "All"
tdf1 = clonotype_presence.loc[
cases,
]
tdf2 = clonotype_presence.loc[
controls,
]
tdf1 = clonotype_presence.loc[cases,]
tdf2 = clonotype_presence.loc[controls,]
suspects = set(
tdf1.loc[:, tdf1.sum() > 0].columns.values.tolist()
+ tdf2.loc[:, tdf2.sum() > 0].columns.values.tolist()
Expand Down Expand Up @@ -156,7 +152,6 @@ def clonotype_imbalance(
clt_stats = clt_stats.sort_values(by="pValue")

if inplace:

# Store calculated data
adata.uns[key_added] = {"abundance": clt_freq, "pvalues": clt_stats}
return
Expand Down
2 changes: 1 addition & 1 deletion scirpy/tl/_clonotype_modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from ..util.graph import _get_igraph_from_adjacency
from ..util._negative_binomial import fit_nbinom
from .._compat import Literal
from typing import Literal
import scipy.stats
import scipy.sparse
from statsmodels.stats.multitest import fdrcorrection
Expand Down
2 changes: 1 addition & 1 deletion scirpy/tl/_clonotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scanpy import logging
import scipy.sparse as sp

from .._compat import Literal
from typing import Literal
from ..pp import ir_dist
from ..ir_dist import MetricType, _get_metric_key
from ..ir_dist._clonotype_neighbors import ClonotypeNeighbors
Expand Down
2 changes: 1 addition & 1 deletion scirpy/tl/_group_abundance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from ..util import _is_na, _normalize_counts
from typing import Sequence
from .._compat import Literal
from typing import Literal
from ..io._util import _check_upgrade_schema


Expand Down
2 changes: 1 addition & 1 deletion scirpy/tl/_ir_query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Counter, Optional, Union, Sequence

from .._compat import Literal
from typing import Literal
from anndata import AnnData
import pandas as pd
import itertools
Expand Down
1 change: 0 additions & 1 deletion scirpy/tl/_repertoire_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def repertoire_overlap(
linkage = sc_hierarchy.linkage(distM)

if inplace:

# Store calculated data
adata.uns[added_key] = {
"weighted": df,
Expand Down
2 changes: 1 addition & 1 deletion scirpy/util/graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import igraph as ig
import numpy as np
from scipy import sparse
from ..._compat import Literal
from typing import Literal
from scipy.sparse import spmatrix, csr_matrix
import itertools
from ._component_layout import layout_components
Expand Down
2 changes: 1 addition & 1 deletion scirpy/util/graph/_component_layout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional
import igraph as ig
import numpy as np
from ..._compat import Literal
from typing import Literal
from ._fr_size_aware_layout import layout_fr_size_aware


Expand Down
2 changes: 0 additions & 2 deletions scirpy/util/graph/_fr_size_aware_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def _is_within_bbox(points, origin, scale):
def _get_temperature_decay(
initial_temperature, total_iterations, mode="quadratic", eps=1e-9
):

x = np.linspace(0.0, 1.0, total_iterations)
if mode == "quadratic":
y = (x - 1.0) ** 2 + eps
Expand Down Expand Up @@ -336,7 +335,6 @@ def _get_unique_nodes(edge_list):


def _edge_list_to_adjacency_matrix(edge_list, edge_weights=None):

sources = [s for (s, _) in edge_list]
targets = [t for (_, t) in edge_list]
if edge_weights:
Expand Down