Skip to content

Commit

Permalink
Merge pull request #172 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
MAGIC v2.0
  • Loading branch information
dburkhardt authored Nov 12, 2019
2 parents 9039a60 + 67d2fff commit 55c9d89
Show file tree
Hide file tree
Showing 24 changed files with 727 additions and 636 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ script:
- cd Rmagic; R CMD build .
- R CMD check *tar.gz
- cd ../python; pip install --user -q .[test]
- if [ "$TRAVIS_PYTHON_VERSION" != "3.5" ]; then black . --check --diff; fi
- python setup.py test
- pip install --user -q .[doc]
- cd doc; make html
- cd ..
- cd doc; make html; cd ..

deploy:
provider: pypi
Expand Down
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Contributing to MAGIC
============================

There are many ways to contribute to `MAGIC`, with the most common ones
being contribution of code or documentation to the project. Improving the
documentation is no less important than improving the library itself. If you
find a typo in the documentation, or have made improvements, do not hesitate to
submit a GitHub pull request.

But there are many other ways to help. In particular answering queries on the
[issue tracker](https://github.com/KrishnaswamyLab/MAGIC/issues),
investigating bugs, and [reviewing other developers' pull
requests](https://github.com/KrishnaswamyLab/MAGIC/pulls)
are very valuable contributions that decrease the burden on the project
maintainers.

Another way to contribute is to report issues you're facing, and give a "thumbs
up" on issues that others reported and that are relevant to you. It also helps
us if you spread the word: reference the project from your blog and articles,
link to it from your website, or simply star it in GitHub to say "I use it".

Code Style and Testing
----------------------

Contributors are encouraged to write tests for their code, but if you do not know how to do so, please do not feel discouraged from contributing code! Others can always help you test your contribution.

Python code style is dictated by [`black`](https://pypi.org/project/black/#installation-and-usage). To automatically reformat your code when you run `git commit`, you can run `./autoblack.sh` in the root directory of this project to add a hook to your `git` repository.

Code of Conduct
---------------

We abide by the principles of openness, respect, and consideration of others
of the Python Software Foundation: https://www.python.org/psf/codeofconduct/.

Attribution
---------------

This `CONTRIBUTING.md` was adapted from [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To see how MAGIC can be applied to single-cell RNA-seq, elucidating the epitheli

[David van Dijk, et al. **Recovering Gene Interactions from Single-Cell Data Using Data Diffusion**. 2018. *Cell*.](https://www.cell.com/cell/abstract/S0092-8674(18)30724-4)

MAGIC has been implemented in Python, Matlab, and R. Note, the current implementation of MAGIC differs compared to the algorithm described in [vanDijk18](https://www.cell.com/cell/abstract/S0092-8674(18)30724-4) in that it uses the adaptive kernel described in Moon et al, 2019 [Moon19](https://www.biorxiv.org/content/10.1101/120378v4).
MAGIC has been implemented in Python, Matlab, and R.

#### To get started immediately, check out our tutorials:
##### Python
Expand Down
2 changes: 1 addition & 1 deletion Rmagic/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rmagic
Type: Package
Title: MAGIC - Markov Affinity-Based Graph Imputation of Cells
Version: 1.5.0
Version: 2.0.0
Authors@R: c(person(given = "David", family = "van Dijk", email = "davidvandijk@gmail.com", role = c("aut")),
person(given = 'Scott', family = 'Gigante', email = 'scott.gigante@yale.edu', role = 'cre',
comment = c(ORCID = '0000-0002-4544-2764')))
Expand Down
1 change: 1 addition & 0 deletions Rmagic/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ S3method(summary,magic)
export(install.magic)
export(library.size.normalize)
export(magic)
export(pymagic_is_available)
import(Matrix)
importFrom(ggplot2,ggplot)
22 changes: 17 additions & 5 deletions Rmagic/R/magic.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#' vector of column names or column indices for which to return smoothed data
#' If 'all_genes' or NULL, the entire smoothed matrix is returned
#' @param knn int, optional, default: 10
#' number of nearest neighbors on which to build kernel
#' @param decay int, optional, default: 15
#' number of nearest neighbors on which to compute bandwidth
#' @param knn.max int, optional, default: NULL
#' maximum number of neighbors for each point. If NULL, defaults to 3*knn
#' @param decay int, optional, default: 2
#' sets decay rate of kernel tails.
#' If NULL, alpha decaying kernel is not used
#' @param t int, optional, default: 'auto'
Expand Down Expand Up @@ -107,7 +109,8 @@ magic.default <- function(
data,
genes = NULL,
knn = 10,
decay = 15,
knn.max = NULL,
decay = 2,
t = 'auto',
npca = 100,
init = NULL,
Expand Down Expand Up @@ -183,6 +186,7 @@ magic.default <- function(
params <- list(
"data" = data,
"knn" = knn,
"knn.max" = knn.max,
"decay" = decay,
"t" = t,
"npca" = npca,
Expand All @@ -197,6 +201,7 @@ magic.default <- function(
operator <- init$operator
operator$set_params(
knn = knn,
knn_max = knn.max,
decay = decay,
t = t,
n_pca = npca,
Expand All @@ -210,6 +215,7 @@ magic.default <- function(
if (is.null(x = operator)) {
operator <- pymagic$MAGIC(
knn = knn,
knn_max = knn.max,
decay = decay,
t = t,
n_pca = npca,
Expand Down Expand Up @@ -244,7 +250,8 @@ magic.seurat <- function(
data,
genes = NULL,
knn = 10,
decay = 15,
knn.max = NULL,
decay = 2,
t = 'auto',
npca = 100,
init = NULL,
Expand All @@ -260,6 +267,7 @@ magic.seurat <- function(
data = as.matrix(x = t(x = data@data)),
genes = genes,
knn = knn,
knn.max = knn.max,
decay = decay,
t = t,
npca = npca,
Expand All @@ -278,6 +286,7 @@ magic.seurat <- function(
data,
genes = genes,
knn = knn,
knn.max = knn.max,
decay = decay,
t = t,
npca = npca,
Expand All @@ -303,7 +312,8 @@ magic.Seurat <- function(
assay = NULL,
genes = NULL,
knn = 10,
decay = 15,
knn.max = NULL,
decay = 2,
t = 'auto',
npca = 100,
init = NULL,
Expand All @@ -322,6 +332,7 @@ magic.Seurat <- function(
data = t(x = Seurat::GetAssayData(object = data, slot = 'data', assay = assay)),
genes = genes,
knn = knn,
knn.max = knn.max,
decay = decay,
t = t,
npca = npca,
Expand All @@ -344,6 +355,7 @@ magic.Seurat <- function(
data,
genes = genes,
knn = knn,
knn.max = knn.max,
decay = decay,
t = t,
npca = npca,
Expand Down
2 changes: 1 addition & 1 deletion Rmagic/README.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title : Rmagic v1.5.0
title : Rmagic
output: github_document
toc: true
---
Expand Down
2 changes: 1 addition & 1 deletion Rmagic/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Rmagic v1.5.0
Rmagic
================

true
Expand Down
2 changes: 1 addition & 1 deletion Rmagic/man/ggplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions Rmagic/man/magic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Rmagic/man/print.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Rmagic/man/pymagic_is_available.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Rmagic/man/summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions autoblack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cat <<EOF >> .git/hooks/pre-commit
#!/bin/sh
set -e
files=\$(git diff --staged --name-only --diff-filter=d -- "*.py")
for file in \$files; do
black -q \$file
git add \$file
done
EOF
chmod +x .git/hooks/pre-commit

Loading

0 comments on commit 55c9d89

Please sign in to comment.