def cell_origin(data, groupby='<STR_LIT>', disconnected_groups=None, self_transitions=False, n_neighbors=None, copy=False):
adata = data.copy() if copy else data<EOL>logg.info('<STR_LIT>', r=True)<EOL>n_neighbors = <NUM_LIT:10> if n_neighbors is None else n_neighbors<EOL>_adata = adata.copy()<EOL>vgraph = VelocityGraph(_adata, n_neighbors=n_neighbors, approx=True, n_recurse_neighbors=<NUM_LIT:1>)<EOL>vgraph.compute_cosines()<EOL>_adata.uns['<STR_LIT>'] = vgraph.graph<EOL>_adata.uns['<STR_LIT>'] = vgraph.graph_neg<EOL>T = transition_matrix(_adata, self_transitions=self_transitions, backward=True)<EOL>I = np.eye(_adata.n_obs)<EOL>fate = np.linalg.inv(I - T)<EOL>if issparse(T): fate = fate.A<EOL>cell_fates = np.array(_adata.obs[groupby][fate.argmax(<NUM_LIT:1>)])<EOL>if disconnected_groups is not None:<EOL><INDENT>idx = _adata.obs[groupby].isin(disconnected_groups)<EOL>cell_fates[idx] = _adata.obs[groupby][idx]<EOL><DEDENT>adata.obs['<STR_LIT>'] = cell_fates<EOL>adata.obs['<STR_LIT>'] = fate.max(<NUM_LIT:1>) / fate.sum(<NUM_LIT:1>)<EOL>strings_to_categoricals(adata)<EOL>logg.info('<STR_LIT>', time=True, end='<STR_LIT:U+0020>' if settings.verbosity > <NUM_LIT:2> else '<STR_LIT:\n>')<EOL>logg.hint(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>
Computes individual cell root points

        Arguments
        ---------
        data: :class:`~anndata.AnnData`
            Annotated data matrix.
        groupby: `str` (default: `'clusters'`)
            Key to which to assign the fates.
        disconnected_groups: list of `str` (default: `None`)
            Which groups to treat as disconnected for fate assignment.
        n_neighbors: `int` (default: `None`)
            Number of neighbors to restrict transitions to.
        copy: `bool` (default: `False`)
            Return a copy instead of writing to `adata`.

        Returns
        -------
        Returns or updates `adata` with the attributes
        cell_origin: `.obs`
            most likely cell origin for each individual cell
        cell_origin_confidence: `.obs`
            confidence of coming from assigned origin