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)
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_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
andmin_nodes
parameters.The
components
layout algorithm takes node sizes into account, avoiding overlapping nodes. Therefore, we recommend specifyingbase_size
andsize_power
already here instead of providing them toscirpy.pl.clonotype_network()
.Stores coordinates of the clonotype network in
adata.obsm
.- Parameters
- adata :
AnnData
annotated data matrix
- sequence : {‘aa’, ‘nt’}
Literal
[‘aa’, ‘nt’] (default:'nt'
) The
sequence
parameterscirpy.tl.define_clonotypes()
was ran with.- metric : {‘identity’, ‘alignment’, ‘levenshtein’, ‘hamming’, ‘custom’}
Literal
[‘identity’, ‘alignment’, ‘levenshtein’, ‘hamming’, ‘custom’] (default:'identity'
) The
metric
parameterscirpy.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 withlayout = 'components'
.- base_size :
float
|None
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 :
dict
|None
Optional
[dict
] (default:None
) Will be passed to the layout function
- clonotype_key :
str
|None
Optional
[str
] (default:None
) Key under which the result of
scirpy.tl.define_clonotypes()
orscirpy.tl.define_clonotype_clusters()
is stored inadata.uns
. Defaults toclone_id
ifsequence == 'nt' and distance == 'identity'
orcc_{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 inadata.uns
.- inplace :
bool
(default:True
) If
True
, store the coordinates inadata.obsm
, otherwise return them.- random_state
Random seed set before computing the layout.
- adata :
- Return type
- Returns
Depending on the value of
inplace
returns either nothing or the computed coordinates.