moscot.problems.time.LineageProblem.prepare¶
- LineageProblem.prepare(time_key, lineage_attr=mappingproxy({}), joint_attr=None, policy='sequential', cost='sq_euclidean', cost_kwargs=mappingproxy({}), a=None, b=None, marginal_kwargs=mappingproxy({}), subset=None, reference=None, xy_callback=None, x_callback=None, y_callback=None, xy_callback_kwargs=mappingproxy({}), x_callback_kwargs=mappingproxy({}), y_callback_kwargs=mappingproxy({}), x=mappingproxy({}), y=mappingproxy({}), xy=mappingproxy({}))[source]¶
Prepare the lineage problem problem.
See also
See Mapping lineage-traced cells across time points with moslin on how to prepare and solve the
LineageProblem
.
- Parameters:
time_key (
str
) – Key inobs
where the time points are stored.lineage_attr (
Mapping
[str
,Any
]) –How to get the lineage information, such as barcodes or lineage trees, for the quadratic term:
dict
- it should contain'attr'
and'key'
, the attribute and key inAnnData
, and optionally'tag'
from thetags
. If an emptydict
is passed, use pre-computed cost matrices stored inobsp['cost_matrices']
.
joint_attr (
Union
[str
,Mapping
[str
,Any
],None
]) –How to get the data for the linear term in the fused case:
dict
- it should contain'attr'
and'key'
, the attribute and key inAnnData
, and optionally'tag'
from thetags
.
By default,
tag = 'point_cloud'
is used.policy (
Literal
['sequential'
,'triu'
,'tril'
,'explicit'
]) –Rule which defines how to construct the subproblems using
obs['{time_key}']
. Valid options are:'sequential'
- align subsequent time points[(t0, t1), (t1, t2), ...]
.'triu'
- upper triangular matrix[(t0, t1), (t0, t2), ..., (t1, t2), ...]
.'tril'
- lower triangular matrix[(t_n, t_n-1), (t_n, t0), ..., (t_n-1, t_n-2), ...]
.'explicit'
- explicit sequence of subsets passed viasubset = [(b3, b0), ...]
.
cost (
Union
[Literal
['euclidean'
,'sq_euclidean'
,'cosine'
,'pnorm_p'
,'sq_pnorm'
,'geodesic'
],Literal
['barcode_distance'
,'leaf_distance'
,'custom'
],Mapping
[str
,Union
[Literal
['euclidean'
,'sq_euclidean'
,'cosine'
,'pnorm_p'
,'sq_pnorm'
,'geodesic'
],Literal
['barcode_distance'
,'leaf_distance'
,'custom'
]]]]) –Cost function to use. Valid options are:
str
- name of the cost function for all terms, seeget_available_costs()
.dict
- a dictionary with the following keys and values:'xy'
- cost function for the linear term.'x'
- cost function for the source quadratic term, e.g.,LeafDistance()
orBarcodeDistance()
.'y'
- cost function for the target quadratic term, e.g.,LeafDistance()
orBarcodeDistance()
.
cost_kwargs (
Union
[Mapping
[str
,Any
],Mapping
[Literal
['x'
,'y'
,'xy'
],Mapping
[str
,Any
]]]) – Keyword arguments for theBaseCost
or any backend-specific cost.Source marginals. Valid options are:
bool
- ifTrue
,estimate the marginals
, otherwise use uniform marginals.None
- set toTrue
ifproliferation_key
orapoptosis_key
is notNone
.
Target marginals. Valid options are:
bool
- ifTrue
,estimate the marginals
, otherwise use uniform marginals.None
- set toTrue
ifproliferation_key
orapoptosis_key
is notNone
.
marginal_kwargs (
Mapping
[str
,Any
]) – Keyword arguments forestimate_marginals()
. It always containsproliferation_key
andapoptosis_key
, seescore_genes_for_marginals()
for more information.subset (
Optional
[Sequence
[Tuple
[Union
[int
,float
],Union
[int
,float
]]]]) – Subset ofobs['{key}']
for theExplicitPolicy
. Only used whenpolicy = 'explicit'
.reference (
Optional
[Any
]) – Reference for theSubsetPolicy
. Only used whenpolicy = 'star'
.xy_callback (
Union
[Literal
['local-pca'
],Callable
[[Literal
['xy'
,'x'
,'y'
],AnnData
,Optional
[AnnData
]],Optional
[TaggedArray
]],None
]) – Callback function used to prepare the data in the linear term.x_callback (
Union
[Literal
['local-pca'
],Callable
[[Literal
['xy'
,'x'
,'y'
],AnnData
,Optional
[AnnData
]],Optional
[TaggedArray
]],None
]) – Callback function used to prepare the data in the source quadratic term.y_callback (
Union
[Literal
['local-pca'
],Callable
[[Literal
['xy'
,'x'
,'y'
],AnnData
,Optional
[AnnData
]],Optional
[TaggedArray
]],None
]) – Callback function used to prepare the data in the target quadratic term.xy_callback_kwargs (
Mapping
[str
,Any
]) – Keyword arguments for thexy_callback
.x_callback_kwargs (
Mapping
[str
,Any
]) – Keyword arguments for thex_callback
.y_callback_kwargs (
Mapping
[str
,Any
]) – Keyword arguments for they_callback
.x (
Mapping
[str
,Any
]) – Data for the source quadratic term.y (
Mapping
[str
,Any
]) – Data for the target quadratic term.xy (
Mapping
[str
,Any
]) – Data for the linear term.
- Return type:
- Returns:
: Returns self and updates the following fields:
problems
- the prepared subproblems.temporal_key
- key inobs
where time points are stored.stage
- set to'prepared'
.problem_kind
- set to'quadratic'
.