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', mask_obs=None)#
Computes the layout of the clonotype network.
Requires running
scirpy.tl.define_clonotypes()orscirpy.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_genewas 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_cellsandmin_nodesparameters.The
componentslayout algorithm takes node sizes into account, avoiding overlapping nodes. Therefore, we recommend specifyingbase_sizeandsize_poweralready here instead of providing them toscirpy.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')) – Thesequenceparameterscirpy.tl.define_clonotypes()was ran with.metric (
Union[Literal['alignment','fastalignment','identity','levenshtein','hamming','gpu_haming','normalized_hamming','tcrdist'],DistanceCalculator] (default:'identity')) – Themetricparameterscirpy.tl.define_clonotypes()was ran with.min_cells (
int(default:1)) – Only show clonotypes consisting of at leastmin_cellscellsmin_nodes (
int(default:1)) – Only show clonotypes consisting of at leastmin_nodesnodes (i.e. non-identical receptor configurations)layout (
str(default:'components')) – The layout algorithm to use. Can be anything supported byigraph.Graph.layout, or “components” to layout all connected components individually.scirpy.util.graph.layout_components()for more details.size_aware (
bool(default:True)) – IfTrue, use a node-size aware layouting algorithm. This option is only compatible withlayout = 'components'.base_size (
float|None(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 (
dict|None(default:None)) – Will be passed to the layout functionclonotype_key (
str|None(default:None)) – Key under which the result ofscirpy.tl.define_clonotypes()orscirpy.tl.define_clonotype_clusters()is stored inadata.uns. Defaults toclone_idifsequence == 'nt' and distance == 'identity'orcc_{sequence}_{metric}otherwise.key_added (
str(default:'clonotype_network')) – Key under which the layout coordinates will be stored inadata.obsmand parameters will be stored inadata.uns.inplace (
bool(default:True)) – IfTrue, store the coordinates inadata.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 theMuDataobject. if anAnnDataobject is passed to the function, this parameter is ignored.mask_obs (
ndarray[bool] |str|None(default:None)) – Boolean mask or the name of the column in anndata.obs that contains the boolean mask to select cells to filter the clonotype clusters that should be displayed in the graph. Only connected modules in the clonotype distance graph that contain at least one of these cells will be shown. Can be set to None to avoid filtering.
- Return type:
- Returns:
Depending on the value of
inplacereturns either nothing or the computed coordinates.