# Rebuilding the data directory from these files

Download every file into one directory. That directory's path is what you set as
`HOME_DIR` in `utils/constant.py`, or as the `ZONATION_DATA_DIR` environment variable.

Zenodo stores files in a flat list, so directory structure is carried inside the zip
archives. Three files were split into `.part*` pieces because single uploads above
~3 GB do not complete reliably, and the three background images were renamed because
they share a filename in the original layout.

## 1. Reassemble the split files

Each set of `.part*` pieces concatenates back into one file, in alphabetical order.
`cat` with a `*` glob does this correctly.

    cat background_nov23_72hr_roi1.tiff.part* > background_nov23_72hr_roi1.tiff
    cat background_pasadena_roi1.tiff.part*   > background_pasadena_roi1.tiff
    cat sprinkling_nov_23.zip.part*           > sprinkling_nov_23.zip

Verify each against the checksum of the original before going further
(`md5` on macOS, `md5sum` on Linux):

| file | MD5 |
|---|---|
| `background_nov23_72hr_roi1.tiff` | `9d588e5dd910f35c5bc82535efece121` |
| `background_pasadena_roi1.tiff` | `261f5253206141fbd589fae3c15b8f49` |
| `sprinkling_nov_23.zip` | `b98ee1ba6036b619cafdfb712254067d` |

If they match, delete the `.part*` pieces.

## 2. Unzip in place

    unzip raw.zip                # -> raw/
    unzip sprinkling_nov_23.zip  # -> sprinkling_nov_23/
    unzip perturbations.zip      # -> perturbations/
    unzip unperturbed.zip        # -> unperturbed/
    unzip sprinkled.zip          # -> sprinkled/

## 3. Put the background images back

    mkdir -p backgrounds/pasadena_roi1 backgrounds/nov23_72hr_roi1 backgrounds/nov23_12hr_roi2
    mv background_pasadena_roi1.tiff   backgrounds/pasadena_roi1/hyb_background_aligned.tiff
    mv background_nov23_72hr_roi1.tiff backgrounds/nov23_72hr_roi1/hyb_background_aligned.tiff
    mv background_nov23_12hr_roi2.tiff backgrounds/nov23_12hr_roi2/hyb_background_aligned.tiff

These keep only the channels the figures read: acquisition channel 3 for
`pasadena_roi1`, and channels 2 (GFP) and 3 (DAPI) for the two nov23 images. The
plotting code indexes them at their new positions (`_BG_CH = 0`; `_GFP_CH = 0`,
`_DAPI_CH = 1`).

## 4. Two datasets are NOT included here

Download these yourself and place them as shown:

1. **Moor et al. 2018** (Cell 175:1156-1167) — `table_A_LCM_TPM_values.tsv` and
   `table_D_zonation_reconstruction.tsv`, into `in_vivo_villus_data/`.
2. **Mouse Visium HD** — GEO accession GSE303705, into `mouse_visium/`.

## Resulting layout

    <HOME_DIR>/
      backgrounds/{pasadena_roi1,nov23_72hr_roi1,nov23_12hr_roi2}/hyb_background_aligned.tiff
      raw/  sprinkling_nov_23/  perturbations/  unperturbed/  sprinkled/
      in_vivo_villus_data/      <- you download
      mouse_visium/             <- you download
      intestinal_monolayer_spatial_data.zip

## Regenerating the figures

Code: https://github.com/nitzanlab/Self-Organization-Through-Local-Cell-Cell-Communication-Drives-Intestinal-Epithelial-Zonation

    from paper.plotScripts.plotALL import plot_all_figures
    plot_all_figures()
