scdef.tl.get_obs_value_specific_factors ¶
get_obs_value_specific_factors(model: scDEF, layer: Union[int, str], obs_key: str, obs_values: Union[str, Sequence[str]], mode: Literal['f1', 'fracs', 'weights', 'prob', 'soft_prec', 'score'] = 'fracs', min_specificity: float = 0.0, top_n: Optional[int] = None, recompute: bool = False, return_scores: bool = False) -> Union[Dict[str, List[str]], DataFrame]
Get factors specific to each obs value in a layer.
Specificity is defined within the provided obs_values as:
specificity = score(obs_value) - max(score(other_obs_values)).
Higher values indicate stronger specificity for that obs category.
Note that specificity is relative to the obs_values given, not to the whole
annotation: passing two of five cell types asks which factors separate those
two, not which are unique across all five.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
fitted scDEF model. |
required |
layer
|
Union[int, str]
|
layer to search, as an index or a name from |
required |
obs_key
|
str
|
column in |
required |
obs_values
|
Union[str, Sequence[str]]
|
values of |
required |
mode
|
Literal['f1', 'fracs', 'weights', 'prob', 'soft_prec', 'score']
|
association score to compute specificity from — see
|
'fracs'
|
min_specificity
|
float
|
drop factors whose margin over the best competing value falls below this. The default of 0.0 keeps any factor that leads. |
0.0
|
top_n
|
Optional[int]
|
keep at most this many factors per value, most specific first.
Defaults to all that pass |
None
|
recompute
|
bool
|
force the underlying score matrix to be recomputed rather than read from cache. |
False
|
return_scores
|
bool
|
return the full table with the specificity margins and the competing value, instead of just the factor names. |
False
|
Returns:
| Type | Description |
|---|---|
Union[Dict[str, List[str]], DataFrame]
|
Factor names per |
Union[Dict[str, List[str]], DataFrame]
|
DataFrame with the score, the margin, and which value came second. |