Exemple #1
0
        4. Assign genes to cells
        5. Calculate area of non-stroma tissue, add up each type of gene, normalize gene density. 
"""
gene_counts_across_fovs = []

for fov in exp.fovs():
    # 1 - already completed
    # 2: Filter images and project Zplanes
    img_stack = next(exp[fov].get_images(FieldOfView.PRIMARY_IMAGES))
    img_stack_f1 = ghp.run(img_stack,  in_place=False)
    img_stack_f2 = glp.run(img_stack_f1,  in_place=False)
    img_proj_z = img_stack_f2.reduce({Axes.ZPLANE}, func='max')

    # 2: Find Spots
    spots = SpotFinder.run(img_proj_z)
    decoder = DecodeSpots.SimpleLookupDecoder(codebook=codebook)
    decoded_intensities = decoder.run(spots=spots)

    # 3:
    path = root_path + 'ilastik/classified_fovs/' + exp_name + fov + '.tif'
    mask, label_image = produceMaskFromTif(path, img_stack)

    # 4:
    al = AssignTargets.Label()
    labeled = al.run(mask, decoded_intensities)
    cg = labeled.to_expression_matrix()

    # 5:
    STROMA_ID = 2
    NON_STROMA_ID = 1
Exemple #2
0
experiment = starfish.data.allen_smFISH(use_test_data=True)
image = experiment["fov_001"].get_image(FieldOfView.PRIMARY_IMAGES)

bandpass = Filter.Bandpass(lshort=.5, llong=7, threshold=0.0)
glp = Filter.GaussianLowPass(sigma=(1, 0, 0), is_volume=True)
clip1 = Filter.Clip(p_min=50, p_max=100, level_method=Levels.SCALE_BY_CHUNK)
clip2 = Filter.Clip(p_min=99,
                    p_max=100,
                    is_volume=True,
                    level_method=Levels.SCALE_BY_CHUNK)
tlmpf = starfish.spots.FindSpots.TrackpyLocalMaxPeakFinder(
    spot_diameter=5,
    min_mass=0.02,
    max_size=2,
    separation=7,
    noise_size=0.65,
    preprocess=False,
    percentile=10,
    verbose=True,
    is_volume=True,
)
clip1.run(image, in_place=True)
bandpass.run(image, in_place=True)
glp.run(image, in_place=True)
clip2.run(image, in_place=True)
spots = tlmpf.run(image)

# Decode spots with SimpleLookupDecoder
from starfish.spots import DecodeSpots
decoder = DecodeSpots.SimpleLookupDecoder(codebook=experiment.codebook)
decoded_intensities = decoder.run(spots=spots)