# How to match HTX samples with the closest MGX sampling in IBDMDB?

**URL:** <https://forum.biobakery.org/t/how-to-match-htx-samples-with-the-closest-mgx-sampling-in-ibdmdb/8624>\
**Category:** IBDMDB\
**Created:** [November 17, 2025, 7:12pm UTC](https://forum.biobakery.org/t/how-to-match-htx-samples-with-the-closest-mgx-sampling-in-ibdmdb/8624 "2025-11-17T19:12:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daisakon1109](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/daisakon1109/32/3479_2.png) [@daisakon1109](https://forum.biobakery.org/u/daisakon1109)\
**Post date:** [November 17, 2025, 7:12pm UTC](https://forum.biobakery.org/t/how-to-match-htx-samples-with-the-closest-mgx-sampling-in-ibdmdb/8624/1 "2025-11-17T19:12:35Z")

</div>

Hello,  
I am currently trying to integrate host transcriptome (HTX) data with metagenomic (MGX) data from IBDMDB in order to analyze associations between host gene expression and the gut microbiome.

To do this properly, I would like to match each HTX sample with the MGX sample collected **as close in time as possible**.  
However, I am not sure **which metadata fields should be used to determine the sampling dates**.

For example:

- **`week_num`** appears to match between HTX and MGX samples from the same subject.

- But **`visit_num` does _not_ match** (e.g., HTX samples are almost always `visit_num = 1`, while MGX samples for the same subject are often `visit_num ≥ 4`).

Therefore, I would like to ask:

1. **What exactly do `week_num` and `visit_num` represent in IBDMDB metadata?**

2. **What is the recommended way to identify the MGX sample taken closest to an HTX sampling timepoint?**

Any clarification on how to correctly pair HTX and MGX samples would be greatly appreciated.  
Thank you very much for your help!
