From 66668c7679f678d6bd8ed3e0899a5deb99784532 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sun, 29 Sep 2024 20:43:00 -0500 Subject: [PATCH] Fix the issue of not updating lineage channel indices Now, the indices are updated whenever the setter is called or whenever subsetting of channels is performed. --- PyCytoData/data.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PyCytoData/data.py b/PyCytoData/data.py index 6eacf9e..ec0c14e 100644 --- a/PyCytoData/data.py +++ b/PyCytoData/data.py @@ -417,6 +417,8 @@ def subset(self, channels: Optional[ArrayLike]=None, sample: Optional[ArrayLike] self.channels = self.channels[channel_filter_condition] if self.lineage_channels is not None: self.lineage_channels = self.lineage_channels[np.isin(self.lineage_channels, self.channels)] + else: + self._lineage_channels_indices = np.arange(self.n_channels) self.sample_index = self.sample_index[filter_condition] self.cell_types = self.cell_types[filter_condition] @@ -786,6 +788,7 @@ def lineage_channels(self, lineage_channels: ArrayLike): if not np.all(np.isin(lineage_channels, self._channels)): raise ValueError("Some lineage channels are not listed in channel names.") self._lineage_channels: Optional[np.ndarray] = lineage_channels if lineage_channels is None else np.array(lineage_channels).flatten() + self._lineage_channels_indices = np.where(np.isin(self.lineage_channels, self.channels)) @property