@@ -4,21 +4,21 @@ Tutorial
44Step 1: Clonal nearest neighbours graph construction
55****************************************************
66
7- Firstly, we have to identify *k * nearest clonally labelled cells for each cell. It will create "bag of clones"
8- (similar to "bag of words") that will be used for *clone2vec * training further.
7+ Firstly, we will create AnnData-object with clones.
98
109.. code-block :: python
1110
1211 import scanpy as sc
1312 import sclitr as sl
1413
15- sl.tl.clonal_nn (
14+ clones = sl.pp.clones_adata (
1615 adata,
17- obs_name = " clone" , # Column with clonal labels
18- use_rep = " X_pca " , # Which dimred to use for graph construction
19- min_size = 5 , # Minimal clone size
16+ obs_name = " clone" , # Column with clonal labels
17+ min_size = 2 , # Minimal clone size
18+ na_value = " NA " , # Value for non-labelled cells
2019 )
2120
21+
2222 Minimal clone size parameter is used to exclude small clones from embedding construction.
2323
2424Step 2: clone2vec
@@ -29,24 +29,14 @@ clonally labelled cell.
2929
3030.. code-block :: python
3131
32- clones = sl.pp.clones_adata (
32+ sl.tl.clonal_nn (
3333 adata,
34- obs_name = " clone" ,
35- min_size = 5 ,
36- fill_obs = " cell_type" , # Optional: composition column to fill clones layers
34+ clones,
35+ use_rep = " X_pca" , # Which dimred to use for graph construction
3736 )
3837
39- # build clone graph in clones.obsp["gex_adjacency"] using cell-level embedding
40- # e.g., cosine similarity between clone centroids in `adata.obsm["X_pca"]` and kNN
41- # (see your pipeline; not shown here for brevity)
38+ sl.tl.clone2vec(clones)
4239
43- sl.tl.clone2vec(
44- clones,
45- z_dim = 10 ,
46- obsp_key = " gex_adjacency" , # graph between clones
47- obsm_key = " clone2vec" ,
48- uns_key = " clone2vec" ,
49- )
5040
5141 After execution of this function we have AnnData-object :code: `clones ` with clonal vector representation
5242stored in :code: `clones.obsm["clone2vec"] `. Now we can work with it like with regular scRNA-Seq dataset.
@@ -62,29 +52,4 @@ Step 3: clone2vec analysis
6252
6353 And after perform all other additional steps of analysis.
6454
65- Step 4: Identify predictors of clonal behaviour
66- ***********************************************
67-
68- In the simplest case, the model can be built to identify gene expression predictors of (a) position on a
69- clonal embedding and (b) cell type composition of clones based on the expression in progenitor cells (if they exist).
70- More broadly, we don't have to limit the prediction by the progenitor cells, and in this case the algorithm will
71- identify general gene expression predictors of the distribution of the clone on an embedding.
72-
73- .. code-block :: python
74-
75- shapdata_c2v = sl.tl.catboost(
76- adata,
77- obsm_key = " X_umap" , # predict clone position; replace with your embedding
78- gs_key = " gs" , # optional: use gs split info if available
79- model = " regressor" ,
80- num_trees = 1000 ,
81- )
82-
83- shapdata_ct = sl.tl.associations(
84- adata,
85- response_key = " proportions" , # or a specific layer/metric
86- response_field = " obsm" , # depends on how you store targets
87- method = " gam" , # pearson/spearman/gam
88- )
89-
9055For a more detailed walkthrough see the Examples section.
0 commit comments