Skip to content

Commit

Permalink
Merge pull request #152 from BiomedicalMachineLearning/prepare
Browse files Browse the repository at this point in the history
update: config and docs for 0.4.0
  • Loading branch information
duypham2108 committed Feb 3, 2022
2 parents 45a1574 + 782b719 commit 5ebea70
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.1.0
hooks:
- id: black
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
History
=======

0.4.0 (2022-02-03)
------------------
0.3.2 (2021-03-29)
------------------
0.3.1 (2020-12-24)
Expand Down
32 changes: 21 additions & 11 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Spatial: `spatial`
spatial.trajectory.compare_transitions
spatial.trajectory.detect_transition_markers_clades
spatial.trajectory.detect_transition_markers_branches
spatial.trajectory.set_root

.. module:: stlearn.spatial.morphology
.. currentmodule:: stlearn
Expand Down Expand Up @@ -145,13 +146,12 @@ Tools: `tl`
.. autosummary::
:toctree: .

tl.cci.lr
tl.cci.het.count
tl.cci.het.create_grids
tl.cci.het.count_grid
tl.cci.merge
tl.cci.permutation

tl.cci.load_lrs
tl.cci.grid
tl.cci.run
tl.cci.adj_pvals
tl.cci.run_lr_go
tl.cci.run_cci

Plot: `pl`
-------------------
Expand All @@ -162,6 +162,7 @@ Plot: `pl`
.. autosummary::
:toctree: .

pl.QC_plot
pl.gene_plot
pl.gene_plot_interactive
pl.cluster_plot
Expand All @@ -170,11 +171,20 @@ Plot: `pl`
pl.subcluster_plot
pl.non_spatial_plot
pl.deconvolution_plot
pl.QC_plot
pl.het_plot
pl.het_plot_interactive
pl.grid_plot
pl.plot_mask
pl.lr_summary
pl.lr_diagnostics
pl.lr_n_spots
pl.lr_go
pl.lr_result_plot
pl.lr_plot
pl.cci_check
pl.ccinet_plot
pl.lr_chord_plot
pl.lr_cci_map
pl.cci_map
pl.lr_plot_interactive
pl.spatialcci_plot_interactive

.. module:: stlearn.pl.trajectory
.. currentmodule:: stlearn
Expand Down
26 changes: 4 additions & 22 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import os

if not os.path.isdir("./_static"):
url = "https://www.dropbox.com/s/mky2cp1ksjc4bes/downloads.zip"
url = "https://www.dropbox.com/s/6mgg4p978zwyxy9/download.zip?dl=1"
os.system("wget " + url)
os.system("unzip downloads.zip")

Expand Down Expand Up @@ -75,7 +75,7 @@

# General information about the project.
project = "stLearn"
copyright = "2020, Genomics and Machine Learning lab"
copyright = "2022, Genomics and Machine Learning lab"
author = "Genomics and Machine Learning lab"

# The version info for the project you're documenting, acts as replacement
Expand Down Expand Up @@ -199,7 +199,7 @@ def setup(app):
"tutorials/stSME_clustering": "_static/img/thumbnail/sme.png",
"tutorials/stSME_comparison": "_static/img/thumbnail/com.png",
"tutorials/Pseudo-time-space-tutorial": "_static/img/thumbnail/psts.png",
"tutorials/stLearn-CCI": "_static/img/thumbnail/cci_rank.png",
"tutorials/stLearn-CCI": "_static/img/thumbnail/cci.png",
"tutorials/Read_MERFISH": "_static/img/thumbnail/mer.png",
"tutorials/Read_seqfish": "_static/img/thumbnail/seq.png",
"tutorials/Working-with-Old-Spatial-Transcriptomics-data": "_static/img/thumbnail/legacy.png",
Expand All @@ -209,23 +209,5 @@ def setup(app):
"tutorials/Working_with_scanpy": "_static/img/thumbnail/scanpy.png",
"tutorials/Core_plots": "_static/img/thumbnail/core_plots.png",
"tutorials/Read_any_data": "_static/img/thumbnail/any.png",
"tutorials/Integration_multiple_datasets": "_static/img/thumbnail/integrate.png",
}


# import nbclean, glob
# from pathlib import Path

# for filename in glob.glob('../tutorials/*.ipynb', recursive=True):
# Path(filename).rename(filename.split("/")[-1])


# with open("./list_tutorial.txt") as f:
# content = f.readlines()

# content = [x.strip() for x in content]


# for filename in glob.glob('*.ipynb', recursive=True):
# ntbk = nbclean.NotebookCleaner(filename)
# ntbk.clear('stderr')
# ntbk.save(filename)
4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ In the new release, we provide the interactive plots:
Latest additions
----------------

.. include:: release_notes/0.4.0.rst

.. include:: release_notes/0.3.2.rst




.. toctree::
:maxdepth: 1
:hidden:
Expand Down
8 changes: 3 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ Access to:

- https://www.lfd.uci.edu/~gohlke/pythonlibs/#louvain-igraph

