Skip to content

Cellrank component #6

Open
Open
@bio-la

Description

@bio-la

from velocity_component import velocity_vectors

1. Initialize kernel

from cellrank.tl.kernels import VelocityKernel
vk = VelocityKernel(adata)

input: anndata with velocity vectors
output: initialized kernel object

2. Compute transition matrix

vk.compute_transition_matrix()

input: initialized kernel object
output: kernel object with transition matrix

3. optional but recommended correct velocity kernel by combining with connectivity kernel

ck = ConnectivityKernel(adata).compute_transition_matrix()
#NB 3.1,3.2 are just 1,2 with different param choice

3.1 compute connectivity kernel 
	input: anndata with connectivities
	output: kernel object 

3.2 compute transition matrix
	input: initialized kernel object
	output: kernel object with transition matrix

3.3 combine kernels
	input: 2 kernels and combining ratio (combined_kernel = 0.8 * vk + 0.2 * ck)
	output: combined kernel with transition matrix

4. initialize estimator for matrix decomposition

from cellrank.tl.estimators import GPCCA
g = GPCCA(combined_kernel)

#note best estimator is GPCCA use this by default
input: kernel with transition matrix
output: *estimator* initialized object with transition matrix (anndata)

5. compute matrix decomposition

g.compute_schur(n_components=20)

params: 
		- no of components (usually 20)
		- method: default to krylov for GPCCA

input: *estimator* initialized object with transition matrix (anndata)
output: *estimator* object with transition matrix decomposition (anndata)
#nb this can be plotted

6. compute macrostates

g.compute_macrostates(n_states=3, cluster_key="clusters")

params: 
		- number of macrostates if known, or from inspection of re(gamma) vs eigenvalue index plot
		- clustering info (NB don't understand if this can be run without clustering altogether)

input: *estimator* object with transition matrix decomposition	(anndata)	
output: *estimator* object with computed macrostates (anndata)
#nb this can be plotted

7. identify terminal states from macrostates

options:

	- automatic  
		estimator.compute_terminal_states()
		input: *estimator* object with computed macrostates (anndata)
		output: *estimator* object with terminal states in obs (anndata)
	
	- restrict macrostates to a list of states known beforehand
		estimator.set_terminal_states_from_macrostates()
		input: *estimator* object with computed macrostates (anndata) + list of states
		output: *estimator* object with terminal states in obs (anndata)
	
	- manually set terminal states ignoring macrostates
		estimator.set_terminal_states()
		input: *estimator* object with computed macrostates (anndata) + list of states
		output: *estimator* object with terminal states in obs (anndata)

8. estimate fate probabilties (absorption)

g.compute_absorption_probabilities()

input: *estimator* object with terminal states in obs (anndata)
output: *estimator* object with fate probabilities in obs (anndata)

9. find driver genes (correlate GEX with fate prob)

g.compute_lineage_drivers(lineages="Alpha", return_drivers=True)

input:*estimator* object with fate probabilities in obs (anndata)
output *estimator* object with added .var  (anndata)

10. plotting utilities

input: anndata
output: pngs

- g.plot_spectrum()
- g.plot_macrostates()
- g.plot_lineage_drivers("Alpha", n_genes=5)
- cr.pl.circular_projection(adata, keys="clusters", legend_loc="right")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions