plankton package

Submodules

plankton.graph module

class plankton.graph.SpatialGraph(sdata, n_neighbors=10)

Bases: object

SpatialGraph: Container object for all KNN-graph based operations on spatial data sets.

Parameters
  • sdata (plankton.SpatialData) – The spatial data source

  • n_neighbors (int, optional) – number of nearset neighbors to infer, defaults to 10

property distances

distances: Returns an array of inter-spot distances, which each entry encoding the distance to a defined neighbor.

Returns

2d array of distances to the data points of self.neighbors.

Return type

numpy.Array

knn_entropy(n_neighbors=4)
map_and_umap(color_prop=None, scalebar=True, cmap='jet', **kwargs)

map_and_umap: Plots a side-by-side representation of the available UMAP- and coordinate data, with styling arguments passed to both plotting functions.

Parameters
  • color_prop (_type_, optional) – Property to color the individual markers by. Needs to be a column in self.sdata.var, defaults to None

  • scalebar (bool, optional) – Whether to display a scalebar in the coordinate representation, defaults to True

property neighbor_types

neighbor_types: Returns an array of gene_ids for the spots listed in self.neighbors

Returns

2d array of gene_ids.

Return type

numpy.Array

property neighbors

neighbors: Returns an array of neighbors, where each entry encoding the row position of a point in the data set.

Returns

2d array of n-neighbors per sample data point

Return type

numpy.Array

plot_entropy(n_neighbors=4)
plot_umap(color_prop='genes', text_prop=None, text_color_prop=None, c=None, color=None, color_dict=None, text_distance=1, thlds_text=(1.0, 0.0, 0.0), text_kwargs={}, legend=False, **kwargs)
run_umap(bandwidth=1, kernel=None, metric='euclidean', zero_weight=1.0, cutoff=None, random_state=None, *args, **kwargs)

run_umap: Creates a UMAP representation of recurring local contexts in the source data.

Parameters
  • bandwidth (int, optional) – Bandwidth of the default Gaussian kernel used to build local environment models, defaults to 1

  • kernel (callable, optional) – Callable function to generate a model of the local spatial context for each spot’s KNN graph. If none is provided, the default Gaussian is used. Defaults to None

  • metric (str, callable, optional) – Kernel description used as a UMAP parameter, defaults to ‘euclidean’

  • zero_weight (float, optional) – Regularization parameter that adds information of each spot’s gene label to its local context model. High value encourages spots to form clusters with spots of their own gene label, defaults to 1

  • random_state (int) – Random state to initialize UMAP and FastICA.

property umap

umap: Returns the coordinates of the UMAP representation of the source data.

Returns

UMAP coordinates

Return type

numpy.Array

property umap_0
property umap_1
umap_js(color_prop='c_genes')

umap_js: A javascript-based display and selection function for the spatial source data and generated UMAP embedding. Can be used to understand UMAP agglomerations by displaying their gene compositions and projecting them back onto the original source data coordinates.

Parameters

color_prop (str, optional) – Property by which to color the spots in the scatter plots of the source data coordinates as well as the UMAP representation. Needs to be a column in sdata.var, defaults to ‘c_genes’

Returns

plotly HTML/javascript widget that displays in the jupyter notebook.

Return type

plotly.Widget

update_knn(n_neighbors, re_run=True)

update_knn: Updates the KNN representation that gives rise to self.neighbors, self.distances and self.neighbor_types. This does not happen automatically after slicing, so it should be performed regularity before any graph-based analysis. Can be memory-intensive.

Parameters
  • n_neighbors (int) – Number of neighbors for each neighbor graph.

  • re_run (bool, optional) – re-run, or use current representation, defaults to True

plankton.pixelmaps module

plankton.plankton module

plankton.stats module

plankton.stats.co_cooccurrence(sdata_0, sdata_1, resolution=5.0, max_radius=400, linear_steps=5, category=None)

co_occurrence _summary_

Parameters
  • sdata (SpatialData) – SpatialData - all spots contained in sdata will be analysed.

  • resolution (float, optional) – Smallest resolution of the co-occurence model in um, defaults to 5.

  • max_radius (float, optional) – Largest radius of the co-occurrence model in um, defaults to 400.

  • linear_steps (int, optional) – Number of linear steps to model local heterogeniety. Afterwards, distance bins get wider to save computational resources, defaults to 5

  • category (str, optional) – Category to model the co-occurrence of. Must be a column in ‘sdata’ with dtype ‘category’. When given ‘None’, the algorithm defaults to gene labels.

Returns

_description_

Return type

_type_

plankton.stats.co_occurrence(sdata, resolution=5.0, max_radius=400, linear_steps=5, category=None)

co_occurrence _summary_

Parameters
  • sdata (SpatialData) – SpatialData - all spots contained in sdata will be analysed.

  • resolution (float, optional) – Smallest resolution of the co-occurence model in um, defaults to 5.

  • max_radius (float, optional) – Largest radius of the co-occurrence model in um, defaults to 400.

  • linear_steps (int, optional) – Number of linear steps to model local heterogeniety. Afterwards, distance bins get wider to save computational resources, defaults to 5

  • category (str, optional) – Category to model the co-occurrence of. Must be a column in ‘sdata’ with dtype ‘category’. When given ‘None’, the algorithm defaults to gene labels.

Returns

_description_

Return type

_type_

plankton.stats.get_histograms(sdata, category=None, resolution=5, mins=None, maxs=None)
plankton.stats.mor_normalize(stats1, stats2)

mor_normalize _summary_

Parameters
  • stats1 (_type_) – _description_

  • stats2 (_type_) – _description_

plankton.stats.ripleys_k(sdata, resolution=5, max_radius=400, linear_steps=5, category=None)

plankton.utils module

Module contents