From 2a1b6e5f97509990fb5dc757a29ef6cc00393c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20B=C3=B6rjesson?= Date: Wed, 22 May 2024 23:52:39 +0200 Subject: [PATCH] Fixes for parallell runs (#115) * Fixes for parallell runs * dependencies fixes --------- Co-authored-by: Parashar --- requirements.txt | 2 +- scarf/datastore/datastore.py | 13 ++++++++----- scarf/metadata.py | 6 +++++- scarf/plots.py | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index dea42e1..b4d64a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ numcodecs umap-learn scikit-learn scikit-network -scipy +scipy==1.11.0 statsmodels seaborn tqdm diff --git a/scarf/datastore/datastore.py b/scarf/datastore/datastore.py index 033fed5..62d5585 100644 --- a/scarf/datastore/datastore.py +++ b/scarf/datastore/datastore.py @@ -374,6 +374,13 @@ def run_marker_search( if n_threads is None: n_threads = self.nthreads assay = self._get_assay(from_assay) + + slot_name = f"{cell_key}__{group_key}" + z = self.zw[assay.name] + if "markers" not in z: + z.create_group("markers") + group = z["markers"].create_group(slot_name, overwrite=True) + markers = find_markers_by_rank( assay=assay, group_key=group_key, @@ -385,11 +392,7 @@ def run_marker_search( n_threads=n_threads, **norm_params, ) - z = self.zw[assay.name] - slot_name = f"{cell_key}__{group_key}" - if "markers" not in z: - z.create_group("markers") - group = z["markers"].create_group(slot_name, overwrite=True) + for i in markers: g = group.create_group(i) vals = markers[i] diff --git a/scarf/metadata.py b/scarf/metadata.py index b874825..2027848 100644 --- a/scarf/metadata.py +++ b/scarf/metadata.py @@ -1,5 +1,6 @@ """Contains the MetaData class, which is used for storing metadata about cells and features.""" + import re from typing import List, Iterable, Any, Dict, Tuple, Optional, Union import numpy as np @@ -61,7 +62,10 @@ def _get_size(self, zgrp: zarrGroup, strict_mode: bool = False) -> int: """ sizes = [] for i in zgrp.keys(): - sizes.append(zgrp[i].shape[0]) + try: + sizes.append(zgrp[i].shape[0]) + except Exception: + pass if len(sizes) > 0: if len(set(sizes)) != 1: raise ValueError( diff --git a/scarf/plots.py b/scarf/plots.py index 291c35c..5353f0e 100644 --- a/scarf/plots.py +++ b/scarf/plots.py @@ -467,7 +467,7 @@ def _scatter_fix_mask(v: pd.Series, mask_vals: list, mask_name: str) -> pd.Serie def _scatter_make_colors( v: pd.Series, cmap, color_key: Optional[dict], mask_color: str, mask_name: str ): - from matplotlib.cm import get_cmap + from matplotlib.pyplot import get_cmap na_idx = v == mask_name uv = v[~na_idx].unique()