Skip to content

Commit

Permalink
pull
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:stemangiola/sccomp

# Conflicts:
#	DESCRIPTION
  • Loading branch information
stemangiola committed Oct 12, 2024
2 parents fe49259 + b680e8a commit e664088
Show file tree
Hide file tree
Showing 89 changed files with 5,200 additions and 3,272 deletions.
16 changes: 15 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
^\.github$
^LICENSE\.md$
^README\.md$
^README\.rmd$
^\.gitignore$
^sccomp\.Rproj$
^README_files$
^\.Rproj\.user$
^\.github
^NOTICE$
^\.Rhistory$
^\.Rbuildignore$
^\.RData$
^dev$
sccomp_draws_files*
src/stanExport*
src/Rcpp*
^\.git
^README*
^dev
Expand All @@ -13,3 +26,4 @@ model_glm_dirichlet_multinomial_imputation.rds
^doc$
^Meta$
sccomp_draws_files

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
.Rhistory
.RData
.Ruserdata
README_cache/*
vignettes/introduction_cache*
.Rapp.history
inst/doc
sccomp.Rproj
Meta
doc
Expand Down
66 changes: 24 additions & 42 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
)
Description: A robust and outlier-aware method for testing differential tissue composition from single-cell data. This model can infer changes in tissue composition and heterogeneity, and can produce realistic data simulations based on any existing dataset. This model can also transfer knowledge from a large set of integrated datasets to increase accuracy further.
License: GPL-3
URL: https://github.com/MangiolaLaboratory/sccomp
BugReports: https://github.com/MangiolaLaboratory/sccomp/issues
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Biarch: true
Depends:
R (>= 4.2.0)
Imports:
methods,
Rcpp (>= 0.12.0),
RcppParallel (>= 5.0.1),
rstantools (>= 2.1.1),
rstan (>= 2.26.0),
RoxygenNote: 7.3.2
Depends: R (>= 4.2.0)
Imports:
instantiate (>= 0.2.3),
callr,
fs,
stats,
SeuratObject,
SingleCellExperiment,
parallel,
Expand All @@ -40,44 +38,28 @@ Imports:
readr,
scales,
stringr,
glue
glue,
withr,
digest
Suggests:
cmdstanr (>= 0.6.0),
knitr,
rmarkdown,
BiocStyle,
testthat (>= 3.0.0),
markdown,
knitr,
loo,
prettydoc,
tidyseurat,
tidySingleCellExperiment,
prettydoc
Enhances:
furrr,
extraDistr
LinkingTo:
BH (>= 1.66.0),
Rcpp (>= 0.12.0),
RcppEigen (>= 0.3.3.3.0),
RcppParallel (>= 5.0.1),
rstan (>= 2.26.0),
StanHeaders (>= 2.26.0)
SystemRequirements: GNU make
VignetteBuilder:
knitr
RdMacros:
lifecycle
biocViews:
ImmunoOncology,
Normalization,
Sequencing,
RNASeq,
Software,
GeneExpression,
Transcriptomics,
SingleCell,
Clustering
LazyDataCompression: xz
Config/testthat/edition: 3
URL: https://github.com/stemangiola/sccomp
BugReports: https://github.com/stemangiola/sccomp/issues
bayesplot,
posterior
Remotes:
wlandau/instantiate
Additional_repositories:
https://mc-stan.org/r-packages/
SystemRequirements: CmdStan (https://mc-stan.org/users/interfaces/cmdstan)
biocViews: Bayesian, Regression, DifferentialExpression, SingleCell
LazyData: true
VignetteBuilder: knitr
43 changes: 23 additions & 20 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,sccomp_tbl)
S3method(sccomp_calculate_residuals,sccomp_tbl)
S3method(sccomp_estimate,DFrame)
S3method(sccomp_estimate,Seurat)
S3method(sccomp_estimate,SingleCellExperiment)
Expand All @@ -10,47 +11,48 @@ S3method(sccomp_glm,Seurat)
S3method(sccomp_glm,SingleCellExperiment)
S3method(sccomp_glm,data.frame)
S3method(sccomp_predict,sccomp_tbl)
S3method(sccomp_proportional_fold_change,sccomp_tbl)
S3method(sccomp_remove_outliers,sccomp_tbl)
S3method(sccomp_remove_unwanted_variation,sccomp_tbl)
S3method(sccomp_replicate,sccomp_tbl)
S3method(sccomp_test,sccomp_tbl)
S3method(simulate_data,tbl)
export(get_output_samples)
export(plot_1D_intervals)
export(plot_2D_intervals)
export(plot_summary)
export(sccomp_boxplot)
export(sccomp_calculate_residuals)
export(sccomp_estimate)
export(sccomp_glm)
export(sccomp_predict)
export(sccomp_proportional_fold_change)
export(sccomp_remove_outliers)
export(sccomp_remove_unwanted_variation)
export(sccomp_replicate)
export(sccomp_test)
export(simulate_data)
export(test_contrasts)
import(Rcpp)
import(SeuratObject)
import(dplyr)
import(ggplot2)
import(lifecycle)
import(methods)
import(rstantools)
importFrom(RcppParallel,CxxFlags)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(SingleCellExperiment,colData)
importFrom(SingleCellExperiment,counts)
importFrom(boot,logit)
importFrom(dplyr,"%>%")
importFrom(dplyr,any_of)
importFrom(dplyr,arrange)
importFrom(dplyr,as_tibble)
importFrom(dplyr,cummean)
importFrom(dplyr,distinct)
importFrom(dplyr,distinct_at)
importFrom(dplyr,enquo)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,if_else)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_all)
importFrom(dplyr,mutate_if)
importFrom(dplyr,pull)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(dplyr,with_groups)
importFrom(forcats,fct_relevel)
importFrom(forcats,fct_reorder)
Expand All @@ -64,6 +66,11 @@ importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggrepel,geom_text_repel)
importFrom(glue,glue)
importFrom(instantiate,stan_cmdstan_exists)
importFrom(instantiate,stan_package_compile)
importFrom(instantiate,stan_package_model)
importFrom(lifecycle,deprecate_warn)
importFrom(lifecycle,is_present)
importFrom(magrittr,"%$%")
importFrom(magrittr,divide_by)
importFrom(magrittr,equals)
Expand All @@ -87,6 +94,8 @@ importFrom(purrr,pmap)
importFrom(purrr,reduce)
importFrom(purrr,when)
importFrom(readr,read_file)
importFrom(readr,type_convert)
importFrom(readr,write_file)
importFrom(rlang,":=")
importFrom(rlang,enquo)
importFrom(rlang,ensym)
Expand All @@ -96,13 +105,6 @@ importFrom(rlang,quo_is_symbolic)
importFrom(rlang,quo_name)
importFrom(rlang,quo_squash)
importFrom(rlang,set_names)
importFrom(rstan,Rhat)
importFrom(rstan,extract)
importFrom(rstan,sampling)
importFrom(rstan,sflist2stanfit)
importFrom(rstan,stan_model)
importFrom(rstan,summary)
importFrom(rstan,vb)
importFrom(scales,trans_new)
importFrom(stats,C)
importFrom(stats,as.formula)
Expand All @@ -120,7 +122,6 @@ importFrom(tibble,add_column)
importFrom(tibble,as_tibble)
importFrom(tibble,deframe)
importFrom(tibble,enframe)
importFrom(tibble,rowid_to_column)
importFrom(tidyr,complete)
importFrom(tidyr,drop_na)
importFrom(tidyr,expand_grid)
Expand All @@ -134,7 +135,9 @@ importFrom(tidyr,separate)
importFrom(tidyr,spread)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(tidyselect,all_of)
importFrom(tidyselect,eval_select)
importFrom(tidyselect,last_col)
importFrom(utils,data)
useDynLib(sccomp, .registration = TRUE)
importFrom(utils,install.packages)
importFrom(utils,menu)
42 changes: 42 additions & 0 deletions R/cmdstanr_safe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@


sample_safe <- function(model, fx, ...) {
tryCatch(
{
# Attempt to run the arbitrary fx with additional arguments
result <- fx(model, ...)
return(result)
},
error = function(e) {
# Check if the error message is "model not compiled"
if (grepl("Model not compiled", e$message)) {
message("Model not compiled. Compiling.")
# Load the model with force=TRUE
model <- model$compile(cpp_options = list(stan_threads = TRUE)) # load_model("glm_multi_beta_binomial_generate_data", force = TRUE)
# Retry the arbitrary fx with additional arguments
result <- fx(model, ...)
return(result)
} else {
# If a different error, rethrow the error
stop(e)
}
}
)
}


sample_fx <- function(model, ...) {
model$sample(...)
}

pathfinder_fx <- function(model, ...) {
model$pathfinder(...)
}

variational_fx <- function(model, ...) {
model$variational(...)
}

generate_quantities_fx <- function(model, ...) {
model$generate_quantities(...)
}
Loading

0 comments on commit e664088

Please sign in to comment.