Snakemake Rule 3: Match observations between modalities

Snakemake Rule 3: Match observations between modalities#

This rule create matching observations between MSI and Visium and saves into another spaceranger-style object.

Input#

  • MSI in spaceranger style: output/[sample]/spaceranger

Parameters#

  • agg_fn allows the user to select how multiple MSI pixels corresponding to the same Visium barcode are aggregated (‘mean’ or ‘sum’)

  • only_within_tissue specifies whether Visium barcodes should be filtered for only those labelled as within the tissue by the Space Ranger pre-processing

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

Output#

  • MSI data matched with Visium spots in spaceranger style: output/[sample]/spaceranger_aggregated

  • Correspondence between MSI pixels and Visium spots output/[sample]/matched_Visium_MSI_IDs.csv

Code (from Snakemake file)#

rule create_barcode_matrix:
    message:
        "Generating aggregated data."
    conda: 'magpie'
    input:
        "output/{sample}/spaceranger/filtered_feature_bc_matrix.h5"
    output:
        "output/{sample}/spaceranger_aggregated/filtered_feature_bc_matrix.h5"
    params:
        sample = "{sample}",
        agg_fn = 'mean',
        verbose = True,
        only_within_tissue = False
    script:
        "scripts/create_perbarcode_matrix.py"