From fd2c95124317fc4f26bbd393380b23c99854864d Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Wed, 3 Mar 2021 10:44:30 +0100 Subject: [PATCH 1/7] Fix bug in motif url construction (pt 2) - Fixes #275 - Previously addressed in #158 --- src/pyscenic/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyscenic/utils.py b/src/pyscenic/utils.py index 74528c7..6fb9784 100644 --- a/src/pyscenic/utils.py +++ b/src/pyscenic/utils.py @@ -323,7 +323,7 @@ def add_motif_url(df: pd.DataFrame, base_url: str): :param base_url: :return: """ - df[("Enrichment", COLUMN_NAME_MOTIF_URL)] = list(map(partial(urljoin, base=base_url), df.index.get_level_values(COLUMN_NAME_MOTIF_ID))) + df[("Enrichment", COLUMN_NAME_MOTIF_URL)] = list(map(partial(urljoin, base_url), df.index.get_level_values(COLUMN_NAME_MOTIF_ID))) return df From b001a5df674ca2753e8a687a94eebef5f3ff6630 Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Thu, 15 Apr 2021 14:56:04 +0200 Subject: [PATCH 2/7] Docker requirements updates - make dependabot happy --- requirements_docker.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements_docker.txt b/requirements_docker.txt index 9b0ef54..87969c7 100644 --- a/requirements_docker.txt +++ b/requirements_docker.txt @@ -1,5 +1,5 @@ adjustText==0.7.3 -aiohttp==3.7.3 +aiohttp==3.7.4 anndata==0.7.5 ansiwrap==0.8.4 appdirs==1.4.4 @@ -81,7 +81,7 @@ pathspec==0.8.1 patsy==0.5.1 pexpect==4.8.0 pickleshare==0.7.5 -Pillow==8.1.0 +Pillow==8.1.1 prompt-toolkit==3.0.15 psutil==5.8.0 ptyprocess==0.7.0 @@ -122,7 +122,7 @@ traitlets==5.0.5 typed-ast==1.4.2 typing-extensions==3.7.4.3 umap-learn==0.5.1 -urllib3==1.26.3 +urllib3==1.26.4 wcwidth==0.2.5 webencodings==0.5.1 yarl==1.6.3 From 371d0f807b89cf8491dc6af7807c7f1b9b73a610 Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Thu, 15 Apr 2021 15:24:35 +0200 Subject: [PATCH 3/7] Update sklearn tsne import - Fixes #285 - aertslab/SCENICprotocol/issues/41 --- requirements.txt | 1 + src/pyscenic/export.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 73c49af..6422672 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,3 +23,4 @@ scipy fsspec requests aiohttp +scikit-learn>=0.22.2 diff --git a/src/pyscenic/export.py b/src/pyscenic/export.py index b39f5e9..0bb27f6 100644 --- a/src/pyscenic/export.py +++ b/src/pyscenic/export.py @@ -4,7 +4,7 @@ import numpy as np import pandas as pd import loompy as lp -from sklearn.manifold.t_sne import TSNE +from sklearn.manifold import TSNE from .aucell import aucell from .genesig import Regulon from typing import List, Mapping, Union, Sequence, Optional From 4ddfd60dfe6fabda36f5a5bd908152e42af5508b Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Thu, 15 Apr 2021 15:41:11 +0200 Subject: [PATCH 4/7] Update Dockerfile - Expose 8787 for dask dashboard (#54) - Update scanpy --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 683cf3d..6731106 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN pip install --no-cache-dir --upgrade pip wheel && \ # use version from argument (--build-arg version=0.11.0), or a default: ARG version="0.11.0" RUN pip install --no-cache-dir pyscenic==$version && \ - pip install --no-cache-dir scanpy==1.7.0 + pip install --no-cache-dir scanpy==1.7.2 FROM python:3.7.9-slim AS build-image @@ -42,3 +42,5 @@ COPY --from=compile-image /opt/venv /opt/venv # Make sure we use the virtualenv: ENV PATH="/opt/venv/bin:$PATH" +EXPOSE 8787 + From f15d35a8daa1ca3ec0813ff16782f04fe59c4fca Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Thu, 15 Apr 2021 22:19:09 +0200 Subject: [PATCH 5/7] Fix for export2loom with sparse dataframe - Fix counting of genes per cell - #278 --- src/pyscenic/export.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pyscenic/export.py b/src/pyscenic/export.py index 0bb27f6..ef711f6 100644 --- a/src/pyscenic/export.py +++ b/src/pyscenic/export.py @@ -95,9 +95,7 @@ def export2loom(ex_mtx: pd.DataFrame, regulons: List[Regulon], out_fname: str, embeddings_Y = pd.merge(embeddings_Y, embedding['_Y'].to_frame().rename(columns={'_Y': str(embedding_id)}), left_index=True, right_index=True) # Calculate the number of genes per cell. - binary_mtx = ex_mtx.copy() - binary_mtx[binary_mtx != 0] = 1.0 - ngenes = binary_mtx.sum(axis=1).astype(int) + ngenes = np.count_nonzero(ex_mtx, axis=1) # Encode genes in regulons as "binary" membership matrix. genes = np.array(ex_mtx.columns) @@ -127,7 +125,7 @@ def create_structure_array(df): default_embedding.columns=['_X', '_Y'] column_attrs = { "CellID": ex_mtx.index.values.astype('str'), - "nGene": ngenes.values, + "nGene": ngenes, "Embedding": create_structure_array(default_embedding), "RegulonsAUC": create_structure_array(auc_mtx), "Clusterings": create_structure_array(clusterings), From 68343735e3a503d2612dbc270292a887137df115 Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Fri, 16 Apr 2021 14:10:17 +0200 Subject: [PATCH 6/7] Alternate method for auc thresholding - avoid making a full copy of the expression matrix --- src/pyscenic/aucell.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pyscenic/aucell.py b/src/pyscenic/aucell.py index ddb96f3..231ed00 100644 --- a/src/pyscenic/aucell.py +++ b/src/pyscenic/aucell.py @@ -60,10 +60,7 @@ def derive_auc_threshold(ex_mtx: pd.DataFrame) -> pd.DataFrame: that when using this value as the AUC threshold for 99% of the cells all ranked genes used for AUC calculation will have had a detected expression in the single-cell experiment. """ - binary_mtx = ex_mtx.copy() - binary_mtx[binary_mtx != 0] = 1.0 - n_genes = len(binary_mtx.columns) - return binary_mtx.sum(axis=1).quantile([.01, .05, .10, .50, 1])/n_genes + return pd.Series(np.count_nonzero(ex_mtx, axis=1)).quantile([.01, .05, .10, .50, 1])/ex_mtx.shape[1] enrichment = enrichment4cells From 1acff24a1c06c119a9c40e1783236248c9f0df6d Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Fri, 16 Apr 2021 16:14:07 +0200 Subject: [PATCH 7/7] Update readme --- README.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.rst b/README.rst index 7b43f1d..96239e3 100644 --- a/README.rst +++ b/README.rst @@ -18,6 +18,14 @@ in no time. The latter is achieved via the dask_ framework for distributed compu News and releases ----------------- +0.11.1 | 2021-02-11 +^^^^^^^^^^^^^^^^^^^ + +* Fix bug in motif url construction (#275) +* Fix for export2loom with sparse dataframe (#278) +* Fix sklearn t-SNE import (#285) +* Updates to Docker image (expose port 8787 for Dask dashboard) + 0.11.0 | 2021-02-10 ^^^^^^^^^^^^^^^^^^^