Download 2 files: python_igraph‑0.7.1.post6‑cp38‑cp38‑win_amd64.whl and louvain‑0.6.1‑cp38‑cp38‑win_amd64.whl
- https://www.lfd.uci.edu/~gohlke/pythonlibs/#leidenalg

You have to change to downloaded files directory and install it:
::
Download 3 files: igraph‑0.9.9‑cp38‑cp38‑win_amd64.whl, louvain‑0.7.1‑cp38‑cp38‑win_amd64.whl, leidenalg‑0.8.8‑cp38‑cp38‑win_amd64.whl

pip install python_igraph‑0.7.1.post6‑cp38‑cp38‑win_amd64.whl
pip install louvain‑0.6.1‑cp38‑cp38‑win_amd64.whl
You have to change to downloaded files directory and install those packages.

**Step 4:**

Expand Down
8 changes: 8 additions & 0 deletions docs/release_notes/0.4.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0.4.0 `2022-02-03`
~~~~~~~~~~~~~~~~~~~~~~~~~

.. rubric:: Feature

- Upgrade stSME, PSTS and CCI analysis methods.

- Add CCI analysis functions: :func:`~stlearn.tl.cci.load_lrs`, :func:`~stlearn.tl.cci.grid`, :func:`~stlearn.tl.cci.run`, :func:`~stlearn.tl.cci.adj_pvals`, :func:`~stlearn.tl.cci.run_lr_go`, :func:`~stlearn.pl.lr_summary`, :func:`~stlearn.pl.lr_diagnostics`, :func:`~stlearn.pl.lr_n_spots`, :func:`~stlearn.pl.lr_go`, :func:`~stlearn.pl.lr_result_plot`, :func:`~stlearn.pl.lr_plot`, :func:`~stlearn.pl.cci_check`, :func:`~stlearn.pl.ccinet_plot`, :func:`~stlearn.pl.lr_chord_plot`, :func:`~stlearn.pl.lr_cci_map`, :func:`~stlearn.pl.cci_map`, :func:`~stlearn.pl.lr_plot_interactive`, :func:`~stlearn.pl.spatialcci_plot_interactive`
2 changes: 2 additions & 0 deletions docs/release_notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Version 0.3.2
---------------------------

.. include:: 0.3.2.rst

.. include:: 0.4.0.rst
7 changes: 4 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
-r ../requirements.txt
ipyvolume==0.6.0a1
ipywebrtc
ipywidgets>=7.4.0
ipywidgets
jupyter_sphinx==0.1.4
nbclean>=0.3.2
nbformat==4.4.0
nbformat
nbsphinx>=0.7.0
pygments >= 2.4.1
recommonmark
sphinx==3.0.0
sphinx-autodoc-typehints
sphinx_gallery
sphinx_rtd_theme>=0.3.1
typing_extensions; python_version < '3.8'
typing_extensions
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bokeh == 2.3.0
numba==0.53.1
#fa2 == 0.3.5
Pillow==9.0.0
scanpy==1.8.2
scikit-image==0.18.2
tensorflow==2.7.0
numba==0.53.1
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.2
current_version = 0.4.0
commit = True
tag = True

