Skip to content

Commit

Permalink
Fix the issue of not updating lineage channel indices
Browse files Browse the repository at this point in the history
Now, the indices are updated whenever the setter is called or whenever subsetting of channels is performed.
  • Loading branch information
kevin931 committed Sep 30, 2024
1 parent e8eef37 commit 66668c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PyCytoData/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 66668c7

Please sign in to comment.