Snakemake Rule 1: Transform coordinates to match between modalities

Snakemake Rule 1: Transform coordinates to match between modalities#

This step takes landmarks identified through the MAGPIE app (or otherwise) and calculates new MSI coordinates in the same coordinate system.

Input#

  • MSI data: input/[sample]/msi/MSI_metadata.csv, input/[sample]/msi/MSI_HE.[jpg/tiff/png] (optional)

  • Landmarks: input/[sample]/landmarks_noHE.csv or input/[sample]/landmarks_MSI2HE.csv and input/[sample]/landmarks_HE2HE.csv

Parameters#

  • no_HE_transform, MSI2HE_transform, HE2HE_transform can be set to ‘affine’ or ‘TPS’ depending on the whether a linear or non-linear transformation is preferred. We have generally seen that using affine for MSI2HE and no_HE and TPS for HE2HE can work well

  • verbose determines how much information about different stages of the process is delivered to the user

Output#

  • New MSI coordinates: output/[sample]/transformed.csv

  • New MSI coordinates overlaid on Visium image transformed_withCoords_VisiumHE.png

  • New H&E image output/[sample]/transformed.png (transformed MSI image if available or Visium image otherwise)

  • New H&E image with new MSI coordinates overlaid output/[sample]/transformed_withCoords.png

Example outputs#

transformed_withCoords_VisiumHE.png

app_options

output/[sample]/transformed_withCoords.png

app_options

transformed.png

app_options

Code (from Snakemake file)#

rule perform_coreg:
    message:
        "Performing co-registration."
    conda: 'magpie'
    input:
        "input/{sample}/msi/MSI_metadata.csv",
        "output/summary.csv"
    output:
        "output/{sample}/transformed.csv",
        "output/{sample}/transformed.png"
    params:
        no_HE_transform = 'affine',
        MSI2HE_transform = 'affine',
        HE2HE_transform = 'TPS',
        sample = "{sample}",
        verbose = True
    script:
        "scripts/alter_data.py"