Skip to content

Commit

Permalink
Merge pull request #139 from omnideconv/fix_consensusTME_bug
Browse files Browse the repository at this point in the history
Fix consensus tme bug (#133)  + Cibersort warning (#137)
  • Loading branch information
LorenzoMerotto authored Mar 9, 2023
2 parents 28fce56 + 6b49224 commit 8282446
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
extra-packages: any::covr
needs: coverage

- name: Manually install preprocessCore
if: ${{ !(matrix.config.os == 'windows-latest' || matrix.config.os == 'macOS-latest') }}
run: |
git clone https://github.com/bmbolstad/preprocessCore.git
cd preprocessCore
R CMD INSTALL --configure-args="--disable-threading" .
- name: Test coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
- { 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 }}
Expand All @@ -46,6 +45,13 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- name: Manually install preprocessCore
if: ${{ !(matrix.config.os == 'windows-latest' || matrix.config.os == 'macOS-latest') }}
run: |
git clone https://github.com/bmbolstad/preprocessCore.git
cd preprocessCore
R CMD INSTALL --configure-args="--disable-threading" .
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ Roxygen: list(markdown = TRUE)
LazyData: true
URL: https:/omnideconv.org/immunedeconv, https://github.com/omnideconv/immunedeconv
BugReports: https://github.com/omnideconv/immunedeconv/issues
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
3 changes: 2 additions & 1 deletion R/immune_deconvolution_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ deconvolute_cibersort <- function(gene_expression_matrix,
source(get("cibersort_binary", envir = config_env))

tmp_mat <- tempfile()
write_tsv(as_tibble(gene_expression_matrix, rownames = "gene_symbol"), path = tmp_mat)
write_tsv(as_tibble(gene_expression_matrix, rownames = "gene_symbol"), file = tmp_mat)

arguments <- dots_list(get("cibersort_mat", envir = config_env), tmp_mat,
perm = 0,
Expand Down Expand Up @@ -309,6 +309,7 @@ deconvolute_consensus_tme <- function(gene_expression_matrix,
method = "ssgsea",
...) {
indications <- toupper(indications)
indications[indications == "UNFILTERED"] <- "Unfiltered"
assert("indications fit to mixture matrix", length(indications) == ncol(gene_expression_matrix))

gene_expression_matrix <- as.matrix(gene_expression_matrix)
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test_deconvolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ test_that("consensus_tme with multiple indications, ordered and unordered", {
})


test_that("consensus_tme with multiple indications, including 'Unfiltered'", {
indications_1 <- c("blca", "blca", "brca", "brca", "chol", "chol", "Unfiltered", "Unfiltered")
indications_2 <- c("brca", "Unfiltered", "brca", "blca", "Unfiltered", "chol", "chol", "blca")
res_1 <- deconvolute_consensus_tme(test_mat, indications = indications_1)
res_2 <- deconvolute_consensus_tme(test_mat, indications = indications_2)
assert("matrix dimensions consistent", ncol(res_1) == ncol(test_mat))
assert("matrix dimensions consistent", ncol(res_2) == ncol(test_mat))

order.samples <- order(toupper(indications_2))

assert("proper results", all(colnames(res_1)[order.samples] == colnames(res_2)))
})

test_that("generic deconvolution works for all methods", {
lapply(deconvolution_methods, function(method) {
# cibersort requires the binary path to be set, n/a in unittest.
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_deconvolution_mouse.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ test_that("DCQ works", {
})

test_that("BASE works", {
res <- deconvolute_base_algorithm(test_mat)
res <- deconvolute_base_algorithm(test_mat, n_permutations = 5)
assert("matrix dimensions consistent", ncol(res) == ncol(test_mat))
})

test_that("DCQ works without reducing cell types", {
res <- deconvolute_dcq(test_mat, combine_cells = FALSE)
res <- deconvolute_dcq(test_mat, combine_cells = FALSE, n_repeats = 5)
assert("matrix dimensions consistent", ncol(res) == ncol(test_mat))
})

Expand Down

0 comments on commit 8282446

Please sign in to comment.