scsplice.tl¶
Tools that operate on a populated splicing AnnData. Both functions require layers["M1"] to be present; pseudo_correlation additionally requires valid M2 (uns["scsplice"]["m2_valid"] == True).
tl
¶
scsplice.tl — tools that operate on a populated splicing AnnData.
make_m2
¶
Build the exclusion matrix M2 and store it in adata.layers['M2'].
For every event i (var) and cell j (obs):
M2[j, i] = sum(M1[j, k] for k in same LJV group as i) - M1[j, i]
Entries that are exactly zero are dropped (no epsilon threshold). M2 has the
same shape, sparse format (CSC), and dtype (float64) as M1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Splicing AnnData built by :func: |
required |
n_threads
|
int
|
OpenMP thread count for the kernel. |
1
|
copy
|
bool
|
Mutate |
False
|
Returns:
| Type | Description |
|---|---|
``None`` when ``copy=False``; the new AnnData when ``copy=True``.
|
|
Notes
Sets adata.uns['scsplice']['m2_valid'] = True and records the call params
under adata.uns['scsplice']['params']['make_m2'].
The kernel reads layers['M1'], transposes to events × cells at the C++
boundary (the kernel works in that layout), and transposes the result back
to AnnData layout (cells × events) before storing in layers['M2'].
Source code in src/scsplice/tl/_make_m2.py
pseudo_correlation
¶
pseudo_correlation(adata: AnnData, zdb: ndarray, *, metric: Literal['CoxSnell', 'Nagelkerke'] = 'CoxSnell', n_permutations: int = 0, seed: int | None = None, n_threads: int = 1, key_added: str = 'pseudo_correlation', inplace: bool = True) -> AnnData | None
Compute per-event signed pseudo-correlation against zdb.
For each event, fit a binomial GLM (logistic link) via IRLS with design
matrix [intercept | zdb[event, valid_cells]] against the M1/(M1+M2)
response, where valid_cells are cells with M1+M2 > 0. Return
sqrt(R^2) * sign(slope) where R^2 is Cox-Snell or Nagelkerke
pseudo-R^2. Events with fewer than two valid cells, all-zero M1 or M2,
singular Hessian, or negative R^2 receive NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Splicing AnnData with valid M1 / M2 layers ( |
required |
zdb
|
ndarray
|
Dense |
required |
metric
|
Literal['CoxSnell', 'Nagelkerke']
|
|
'CoxSnell'
|
n_permutations
|
int
|
If > 0, also compute |
0
|
seed
|
int | None
|
Seed for the column permutation RNG ( |
None
|
n_threads
|
int
|
OpenMP thread count for the per-event outer loop. Per-event results are bit-identical regardless of n_threads (disjoint scalar writes). |
1
|
key_added
|
str
|
Output column name in |
'pseudo_correlation'
|
inplace
|
bool
|
Mutate |
True
|
Returns:
| Type | Description |
|---|---|
``None`` when ``inplace=True``; otherwise the modified copy.
|
|
Source code in src/scsplice/tl/_pseudo_correlation.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |