Utils
novae.spatial_neighbors(adata, slide_key=None, radius=None, pixel_size=None, technology=None, coord_type=None, n_neighs=None, delaunay=None, n_rings=1, percentile=None, set_diag=False, reset_slide_ids=True)
Create a Delaunay graph from the spatial coordinates of the cells.
The graph is stored in adata.obsp['spatial_connectivities']
and adata.obsp['spatial_distances']
. The long edges
are removed from the graph according to the radius
argument (if provided).
Info
This function was updated from squidpy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata
|
AnnData | list[AnnData]
|
An |
required |
slide_key
|
str | None
|
Optional key in |
None
|
radius
|
tuple[float, float] | float | None
|
|
None
|
technology
|
str | SpatialTechnology | None
|
Technology or machine used to generate the spatial data. One of |
None
|
coord_type
|
str | CoordType | None
|
Either |
None
|
n_neighs
|
int | None
|
Number of neighbors to consider. If |
None
|
delaunay
|
bool | None
|
Whether to use Delaunay triangulation to build the graph. If |
None
|
n_rings
|
int
|
See |
1
|
percentile
|
float | None
|
See |
None
|
set_diag
|
bool
|
See |
False
|
reset_slide_ids
|
bool
|
Whether to reset the novae slide ids. |
True
|
Source code in novae/utils/build.py
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 |
|
novae.batch_effect_correction(adatas, obs_key)
Source code in novae/utils/correct.py
novae.utils.prepare_adatas(adata, var_names=None)
Ensure the AnnData objects are ready to be used by the model.
Note
It performs the following operations:
- Preprocess the data if needed (e.g. normalize, log1p), in which case raw counts are saved in
adata.layers['counts']
- Compute the mean and std of each gene
- Save which genes are highly variable, in case the number of genes is too high
- If using a pretrained model, save which genes are known by the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata
|
AnnData | list[AnnData] | None
|
An |
required |
var_names
|
set | list[str] | None
|
Only used when loading a pretrained model, or to select a subset of vars to use. |
None
|
Returns:
Type | Description |
---|---|
tuple[list[AnnData], list[str]]
|
A list of |