API
The sc_simvar package.
SCSimVar ¶
SCSimVar(
ann_data: AnnData,
layer_key: str | None = None,
model: Literal[
"normal", "danb", "bernoulli", "none"
] = "danb",
*,
latent_obsm_key: str | None = None,
distances_obsp_key: str | None = None,
tree: TreeNode | None = None,
umi_counts_obs_key: str | None = None,
)
The SCSimVar class.
Initialize the SimVar class.
One of obsm_latent_key
, obsp_distances_key
or tree
must be
provided.
All matrices will be converted to float64
for computation. Ensure
this does not cause a loss of data/precision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ann_data
|
AnnData
|
The annotated data matrix, shape is cells x genes. |
required |
layer_key
|
str
|
The layer to use for the counts data/matrix, uses |
None
|
model
|
Literal['normal', 'danb', 'bernoulli', 'none']
|
The model to use, by default |
'danb'
|
latent_obsm_key
|
str
|
The key in the |
None
|
distances_obsp_key
|
str
|
The key in the |
None
|
tree
|
TreeNode
|
Root |
None
|
umi_counts_obs_key
|
str
|
The key in the |
None
|
Source code in src/sc_simvar/_sc_simvar.py
linkage
property
¶
The linkage.
Returns:
Type | Description |
---|---|
NDArray[uint64] | None
|
The linkage. |
local_correlation_c
property
¶
The local correlation C.
Returns:
Type | Description |
---|---|
NDArray[float64] | None
|
The local correlation C. |
local_correlation_z
property
¶
The local correlation Z.
Returns:
Type | Description |
---|---|
NDArray[float64] | None
|
The local correlation Z. |
module_scores
property
¶
The module scores.
Returns:
Type | Description |
---|---|
DataFrame | None
|
The module scores. |
modules
property
¶
The modules.
Returns:
Type | Description |
---|---|
Optional[Series[int]]
|
The modules. |
neighbors
property
¶
The indices of the neighbors.
Returns:
Type | Description |
---|---|
DataFrame | None
|
The indices of the neighbors. |
results
property
¶
The results.
Returns:
Type | Description |
---|---|
DataFrame | None
|
The results. |
weights
property
¶
The weights of the neighbors.
Returns:
Type | Description |
---|---|
DataFrame | None
|
The weights of the neighbors. |
calculate_module_scores ¶
Calculate module scores.
Returns:
Name | Type | Description |
---|---|---|
module_scores |
DataFrame
|
A |
Source code in src/sc_simvar/_sc_simvar.py
compute_auto_and_local_correlations ¶
compute_auto_and_local_correlations(
genes: list[str] | NDArray[str_] | None = None,
) -> tuple[DataFrame, DataFrame]
Compute the auto and local correlations.
Avoids returning to the Python layer between the two computations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
genes
|
list[str] | None
|
The genes to compute the local correlations for, if |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
A |
DataFrame
|
A |
Source code in src/sc_simvar/_sc_simvar.py
compute_autocorrelations ¶
Compute the auto correlations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jobs
|
int
|
Not used. |
1
|
Returns:
Type | Description |
---|---|
DataFrame
|
A |
Source code in src/sc_simvar/_sc_simvar.py
compute_local_correlations ¶
compute_local_correlations(
genes: list[str] | NDArray[str_] | None = None,
jobs: int = 1,
) -> DataFrame
Compute the local correlations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
genes
|
list[str] | None
|
The genes to compute the local correlations for, if |
None
|
jobs
|
int
|
Not used. |
1
|
Returns:
Type | Description |
---|---|
DataFrame
|
A |
Source code in src/sc_simvar/_sc_simvar.py
create_knn_graph ¶
create_knn_graph(
weighted_graph: bool = False,
n_neighbors: int = 30,
neighborhood_factor: int = 3,
approx_neighbors: bool = True,
) -> None
Create a k-nearest neighbor graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weighted_graph
|
bool
|
Whether to create a weighted graph, by default |
False
|
n_neighbors
|
int
|
The number of nearest neighbors to use, by default |
30
|
neighborhood_factor
|
int
|
The number of neighbors to approximate the full graph with,
by default |
3
|
approx_neighbors
|
bool
|
Whether to approximate the neighbors, by default |
True
|
Source code in src/sc_simvar/_sc_simvar.py
create_modules ¶
create_modules(
min_gene_threshold: int = 20,
core_only: bool = True,
fdr_threshold: float = 0.05,
) -> Series
Group genes into modules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_gene_threshold
|
int
|
The minimum number of genes in a module, decrease if too many
modules are formed, decrease if sub-structure is not being
captured. Defaults to |
20
|
core_only
|
bool
|
If |
True
|
fdr_threshold
|
float
|
The FDR threshold to use for module assignment, defaults to |
0.05
|
Returns:
Type | Description |
---|---|
Series
|
A |
Source code in src/sc_simvar/_sc_simvar.py
plot_local_correlation ¶
plot_local_correlation(
mod_cmap: str | Colormap = "tab10",
vmin: int = -8,
vmax: int = 8,
z_cmap: str | Colormap = "RdBu_r",
yticklabels: bool = False,
) -> None
Plot a cluster-grid of the local correlation values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mod_cmap
|
str | Colormap
|
Valid |
'tab10'
|
vmin
|
int
|
Min value for Z-scores color scale. Default is |
-8
|
vmax
|
int
|
Max value for Z-scores color scale. Default is |
8
|
z_cmap
|
str | Colormap
|
Valid |
'RdBu_r'
|
yticklabels
|
bool
|
If |
False
|