# Remove channel entries using a keys/entries from another channel

**URL:** <https://community.seqera.io/t/remove-channel-entries-using-a-keys-entries-from-another-channel/564>\
**Category:** Tips & Tricks\
**Tags:** nextflow\
**Created:** [March 14, 2024, 9:04am UTC](https://community.seqera.io/t/remove-channel-entries-using-a-keys-entries-from-another-channel/564 "2024-03-14T09:04:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [March 14, 2024, 9:04am UTC](https://community.seqera.io/t/remove-channel-entries-using-a-keys-entries-from-another-channel/564/1 "2024-03-14T09:04:37Z")

</div>

The channel operators `join` and `combine` are good for pairing up channel entries with a shared key. However, there are times when you want to exclude entries based what’s in another channel, e.g. similar to `grep -v` option. Another way this can be thought off is the set difference, or anti-join.

One way to achieve this is by adding a sentinel value to your list of keys to exclude. Then, after using `groupTuple` or `join`, you can exclude (`filter`) the entries with the sentinel value. e.g.

```auto
workflow {
   ch1 = Channel.of([1, "A", "file"], [2, "B", "file"], [1, "A", "file"], [2, "B", "file"], [3, "C", "file"], [4, "D", "file"])
   ch2 = Channel.of(1, 3, 5)
   ch1.mix(ch2.map { num -> [num, 1] }) // 1 is the sentinel value
        .groupTuple()
        .filter{ 1 !in it[1] }
        .transpose()
        .view()
}

```

The only downside here is that this operation has to wait until all the entries from the channels have been received to emit the non-excluded entries since there’s no way to know apriori the number of entries a group should contain.

This post was inspired by these questions in Slack:

- [Slack](https://nextflow.slack.com/archives/C02T98A23U7/p1710362296655549?thread_ts=1710353550.101109&cid=C02T98A23U7)
- [Slack](https://nextflow.slack.com/archives/C02T98A23U7/p1655717436790319?thread_ts=1655215577.441589&cid=C02T98A23U7)
