Skip to content

Commit

Permalink
Updated docs for gene_graph and adjacency_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cboix committed Jul 22, 2024
1 parent 8ac14f6 commit 142667c
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 64 deletions.
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
# html_theme = "scanpydoc"
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
html_theme_options = {
"repository_url": repository_url,
"use_repository_button": True,
}
# html_theme_options = { # Meeds sphinx-book-theme or scanpydoc
# "repository_url": repository_url,
# "use_repository_button": True,
# }
html_show_sphinx = False
# html_logo = "_static/img/Scanpy_Logo_BrightFG.svg"
html_title = "scdemon"
Expand Down
3 changes: 0 additions & 3 deletions notebooks/example.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env python3
"""Example code for using scdemon part of the library."""
# ---------------------------------------------------------------------
# Example - compute co-expression modules using a scanpy anndata object
# Updated: 04/08/24
# ---------------------------------------------------------------------
import os
import logging
import numpy as np
Expand Down
9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ dependencies = [
# Added from original modules, can prune:
"scanpy", "anndata",
"seaborn", "matplotlib",
"gprofiler-official",
"igraph", "adjustText",
"numba"
"igraph", "numba"
]

[project.urls]
Expand All @@ -35,7 +33,7 @@ Source = "https://github.com/kellislab/scdemon"
Home-page = "https://github.com/kellislab/scdemon"

[project.optional-dependencies]
test = ["pytest", "pytest-cov", "statsmodels", "anndata"]
test = ["adjustText", "gprofiler-official"]

[tool.scikit-build]
wheel.expand-macos-universal-tags = true
Expand All @@ -45,9 +43,6 @@ packages = ["scdemon",
"scdemon.utils", "scdemon.plotting",
"scdemon.graph", "scdemon.data"]

[tool.pytest.ini_options]
python_files = "test_*.py"

[tool.coverage.run]
branch = true

48 changes: 42 additions & 6 deletions scdemon/graph/adjacency_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@


class adjacency_matrix(object):
"""\
Process given correlation matrix into the adjacency matrix.
"""
Turn a correlation matrix into an adjacency matrix.
Process given correlation matrix into the adjacency matrix.
"""

def __init__(
self,
corr,
Expand All @@ -40,7 +37,46 @@ def __init__(
scale=None,
degree_cutoff=0
):
"""Initialize adjacency matrix class."""
"""\
Initialize adjacency matrix class.
Parameters
----------
corr : np.array | sparse.csr_matrix
Gene-gene correlation matrix
adjacency : np.array
Adjacency matrix
method : str
Thresholding method for graph:
``'bivariate'``
default, threshold based on bivariate spline fit to gene-gene sparsity
``'cutoff'``
single cutoff across full matrix
``'sd'``
based on estimated sd, expensive
corr_sd : np.array
Estimated standard deviation of correlations. Only used for ``sd`` method
labels : np.array
Labels for nodes (genes)
margin : np.array
Fraction non-zero values for each of the variables in the original dataset (gene sparsity)
cutoff : float
Raw correlation threshold
z : float
Z-score threshold
zero_outliers : bool
Whether to set outliers to 0 when calculating splines
keep_all_z : bool
Whether to keep z-score matrix dense by removing all values below threshold
knn_k : int
Pruning: keep only the top k edges per node
scale : float
Pruning: remove edges below a certain fraction (in (0.0, 1.0]) of the top edge for the node
degree_cutoff : int
Pruning: remove graph nodes with degree below this cutoff
"""
self.corr = corr
self.adjacency = adjacency
self.method = method
Expand Down
Loading

0 comments on commit 142667c

Please sign in to comment.