scirpy.tl.clonotype_network

scirpy.tl.clonotype_network#

scirpy.tl.clonotype_network(adata, *, sequence='nt', metric='identity', min_cells=1, min_nodes=1, layout='components', size_aware=True, base_size=None, size_power=1, layout_kwargs=None, clonotype_key=None, key_added='clonotype_network', inplace=True, random_state=42, airr_mod='airr')#

Computes the layout of the clonotype network.

Requires running scirpy.tl.define_clonotypes() or scirpy.tl.define_clonotype_clusters() first.

The clonotype network usually consists of many disconnected components, each of them representing a clonotype. Each node represents cells with an identical receptor configuration (i.e. identical CDR3 sequences, and identical v genes if same_v_gene was specified during clonotype definition). The size of each dot refers to the number of cells with the same receptor configurations.

For more details on the clonotype definition, see scirpy.tl.define_clonotype_clusters() and the respective section in the tutorial.

Singleton clonotypes can be filtered out with the min_cells and min_nodes parameters.

The components layout algorithm takes node sizes into account, avoiding overlapping nodes. Therefore, we recommend specifying base_size and size_power already here instead of providing them to scirpy.pl.clonotype_network().

Stores coordinates of the clonotype network in adata.obsm.

Parameters:
  • adata (Union[AnnData, MuData, DataHandler]) – AnnData or MuData object that contains AIRR information.

  • sequence (Literal['aa', 'nt'] (default: 'nt')) – The sequence parameter scirpy.tl.define_clonotypes() was ran with.

  • metric (Literal['identity', 'alignment', 'levenshtein', 'hamming', 'custom'] (default: 'identity')) – The metric parameter scirpy.tl.define_clonotypes() was ran with.

  • min_cells (int (default: 1)) – Only show clonotypes consisting of at least min_cells cells

  • min_nodes (int (default: 1)) – Only show clonotypes consisting of at least min_nodes nodes (i.e. non-identical receptor configurations)

  • layout (str (default: 'components')) – The layout algorithm to use. Can be anything supported by igraph.Graph.layout, or “components” to layout all connected components individually. scirpy.util.graph.layout_components() for more details.

  • size_aware (bool (default: True)) – If True, use a node-size aware layouting algorithm. This option is only compatible with layout = 'components'.

  • base_size (Optional[float] (default: None)) – Size of a point respresenting 1 cell. Per default, this value is a automatically determined based on the number of nodes in the plot.

  • size_power (float (default: 1)) – Sizes are raised to the power of this value. Set this to, e.g. 0.5 to dampen point size.

  • layout_kwargs (Optional[dict] (default: None)) – Will be passed to the layout function

  • clonotype_key (Optional[str] (default: None)) – Key under which the result of scirpy.tl.define_clonotypes() or scirpy.tl.define_clonotype_clusters() is stored in adata.uns. Defaults to clone_id if sequence == 'nt' and distance == 'identity' or cc_{sequence}_{metric} otherwise.

  • key_added (str (default: 'clonotype_network')) – Key under which the layout coordinates will be stored in adata.obsm and parameters will be stored in adata.uns.

  • inplace (bool (default: True)) – If True, store the coordinates in adata.obsm, otherwise return them.

  • random_state (default: 42) – Random seed set before computing the layout.

  • airr_mod (default: 'airr') – Name of the modality with AIRR information is stored in the MuData object. if an AnnData object is passed to the function, this parameter is ignored.

Return type:

Optional[DataFrame]

Returns:

Depending on the value of inplace returns either nothing or the computed coordinates.