Data Structure¶
Here are some tips for using so (a spatial object datastructure).
SO Important Features:¶
so.image_temp()Provides the image portion covered by spots.
so.segmentation_finalGives the nuclei segmentation plot.
so.pixels_cellsRepresents the final results of cells with the same format as
so.segmentation_final.
so.final_nucleiStores the nuclei * genes
adatamatrix.
SO Great Results:¶
adata_sc_finalobs:cell_cluster: Denotes the cluster assignment from the iteration.cos_simularity: The cosine similarity of the cell’s gene expression with the average expression of its cluster.cell_size: The number of2umspots occupied by this cell.xandy: The absolute coordinates of the cell, matching the spot locations provided by 10x.
var:The same as 10x provide for spots*genes array.
SO Beautiful Visualization:¶
1. plot_cellcluster_position¶
plot_cellcluster_position(cell_cluster_final, col_num=5)
This function is often used after return_celltype_plot as:
Example:
import smurf as su
cell_cluster_final = su.return_celltype_plot(adata_sc, so, cluster_name='leiden')
su.plot_cellcluster_position(cell_cluster_final, col_num=5)
It plots the probability of each cell cluster. The first plot will contain all clusters, followed by one plot per cluster.
2. plot_results¶
plot_results(original_image, result_image, transparency=0.6, transparent_background=False, include_label=None, colors=None, dpi=1500, figsize=(20, 20), save=None)
This function allows you to plot results with the same format as So.segmentation_final mapped onto so.image_temp().
Parameters:
original_imageNormally input
so.image_temp().
result_imageRepresents the final results of cells with the same format as
So.segmentation_final.
transparency(float, optional):The transparency of the result_image. Should be in the range (0, 1].
ransparent_background(bool, optional):Whether the zero parts of
result_imageshould be transparent.
include_label(bool, optional):Whether to include a label indicating which color refers to which cluster. Useful for cell cluster results and only valid when the number of unique clusters is ≤ 50.
colors(list of tuples, optional):Provide your own colors in the format like
[(255, 0, 0), (0, 255, 0), ...]. Will use the default colors ifNone.
dpi(int, optional):The resolution of the plot. A higher value may decrease speed; a lower value may reduce quality.
figsize(tuple, optional):Size of the figure in inches
(width, height). Default is(20, 20).
save(str or None, optional):The filename to save the plot. If
FalseorNone, the plot will be shown but not saved.
Example:
import smurf as su
su.plot_results(so.image_temp(), so.pixels_cells)