def saveTable(table: DecodedIntensityTable, savename: str): """ Reformats and saves a DecodedIntensityTable. """ intensities = IntensityTable( table.where(table[Features.PASSES_THRESHOLDS], drop=True)) traces = intensities.stack(traces=(Axes.ROUND.value, Axes.CH.value)) # traces = table.stack(traces=(Axes.ROUND.value, Axes.CH.value)) traces = traces.to_features_dataframe() traces.to_csv(savename)
spot_intensities, results = psd.run(filtered_imgs) spot_intensities = IntensityTable( spot_intensities.where(spot_intensities[Features.PASSES_THRESHOLDS], drop=True)) ################################################################################################### # Here, we: # # 1. Pick a rolony that was succesfully decoded to a gene. # 2. Pull out the average pixel trace for that rolony. # 3. Plot that pixel trace against the barcode of that gene. # # In order to assess, visually, how close decoded barcodes match their targets. # reshape the spot intensity table into a RxC barcode vector pixel_traces = spot_intensities.stack(traces=(Axes.ROUND.value, Axes.CH.value)) # extract dataframe from spot intensity table for indexing purposes pixel_traces_df = pixel_traces.to_features_dataframe() pixel_traces_df['area'] = np.pi * pixel_traces_df.radius**2 # pick index of a barcode that was read and decoded from the ImageStack ind = 4 # get the the corresponding gene this barcode was decoded to gene = pixel_traces_df.loc[ind].target # query the codebook for the actual barcode corresponding to this gene real_barcode = experiment.codebook[experiment.codebook.target == gene].stack( traces=(Axes.ROUND.value, Axes.CH.value)).values[0] read_out_barcode = pixel_traces[ind, :]
plt.gca().add_collection(pc) plt.figure(figsize=(10,10)) plt.imshow(new_image[600:800, 100:300], cmap = 'nipy_spectral'); plt.axis('off'); plt.title('Coded rolonies, zoomed in'); # EPY: END code # EPY: START markdown #### visualization of matched barcodes #here, we 1. pick a rolony that was succesfully decoded to a gene. 2. pull out the average pixel trace for that rolony and 3. plot that pixel trace against the barcode of that gene # EPY: END markdown # EPY: START code # reshape the spot intensity table into a RxC barcode vector pixel_traces = spot_intensities.stack(traces=(Indices.ROUND.value, Indices.CH.value)) # extract dataframe from spot intensity table for indexing purposes pixel_traces_df = pixel_traces.to_features_dataframe() pixel_traces_df['area'] = np.pi*pixel_traces_df.radius**2 # pick index of a barcode that was read and decoded from the ImageStack ind = 4 # The test will error here on pixel_traces[ind,:] with an out of index error # because we are using the test data. # get the the corresponding gene this barcode was decoded to gene = pixel_traces_df.loc[ind].target # query the codebook for the actual barcode corresponding to this gene