Expand Down
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@
setup(
author="Genomics and Machine Learning lab",
author_email="duy.pham@uq.edu.au",
python_requires=">=3.5",
python_requires=">=3.8",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
description="A downstream analysis toolkit for Spatial Transcriptomic data",
Expand All @@ -50,6 +47,6 @@
test_suite="tests",
tests_require=test_requirements,
url="https://github.com/BiomedicalMachineLearning/stLearn",
version="0.3.2",
version="0.4.0",
zip_safe=False,
)
2 changes: 1 addition & 1 deletion stlearn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Genomics and Machine Learning lab"""
__email__ = "duy.pham@uq.edu.au"
__version__ = "0.3.1"
__version__ = "0.4.0"


from . import add
Expand Down
8 changes: 6 additions & 2 deletions stlearn/plotting/cci_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from bokeh.io import push_notebook, output_notebook
from bokeh.plotting import show

# Functions for visualising the overall LR results and diagnostics.
#### Functions for visualising the overall LR results and diagnostics.


def lr_diagnostics(
Expand Down Expand Up @@ -325,6 +325,7 @@ def lr_go(
show_all=n_top <= max_text,
)


def cci_check(
adata: AnnData,
use_label: str,
Expand Down Expand Up @@ -537,6 +538,7 @@ def lr_result_plot(
vmax,
)


# TODO finish writing the documentation for this parameter.
# @_docs_params(het_plot=doc_lr_plot)
def lr_plot(
Expand Down Expand Up @@ -566,7 +568,7 @@ def lr_plot(
sig_cci: bool = False,
lr_colors: dict = None,
figsize: tuple = (6.4, 4.8),
use_mix: None,
use_mix=None,
# plotting params
**kwargs,
) -> Optional[AnnData]:
Expand Down Expand Up @@ -959,6 +961,7 @@ def het_plot(
# Functions relating to visualising celltype-celltype interactions after
# calling: st.tl.cci_rank.run_cci


def ccinet_plot(
adata: AnnData,
use_label: str,
Expand Down Expand Up @@ -1360,6 +1363,7 @@ def lr_chord_plot(
else:
return fig, ax


def grid_plot(
adata,
use_label: str = None,
Expand Down
2 changes: 1 addition & 1 deletion stlearn/plotting/classes_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def update_data(self, attrname, old, new):
self.layout.children[1] = self.make_fig()

def _get_cci_lr_edges(self):
""" Gets edge list of significant interactions for LR pair. """
"""Gets edge list of significant interactions for LR pair."""

adata = self.adata[0]
lr = self.lr_select.value
Expand Down
4 changes: 2 additions & 2 deletions stlearn/spatials/SME/_weighting_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def calculate_weight_matrix(
adata.obs[["imagecol", "imagerow"]],
metric="euclidean",
)
unit = math.sqrt(reg_row.coef_ ** 2 + reg_col.coef_ ** 2)
unit = math.sqrt(reg_row.coef_**2 + reg_col.coef_**2)
pd_norm = np.where(pd >= unit, 0, 1)

md = 1 - pairwise_distances(
Expand All @@ -75,7 +75,7 @@ def calculate_weight_matrix(

else:
pd = pairwise_distances(adata.obs[["imagecol", "imagerow"]], metric="euclidean")
unit = math.sqrt(reg_row.coef_ ** 2 + reg_col.coef_ ** 2)
unit = math.sqrt(reg_row.coef_**2 + reg_col.coef_**2)
pd_norm = np.where(pd >= rate * unit, 0, 1)

md = 1 - pairwise_distances(adata.obsm["X_morphology"], metric="cosine")
Expand Down
2 changes: 1 addition & 1 deletion stlearn/spatials/SME/impute.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def pseudo_spot(

point_tree = scipy.spatial.cKDTree(coor)
n_neighbour = []
unit = math.sqrt(reg_row.coef_ ** 2 + reg_col.coef_ ** 2)
unit = math.sqrt(reg_row.coef_**2 + reg_col.coef_**2)
for i in range(len(impute_coor)):
current_neighbour = point_tree.query_ball_point(
impute_coor.values[i], round(unit)
Expand Down
2 changes: 1 addition & 1 deletion stlearn/spatials/trajectory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def _mat_mat_corr_sparse(

X_bar = np.reshape(np.array(X.mean(axis=1)), (-1, 1))
X_std = np.reshape(
np.sqrt(np.array(X.power(2).mean(axis=1)) - (X_bar ** 2)), (-1, 1)
np.sqrt(np.array(X.power(2).mean(axis=1)) - (X_bar**2)), (-1, 1)
)

y_bar = np.reshape(np.mean(Y, axis=0), (1, -1))
Expand Down
4 changes: 3 additions & 1 deletion stlearn/tools/microenv/cci/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ def run(
count(adata, distance=distance, use_label=use_label, use_het=use_label)

het_vals = (
np.array([1] * len(adata)) if use_label not in adata.obsm else adata.obsm[use_label]
np.array([1] * len(adata))
if use_label not in adata.obsm
else adata.obsm[use_label]
)

""" 1. Filter any LRs without stored expression.
Expand Down
2 changes: 1 addition & 1 deletion stlearn/tools/microenv/cci/het_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_data_for_counting(adata, use_label, mix_mode, all_set):


def get_neighbourhoods(adata):
""" Gets the neighbourhood information. """
"""Gets the neighbourhood information."""

# Old stlearn version where didn't store neighbourhood barcodes, not good
# for anndata subsetting!!
Expand Down
4 changes: 2 additions & 2 deletions stlearn/tools/microenv/cci/perm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def nonzero_quantile(expr, q, interpolation):
""" Calculating the non-zero quantiles. """
"""Calculating the non-zero quantiles."""
nonzero_expr = expr[expr > 0]
quants = np.quantile(nonzero_expr, q=q, interpolation=interpolation)
if type(quants) != np.array and type(quants) != np.ndarray:
Expand All @@ -19,7 +19,7 @@ def nonzero_quantile(expr, q, interpolation):


def getzero_prop(expr):
""" Calculating the proportion of zeros. """
"""Calculating the proportion of zeros."""
zero_bool = expr == 0
n_zeros = len(np.where(zero_bool)[0])
zero_prop = [n_zeros / len(expr)]
Expand Down
2 changes: 1 addition & 1 deletion stlearn/tools/microenv/cci/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def get_stats(
mu = np.exp(res.params[0])
alpha = res.params[1]
Q = 0
size = 1.0 / alpha * mu ** Q
size = 1.0 / alpha * mu**Q
prob = size / (size + mu)

if return_negbinom_params: # For testing purposes #
Expand Down

0 comments on commit 5ebea70

Please sign in to comment.