Beispiel #1
0
def composite_codebook() -> Tuple[Codebook, ImageStack]:
    """
    Produce an Imagestack representing a composite experiment where the first 2 rounds are
    multiplexed data and the last round is sequential data.

    Returns
    -------
    Codebook :
        codebook containing codes that match the data
    ImageStack :
        noiseless ImageStack containing one spot per code in codebook
    """
    codebook_data = [{
        Features.CODEWORD: [{
            Axes.ROUND.value: 0,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }, {
            Axes.ROUND.value: 1,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_A"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 0,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }, {
            Axes.ROUND.value: 1,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_B"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 2,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_C"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 2,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_D"
    }]

    codebook = Codebook.from_code_array(codebook_data)
    imagestack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10), (6, 90, 10), (7, 90, 10)),
        codebook=codebook)
    return codebook, imagestack
Beispiel #2
0
def two_spot_one_hot_coded_data_factory(
) -> Tuple[Codebook, ImageStack, float]:
    """
    Produce a 2-channel 2-round Codebook with two codes and an ImageStack containing one spot from
    each code. The spots do not overlap and the data are noiseless.

    The encoding of this data is similar to that used in In-situ Sequencing, FISSEQ,
    BaristaSeq, STARMAP, MExFISH, or SeqFISH.

    Returns
    -------
    Codebook :
        codebook containing codes that match the data
    ImageStack :
        noiseless ImageStack containing one spot per code in codebook
    float :
        the maximum intensity found in the created ImageStack

    """

    codebook_data = [
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_A"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_B"
        },
    ]
    codebook = Codebook.from_code_array(codebook_data)

    imagestack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10)),
        codebook=codebook)

    max_intensity = np.max(imagestack.xarray.values)

    return codebook, imagestack, max_intensity
Beispiel #3
0
def two_spot_sparse_coded_data_factory() -> Tuple[Codebook, ImageStack, float]:
    """
    Produce a 3-channel 3-round Codebook with two codes and an ImageStack containing one spot from
    each code. The spots do not overlap and the data are noiseless.

    These spots display sparsity in both rounds and channels, similar to the sparse encoding of
    MERFISH

    Returns
    -------
    ImageStack :
        noiseless ImageStack containing two spots

    """

    codebook_data = [
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 2,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_A"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 2,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_B"
        },
    ]
    codebook = Codebook.from_code_array(codebook_data)

    imagestack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10)),
        codebook=codebook)

    max_intensity = np.max(imagestack.xarray.values)

    return codebook, imagestack, max_intensity
Beispiel #4
0
def two_spot_informative_blank_coded_data_factory() -> Tuple[Codebook, ImageStack, float]:
    """
    Produce a 4-channel 2-round Codebook with two codes and an ImageStack containing one spot from
    each code. The spots do not overlap and the data are noiseless.

    The encoding of this data is essentially a one-hot encoding, but where one of the channels is a
    intentionally and meaningfully "blank".

    Returns
    -------
    Codebook :
        codebook containing codes that match the data
    ImageStack :
        noiseless ImageStack containing one spot per code in codebook
    float :
        the maximum intensity found in the created ImageStack

    """

    codebook_data = [
        {
            Features.CODEWORD: [
                {Axes.ROUND.value: 0, Axes.CH.value: 0, Features.CODE_VALUE: 1},
                {Axes.ROUND.value: 1, Axes.CH.value: 1, Features.CODE_VALUE: 1},
                # round 3 is blank and channel 3 is not used
            ],
            Features.TARGET: "GENE_A"
        },
        {
            Features.CODEWORD: [
                # round 0 is blank and channel 0 is not used
                {Axes.ROUND.value: 1, Axes.CH.value: 3, Features.CODE_VALUE: 1},
                {Axes.ROUND.value: 2, Axes.CH.value: 2, Features.CODE_VALUE: 1},
            ],
            Features.TARGET: "GENE_B"
        },
    ]
    codebook = Codebook.from_code_array(codebook_data)

    imagestack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10)),
        codebook=codebook
    )

    max_intensity = np.max(imagestack.xarray.values)

    return codebook, imagestack, max_intensity
Beispiel #5
0
def composite_codebook_mixed_round() -> Tuple[Codebook, ImageStack]:
    """
    Produce an Imagestack representing a composite experiment where the first 2 and a half rounds
    are multiplexed data and the last round and a half is sequential data. This represents the type
    of hybrid experiment happening at the allen.

    Returns
    -------
    Codebook :
        codebook containing codes that match the data
    ImageStack :
        noiseless ImageStack containing one spot per code in codebook
    """
    codebook_data = [
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_A"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_B"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 2,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_C"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 2,
                Axes.CH.value: 2,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_D"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 3,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_E"
        },
    ]

    codebook = Codebook.from_code_array(codebook_data)
    imagestack = create_imagestack_from_codebook(
        pixel_dimensions=(1, 10, 10),
        spot_coordinates=((0, 5, 6), (0, 2, 3), (0, 7, 1), (0, 8, 2), (0, 3,
                                                                       6)),
        codebook=codebook)
    return codebook, imagestack
Beispiel #6
0
def compostie_codebook_seperate_stacks(
) -> Tuple[Codebook, ImageStack, ImageStack]:
    """
    Produce separate different sized ImageStacks containing data from two different experiment
    types (multiplexed and non multiplexed) and one codebook with the information for both.

    Returns
    -------
    Codebook :
        codebook containing codes that match the data
    ImageStack :
        noiseless ImageStack containing one spot per code in codebook
    """

    # 3 round 3 ch multiplexed data
    multiplexed_data = [
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 0,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 2,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_A"
        },
        {
            Features.CODEWORD: [{
                Axes.ROUND.value: 0,
                Axes.CH.value: 1,
                Features.CODE_VALUE: 1
            }, {
                Axes.ROUND.value: 1,
                Axes.CH.value: 2,
                Features.CODE_VALUE: 1
            }],
            Features.TARGET:
            "GENE_B"
        },
    ]
    codebook = Codebook.from_code_array(multiplexed_data)
    multiplexed_stack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10)),
        codebook=codebook)

    # 3 rounds 1 ch non multiplexed data
    sequential_data = [{
        Features.CODEWORD: [{
            Axes.ROUND.value: 3,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_C"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 4,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_D"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 5,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_D"
    }]
    codebook = Codebook.from_code_array(sequential_data)
    sequential_stack = create_imagestack_from_codebook(
        pixel_dimensions=(10, 100, 100),
        spot_coordinates=((4, 10, 90), (5, 90, 10), (7, 90, 10)),
        codebook=codebook)
    sequential_stack = sequential_stack.sel(indexers={Axes.ROUND: (3, 6)})

    # create codebook with combined target values
    combined = [{
        Features.CODEWORD: [{
            Axes.ROUND.value: 0,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }, {
            Axes.ROUND.value: 2,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_A"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 0,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }, {
            Axes.ROUND.value: 1,
            Axes.CH.value: 2,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_B"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 3,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_C"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 4,
            Axes.CH.value: 0,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_D"
    }, {
        Features.CODEWORD: [{
            Axes.ROUND.value: 5,
            Axes.CH.value: 1,
            Features.CODE_VALUE: 1
        }],
        Features.TARGET:
        "GENE_E"
    }]
    codebook = Codebook.from_code_array(combined)
    return codebook, multiplexed_stack, sequential_stack