Skip to content

Commit

Permalink
Public release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff1995 committed Aug 23, 2021
0 parents commit 6281d00
Show file tree
Hide file tree
Showing 198 changed files with 30,874 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#### -- Packrat Autoloader (version 0.5.0) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

options(bitmapType = "cairo")


read_h5ad <- function(filename) {
builtins <- reticulate::import_builtins()
anndata <- reticulate::import("anndata", convert = FALSE)

Mapping <- reticulate::import("typing")$Mapping
DataFrame <- reticulate::import("pandas")$DataFrame
isinstance <- builtins$isinstance

adata <- anndata$read_h5ad(filename)

.convert <- function(obj) {
if (!isinstance(obj, Mapping) || isinstance(obj, DataFrame)) {
return(reticulate::py_to_r(obj))
}
ret <- list()
for (item in builtins$list(obj$keys())) {
ret[[item]] <- .convert(obj[[item]])
}
return(ret)
}

X <- .convert(adata$X$tocsc())
layers <- .convert(adata$layers)
obs <- .convert(adata$obs)
var <- .convert(adata$var)
obsm <- .convert(adata$obsm)
varm <- .convert(adata$varm)
obsp <- .convert(adata$obsp)
varp <- .convert(adata$varp)
uns <- .convert(adata$uns)
rownames(X) <- rownames(obs)
colnames(X) <- rownames(var)

return(list(
X = X, layers = layers,
obs = obs, var = var,
obsm = obsm, varm = varm,
obsp = obsp, varp = varp,
uns = uns
))
}


safe_sd <- function(x) {
if (length(x) == 1)
return(0.0)
return(sd(x))
}


ggplot_theme <- function(...) {
return(ggplot2::theme(
text = ggplot2::element_text(family = "ArialMT"),
plot.background = ggplot2::element_blank(),
panel.grid.major = ggplot2::element_line(color = "#EEEEEE", linetype = "longdash"),
panel.grid.minor = ggplot2::element_blank(),
panel.background = ggplot2::element_rect(fill = "#FFFFFF"),
legend.background = ggplot2::element_blank(),
legend.box.background = ggplot2::element_blank(),
axis.line = ggplot2::element_line(color = "#000000"),
...
))
}


ggplot_save <- function(filename, ...) {
ggplot2::ggsave(filename, ..., dpi = 600, bg = "transparent")
}
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install -y libxml2-utils pandoc
sudo wget -O /usr/bin/bedtools https://github.com/arq5x/bedtools2/releases/download/v2.30.0/bedtools.static.binary
sudo chmod +x /usr/bin/bedtools
pip install --upgrade pip flit
flit install -s
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 scglue --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Test with pytest
run: |
pytest --cov="scglue" --cov-report="xml:cov.xml" tests --cpu-only
COVERAGE=$(xmllint --xpath "/coverage/@line-rate" cov.xml | awk -F\" '{cov = sprintf("%.0f%%", $2 * 100); print(cov);}')
echo "COVERAGE=${COVERAGE}" >> $GITHUB_ENV
- name: Create coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: coverage.json
label: coverage
message: ${{ env.COVERAGE }}
color: green
- name: Build documentation
run: |
sphinx-build -b html docs docs/_build
- name: Get version
run: |
VERSION=$(python -c "from scglue import __version__; print(__version__)")
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Create version badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: version.json
label: version
message: ${{ env.VERSION }}
color: blue
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release

on:
release:
types: [released]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run:
pip install --upgrade pip flit
- name: Build package
run: |
flit build
ls -lh dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: caozj
password: ${{ secrets.PYPI_API_TOKEN }}
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
__pycache__
.coverage*
.ipynb_checkpoints
.snakemake
.snakemake_timestamp
*.annotated_links
*.bak
*.bed*
*.bigWig
*.chain*
*.cprof
*.csv*
*.dill
*.docx
*.egg-info
*.err
*.fa
*.feather
*.gaf*
*.graphml*
*.gtf*
*.h5ad
*.html
*.ipynb
*.jpg
*.json
*.links
*.log
*.loom
*.meme
*.mp4
*.mtx*
*.obo
*.old
*.out
*.owl
*.pdf
*.pkl*
*.png
*.pt
*.pyc
*.tbl
*.tfevents.*
*.tsv*
*@neomake*
*Untitled*
.deprecated
reports
conda
cov.xml
dask-worker-space
objectdb
packrat/lib
packrat/lib*/
packrat/src/
tmp
tools
dist
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
build:
image: latest
sphinx:
configuration: docs/conf.py
python:
version: 3.8
install:
- method: pip
path: .
extra_requirements:
- doc
Loading

0 comments on commit 6281d00

Please sign in to comment.