Skip to content

Commit

Permalink
Merge pull request #48 from klarman-cell-observatory/yiming
Browse files Browse the repository at this point in the history
Fix issue with qcviolin function in pegasus
  • Loading branch information
bli25 committed Dec 10, 2020
2 parents d1d5464 + 665a00b commit ddd10d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ RUN apt-get -qq update && \
python3-dev \
python3-pip

RUN pip3 install setuptools --no-cache-dir && \
pip3 install cython --no-cache-dir
RUN ln -s /usr/bin/python3 /usr/bin/python

RUN python -m pip install --upgrade pip --no-cache-dir && \
python -m pip install setuptools --no-cache-dir && \
python -m pip install cython --no-cache-dir

RUN apt-get -qq -y remove curl gnupg && \
apt-get -qq -y autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/log/dpkg.log && \
ln -s /usr/bin/python3 /usr/bin/python
rm -rf /var/lib/apt/lists/* /var/log/dpkg.log

COPY . /pegasusio/
WORKDIR /pegasusio/tests
RUN git clone https://github.com/klarman-cell-observatory/pegasusio-test-data.git
WORKDIR /pegasusio/
RUN pip3 install -e .
RUN python -m pip install -e .

WORKDIR /pegasusio/tests
8 changes: 4 additions & 4 deletions pegasusio/qc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, string: str):
self.mapping = {}
self.default = None

if string is not None:
if string is not None:
fields = string.split(',')
for field in fields:
if field.find(':') >= 0:
Expand Down Expand Up @@ -98,7 +98,7 @@ def calc_qc_filters(
old_keys = old_str.split(",")
for key in old_keys:
remap[key] = new_key

unidata.obs["assignment"] = pd.Categorical(unidata.obs["assignment"].apply(lambda x: remap[x] if x in remap else x))
logger.info("Singlets are remapped.")

Expand All @@ -108,7 +108,7 @@ def calc_qc_filters(
else:
if "assignment" not in data.obs:
raise ValueError("No assignment field detected!")

subset = np.array(subset_string.split(","))
filters.append(np.isin(data.obs["assignment"], subset))

Expand Down Expand Up @@ -171,6 +171,6 @@ def apply_qc_filters(unidata: UnimodalData):
if len(unidata.varm) > 0:
unidata.varm.clear()
for key in list(unidata.uns):
if key not in {'genome', 'modality', 'norm_count'}:
if key not in {'genome', 'modality', 'norm_count', 'df_qcplot'}:
del unidata.uns[key]
logger.info(f"After filtration, {unidata.shape[0]} out of {prior_n} cell barcodes are kept in UnimodalData object {unidata.get_uid()}.")

0 comments on commit ddd10d1

Please sign in to comment.