From e24bd2942db67af07104705bc3ad40acfe2f57d1 Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Mon, 28 Aug 2023 01:49:12 -0700 Subject: [PATCH 1/2] use set intersection --- scSLAT/viz/multi_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scSLAT/viz/multi_dataset.py b/scSLAT/viz/multi_dataset.py index 5646b06..2814d69 100644 --- a/scSLAT/viz/multi_dataset.py +++ b/scSLAT/viz/multi_dataset.py @@ -225,7 +225,7 @@ def __init__(self,dataset_A:pd.DataFrame, set2 = list(set(self.dataset_B[meta])) self.celltypes = set1 + [x for x in set2 if x not in set1] self.celltypes.sort() # make sure celltypes are in the same order - overlap = [x for x in set2 if x in set1] + overlap = set2.intersection(set1) print(f"dataset1: {len(set1)} cell types; dataset2: {len(set2)} cell types; \n\ Total :{len(self.celltypes)} celltypes; Overlap: {len(overlap)} cell types \n\ Not overlap :[{[y for y in (set1+set2) if y not in overlap]}]" @@ -744,4 +744,4 @@ def matching_2d(matching:np.ndarray, del src.obs['target_celltype'] del src.obs['target_region'] - del src.obs['vis'] \ No newline at end of file + del src.obs['vis'] From 89cfa72601469057c42e15ba1c1db10a61011607 Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Mon, 4 Sep 2023 23:58:02 -0700 Subject: [PATCH 2/2] fix type error --- scSLAT/viz/multi_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scSLAT/viz/multi_dataset.py b/scSLAT/viz/multi_dataset.py index 2814d69..3ac9a39 100644 --- a/scSLAT/viz/multi_dataset.py +++ b/scSLAT/viz/multi_dataset.py @@ -225,7 +225,7 @@ def __init__(self,dataset_A:pd.DataFrame, set2 = list(set(self.dataset_B[meta])) self.celltypes = set1 + [x for x in set2 if x not in set1] self.celltypes.sort() # make sure celltypes are in the same order - overlap = set2.intersection(set1) + overlap = set(set2).intersection(set1) print(f"dataset1: {len(set1)} cell types; dataset2: {len(set2)} cell types; \n\ Total :{len(self.celltypes)} celltypes; Overlap: {len(overlap)} cell types \n\ Not overlap :[{[y for y in (set1+set2) if y not in overlap]}]"