Skip to content

Commit

Permalink
Initial commit recall (compared to callback, adds various null distri…
Browse files Browse the repository at this point in the history
…butions, renames method
  • Loading branch information
agdenadel committed Sep 25, 2024
0 parents commit a939439
Show file tree
Hide file tree
Showing 31 changed files with 1,772 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
^LICENSE\.md$
^Dockerfile$
^tmp$
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/check-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
18 changes: 18 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag recall:$(date +%s)
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
29 changes: 29 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
name: Lint Code Base

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: "main"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData
.RDataTmp

# User-specific files
.Ruserdata

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# R Environment Variables
.Renviron

# pkgdown site
docs/

# translation temp files
po/*~

# RStudio Connect folder
rsconnect/
.Rproj.user
.Rdata
.DS_Store
docs
inst/doc
36 changes: 36 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Package: recall
Title: Calibrated clustering with artificial variables to avoid over-clustering in single-cell RNA-sequencing
Version: 0.0.0
Authors@R:
person("Alan", "DenAdel", , "alan_denadel@brown.edu", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7985-6789"))
Description: recall (Calibrated Clustering with Artificial Variables) is a method for protecting
against over-clustering by controlling for the impact of double-dipping. The approach
can be applied to any clustering algorithm (implemented are the Louvain and Leiden algorithms with
plans forK-means, and hierarchical clustering algorithms). The method provides state-of-the-art
clustering performance and can rapidly analyze large-scale scRNA-seq studies and is
compatible with the Seurat library.
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Imports:
Matrix,
Seurat (>= 5.0.1),
SingleCellExperiment,
scDesign3,
SummarizedExperiment,
MASS,
fitdistrplus,
lamW,
knockoff,
future,
stats,
cli,
stringr,
countsplit
License: MIT + file LICENSE
Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
URL: https://lcrawlab.github.io/recall/
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM rocker/verse:4.0.5

RUN R -e "install.packages('.', type = 'source', repos = NULL)"
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: recall authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 recall authors

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.
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(FindClustersCallback)
export(FindClustersCountsplit)
export(seurat_workflow)
92 changes: 92 additions & 0 deletions R/copula.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
simulate_data_scDesign3 <- function(data_matrix, cores, family) {
sce <- SingleCellExperiment::SingleCellExperiment(list(counts = data_matrix))
SummarizedExperiment::colData(sce)$cell_type <- "1" # scDesign3 needs a cell type so we just make it the same for all cells

simulated_data <- scDesign3::scdesign3(sce,
celltype = "cell_type",
pseudotime = NULL,
spatial = NULL,
other_covariates = NULL,
empirical_quantile = FALSE,
usebam=TRUE, # to speedup marginal inference
mu_formula = "1",
sigma_formula = "1",
corr_formula = "1",
family_use = family, # this is the key parameter
nonzerovar = FALSE,
n_cores = cores,
parallelization = "mcmapply",
important_feature = "all",
nonnegative = FALSE,
copula = "gaussian",
fastmvn = TRUE)

ko <- simulated_data$new_count

return(ko)
}


#' @title todo
#'
#' @description Given data, computes todo
#'
#' @param data_matrix The data to estimate parameters from.
#' @param cores The number of CPU cores to use in estimation by scDesign3.
#' @returns todo
#' @name estimate_negative_binomial_copula
estimate_zi_poisson_copula <- function(data_matrix, cores) {
family <- "zip"
ko <- simulate_data_scDesign3(data_matrix, cores, family)
return(ko)
}


#' @title todo
#'
#' @description Given data, computes todo
#'
#' @param data_matrix The data to estimate parameters from.
#' @param cores The number of CPU cores to use in estimation by scDesign3.
#' @returns todo
#' @name estimate_negative_binomial_copula
estimate_negative_binomial_copula <- function(data_matrix, cores) {
family <- "nb"
ko <- simulate_data_scDesign3(data_matrix, cores, family)
return(ko)
}


#' @title todo
#'
#' @description Given data, computes todo
#'
#' @param data_matrix The data to estimate parameters from.
#' @param cores The number of CPU cores to use in estimation by scDesign3.
#' @returns todo
#' @name estimate_negative_binomial_copula
estimate_poisson_copula <- function(data_matrix, cores) {
family <- "poisson"
ko <- simulate_data_scDesign3(data_matrix, cores, family)
return(ko)
}




#' @title todo
#'
#' @description Given data, computes todo
#'
#' @param data_matrix The data to estimate parameters from.
#' @param cores The number of CPU cores to use in estimation by scDesign3.
#' @returns todo
#' @name estimate_negative_binomial_copula
estimate_gaussian_copula <- function(data_matrix, cores) {
family <- "gaussian"
ko <- simulate_data_scDesign3(data_matrix, cores, family)
return(ko)
}



Empty file added R/countsplit.R
Empty file.
Loading

0 comments on commit a939439

Please sign in to comment.