Skip to content

Commit

Permalink
update run_phenomix to run multiple CTD levels
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Sep 26, 2024
1 parent 10b0d06 commit 84b749c
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 592 deletions.
512 changes: 0 additions & 512 deletions .Rhistory

This file was deleted.

50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,53 @@ tests/testthat/data/
./**/**/**/**/.DS_Store
./**/**/**/**/**/.DS_Store
./**/**/**/**/**/**/.DS_Store

# 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/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MSTExplorer
Title: Multi-Scale Target Explorer
Version: 1.0.3
Version: 1.0.4
Authors@R:
c(
person(given = "Brian",
Expand All @@ -25,7 +25,7 @@ Encoding: UTF-8
URL: https://github.com/neurogenomics/MSTExplorer
BugReports: https://github.com/neurogenomics/MSTExplorer/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Depends:
R (>= 4.1)
Imports:
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# MSTExplorer 1.0.4

## New features

* `run_phenomix`: can now take multiple `annotLevel`s at once (will iterate).

# MSTExplorer 1.0.3

## New features
Expand Down
21 changes: 12 additions & 9 deletions R/run_phenomix.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
#' save_path=tempfile())
#' }
run_phenomix <- function(ctd_name,
annotLevel,
annotLevel = seq(length(ctd)),
ymat,
test_method="glm",
metric="specificity",
ctd = load_example_ctd(
file = paste0("ctd_",ctd_name,".rds")
),
xmat = ctd[[annotLevel]][[metric]],
save_path = file.path(
tempfile(),
# here::here(),
Expand All @@ -49,18 +48,22 @@ run_phenomix <- function(ctd_name,
test_method <- "glm"
multivariate <- FALSE
}
lm_res <- phenomix::iterate_lm(xmat = xmat,
ymat = ymat,
test_method = test_method,
multivariate = multivariate,
workers = workers,
...)
## Iterate over each CTD level
lm_res <- lapply(stats::setNames(annotLevel,annotLevel), function(lvl){
messager("Running phenomix with CTD annotLevel:",lvl)
phenomix::iterate_lm(xmat = ctd[[lvl]][[metric]],
ymat = ymat,
test_method = test_method,
multivariate = multivariate,
workers = workers,
...)
}) |> data.table::rbindlist(idcol = "annotLevel")

run_phenomix_postprocess <- function(lm_res,
annotLevel,
effect_var = c("estimate","statistic",
"ges","F")){
effect_var <- intersect(effect_var,names(lm_res))[1]
lm_res[,annotLevel:=annotLevel]
data.table::setnames(lm_res,
c("xvar","yvar"),
c("CellType","hpo_id"))
Expand Down
32 changes: 0 additions & 32 deletions man/ewce_para.Rd

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

32 changes: 0 additions & 32 deletions man/gen_results.Rd

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

2 changes: 1 addition & 1 deletion man/prioritise_targets.Rd

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

5 changes: 1 addition & 4 deletions man/run_phenomix.Rd

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

0 comments on commit 84b749c

Please sign in to comment.