Skip to content

Commit

Permalink
migrate repo
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmueboe committed Jun 19, 2024
0 parents commit 38db838
Show file tree
Hide file tree
Showing 33 changed files with 3,906 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: no-commit-to-branch
args: [--branch=main]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies:
- "numpy"
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/google/yamlfmt
rev: v0.12.1
hooks:
- id: yamlfmt
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
sphinx:
configuration: docs/source/conf.py
python:
install:
- method: pip
path: .
extra_requirements:
- docs
22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "_utils_rust"
version = "0.1.0"
edition = "2021"

[lib]
name = "_utils_rust"
crate-type = ["cdylib"]

[dependencies]
bincode = { version = "1.3" }
indexmap = { version = "2.1.0", features = ["rayon"] }
itertools = { version = "0.12.1" }
ndarray = { version = "0.15.6", features = ["rayon"] }
ndarray-stats = { version = "0.5.1" }
num = { version = "0.4.1" }
numpy = { version = "0.21.0" }
polars = { version = "0.39", features = ["partition_by", "dtype-categorical"] }
pyo3 = { version = "0.21.0", features = ["extension-module"] }
pyo3-polars = { version = "0.13.0" }
rayon = { version = "1.8.0" }
sprs = { version = "0.11.1", features = ["serde"] }
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Niklas Müller-Bötticher, Naveed Ishaque, Roland Eils, Berlin Institute of Health @ Charité

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# sainsc

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

/ˈsaiəns/

_"**S**egmentation-free **A**nalysis of **In S**itu **C**apture data"_
or alternatively
"_**S**tupid **A**cronyms **In Sc**ience_"

`sainsc` is a segmentation-free analysis tool for spatial transcriptomics from in situ
capture technologies (but also works for imaging-based technologies). It is easily
integratable with the [scverse](https://github.com/scverse) (i.e. `scanpy` and `squidpy`)
by exporting data in [`AnnData`](https://anndata.readthedocs.io/) or
[`SpatialData`](https://spatialdata.scverse.org/) format.

## Installation

`sainsc` will be made available on [PyPI](https://pypi.org/) and
[bioconda](https://bioconda.github.io/). For detailed installation instructions
please refer to the [documentation](https://sainsc.readthedocs.io/en/stable/installation.html).

## Documentation

For an extensive documentation of the package please refer to the
[ReadTheDocs page](https://sainsc.readthedocs.io)

## Versioning

This project follows the [SemVer](https://semver.org/) guidelines for versioning.

## Citations

## License

This project is licensed under the MIT License - for details please refer to the
[LICENSE](./LICENSE) file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
117 changes: 117 additions & 0 deletions docs/source/_templates/python/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{% if obj.display %}
{% if is_own_page %}
{{ obj.id }}
{{ "=" * obj.id | length }}

{% endif %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% set own_page_children = visible_children|selectattr("type", "in", own_page_types)|list %}
{% if is_own_page and own_page_children %}
.. toctree::
:hidden:

{% for child in own_page_children %}
{{ child.include_path }}
{% endfor %}

{% endif %}
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}{% if obj.args %}({{ obj.args }}){% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}

{% endfor %}
{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}

Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}


{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}
{% if obj.docstring %}

{{ obj.docstring|indent(3) }}
{% endif %}
{% for obj_item in visible_children %}
{% if obj_item.type not in own_page_types %}

{{ obj_item.render()|indent(3) }}
{% endif %}
{% endfor %}
{% if is_own_page and own_page_children %}
{% set visible_attributes = own_page_children|selectattr("type", "equalto", "attribute")|list %}
{% if visible_attributes %}
Attributes
----------

.. autoapisummary::

{% for attribute in visible_attributes %}
{{ attribute.id }}
{% endfor %}


{% endif %}
{% set visible_properties = own_page_children|selectattr("type", "equalto", "property")|list %}
{% if visible_properties %}
Properties
----------

.. autoapisummary::

{% for property in visible_properties %}
{{ property.id }}
{% endfor %}


{% endif %}
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
{% if visible_exceptions %}
Exceptions
----------

.. autoapisummary::

{% for exception in visible_exceptions %}
{{ exception.id }}
{% endfor %}


{% endif %}
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
{% if visible_classes %}
Classes
-------

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
{% if visible_methods %}
Methods
-------

.. autoapisummary::

{% for method in visible_methods %}
{{ method.id }}
{% endfor %}


{% endif %}
{% endif %}
{% endif %}
90 changes: 90 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import importlib.metadata
import os
import sys
from datetime import datetime

sys.path.insert(0, os.path.abspath("../.."))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "sainsc"
copyright = f"""
{datetime.now():%Y}, Niklas Müller-Bötticher, Naveed Ishaque, Roland Eils,
Berlin Institute of Health @ Charité"""
author = "Niklas Müller-Bötticher"
version = importlib.metadata.version("sainsc")
release = version

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration


extensions = [
"sphinx_copybutton",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"autoapi.extension",
"sphinx.ext.mathjax",
]


autodoc_typehints = "none"
autodoc_typehints_format = "short"

autoapi_dirs = ["../../sainsc"]
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"imported-members",
]
autoapi_python_class_content = "both"
autoapi_own_page_level = "attribute"
autoapi_template_dir = "_templates"
autoapi_member_order = "groupwise"

python_use_unqualified_type_names = True # still experimental

autosummary_generate = True
autosummary_imported_members = True

nitpicky = True
nitpick_ignore = [
("py:class", "numpy.typing.DTypeLike"),
("py:class", "numpy.typing.NDArray"),
("py:mod", "polars"),
("py:class", "polars.DataFrame"),
("py:class", "optional"),
]

exclude_patterns: list[str] = ["_templates"]

intersphinx_mapping = dict(
anndata=("https://anndata.readthedocs.io/en/stable/", None),
matplotlib=("https://matplotlib.org/stable/", None),
numpy=("https://numpy.org/doc/stable/", None),
pandas=("https://pandas.pydata.org/pandas-docs/stable/", None),
polars=("https://docs.pola.rs/py-polars/html/", None),
python=("https://docs.python.org/3", None),
scipy=("https://docs.scipy.org/doc/scipy/", None),
seaborn=("https://seaborn.pydata.org/", None),
spatialdata=("https://spatialdata.scverse.org/en/stable/", None),
)

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path: list[str] = []


def skip_submodules(app, what, name, obj, skip, options):
if what == "module":
skip = True
return skip


def setup(sphinx):
sphinx.connect("autoapi-skip-member", skip_submodules)
Loading

0 comments on commit 38db838

Please sign in to comment.