Skip to content

Commit 6f6f66e

Browse files
Merge pull request #158 from omnideconv/fix_conversion_fuction
Fix conversion fuction
2 parents 72ef99e + ab9e54f commit 6f6f66e

19 files changed

Lines changed: 115 additions & 86 deletions

.conda/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package:
44
name: {{ name }}
5-
version: "develop"
5+
version: "develop"
66

77
source:
88
path: ".."
@@ -68,7 +68,7 @@ test:
6868
- '$R -e "library(''immunedeconv'')"'
6969

7070
about:
71-
home: https://github.com/icbi-lab/immunedeconv
71+
home: https://github.com/omnideconv/immunedeconv
7272
license: BSD_3_clause
7373
summary: "collection of methods for immune cell deconvolution of bulk RNA-seq samples."
7474
license_family: BSD

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ Roxygen: list(markdown = TRUE)
6666
LazyData: true
6767
URL: https:/omnideconv.org/immunedeconv, https://github.com/omnideconv/immunedeconv
6868
BugReports: https://github.com/omnideconv/immunedeconv/issues
69-
RoxygenNote: 7.2.3
69+
RoxygenNote: 7.3.3

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export(custom_deconvolution_methods)
88
export(deconvolute)
99
export(deconvolute_abis)
1010
export(deconvolute_base_algorithm)
11-
export(deconvolute_base_custom)
1211
export(deconvolute_cibersort)
1312
export(deconvolute_cibersort_custom)
1413
export(deconvolute_consensus_tme)
@@ -22,6 +21,7 @@ export(deconvolute_mmcp_counter)
2221
export(deconvolute_mouse)
2322
export(deconvolute_quantiseq)
2423
export(deconvolute_seqimmucc)
24+
export(deconvolute_seqimmucc_custom)
2525
export(deconvolute_timer)
2626
export(deconvolute_xcell)
2727
export(deconvolution_methods)
@@ -35,6 +35,7 @@ export(map_cell_types)
3535
export(map_result_to_celltypes)
3636
export(reduce_mouse_cell_types)
3737
export(scale_to_million)
38+
export(seqImmuCC_LLSR)
3839
export(set_cibersort_binary)
3940
export(set_cibersort_mat)
4041
export(timer_available_cancers)

R/custom_deconvolution_methods.R

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ NULL
1919
#' List of methods that support the use of a custom signature
2020
#'
2121
#' The available methods are
22-
#' `epic`, `cibersort`, `cibersort_abs`, `consensus_tme`, `base`
22+
#' `epic`, `cibersort`, `cibersort_abs`, `consensus_tme`, `seqimmucc`
2323
#'
2424
#' The object is a named vector. The names correspond to the display name of the method,
2525
#' the values to the internal name.
@@ -29,7 +29,7 @@ custom_deconvolution_methods <- c(
2929
"EPIC" = "epic",
3030
"CIBERSORT" = "cibersort",
3131
"ConsensusTME" = "consensus_tme",
32-
"BASE" = "base"
32+
"seqImmuCC" = "seqimmucc"
3333
)
3434

3535

@@ -153,25 +153,29 @@ deconvolute_consensus_tme_custom <- function(gene_expression_matrix, signature_g
153153
}
154154

155155

156-
157-
#' Deconvolute using BASE and a custom signature matrix
156+
#' Deconvolute using seqImmuCC (LLSR regression) and a custom signature matrix
158157
#'
159158
#' @param gene_expression_matrix a m x n matrix with m genes and n samples. Data
160159
#' should be TPM normalized and log10 scaled.
161-
#' @param signature_matrix a m x l matrix with m genes and l cell types. Data
162-
#' should be non normalized, as the normalization wil be done in the construction
163-
#' of the compendium (internal structure)
164-
#' @param n_permutations the number of permutations of each sample expression
165-
#' to generate. These are used to normalize the results.
166-
#' @param log10 logical. if TRUE, log10 transforms the expression matrix.
160+
#' @param signature_matrix a m x l matrix with m genes and l cell types. The
161+
#' matrix should contain only a subset of the genes useful for the analysis.
162+
#' @param ... passed to the original seqImmuCC_LLSR function
167163
#' @export
168164
#'
169-
deconvolute_base_custom <- function(gene_expression_matrix,
170-
signature_matrix,
171-
n_permutations = 100,
172-
log10 = TRUE) {
173-
new.cell.compendium <- create_base_compendium(signature_matrix)
174-
results <- base_algorithm(gene_expression_matrix, new.cell.compendium, perm = n_permutations)
165+
deconvolute_seqimmucc_custom <- function(gene_expression_matrix,
166+
signature_matrix,
167+
...) {
168+
arguments <- dots_list(
169+
signature = signature_matrix,
170+
SampleData = gene_expression_matrix, ..., .homonyms = "last"
171+
)
172+
173+
call <- rlang::call2(seqImmuCC_LLSR, !!!arguments)
174+
results <- eval(call)
175+
176+
177+
# results <- seqImmuCC_LLSR(signature_matrix, gene_expression_matrix, ..., .homonyms = "last")
178+
results <- results[, !colnames(results) %in% c("Correlation", "RSEM")]
175179

176180
return(t(results))
177181
}

R/immune_deconvolution_methods.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,22 @@ deconvolute_consensus_tme <- function(gene_expression_matrix,
328328
t, method
329329
)
330330

331+
colnames(cur.results) <- colnames(gene_expression_matrix)[cur.samples]
331332
list.results[[t]] <- cur.results
332333
}
333334

334-
results <- Reduce(cbind, list.results)
335+
list.results <- lapply(list.results, function(x) as.data.frame(x))
335336

336-
colnames(results) <- colnames(gene_expression_matrix)
337+
if (length(tumor.types) > 1) {
338+
results <- Reduce(
339+
function(x, y) merge(x, y, all = TRUE),
340+
lapply(list.results, function(x) data.frame(x, rn = row.names(x)))
341+
)
342+
343+
results <- column_to_rownames(results, "rn")
344+
} else {
345+
results <- list.results[[1]]
346+
}
337347

338348
return(results)
339349
}

R/mouse_deconvolution_methods.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ convert_human_mouse_genes <- function(gene_expression_matrix, mirror = "www",
271271
gene_expression_matrix <- as.data.frame(gene_expression_matrix)
272272
gene_expression_matrix$gene_name <- gene.names
273273
} else {
274+
gene.names <- gene_expression_matrix
274275
gene_expression_matrix <- data.frame(
275276
"gene_name" = gene_expression_matrix,
276277
"X" = rep(0, length(gene_expression_matrix))

R/seqImmuCC_LLSR.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' @param sig.stand logical.If TRUE, standardizes the signature matrix
1616
#' @param sample.scale logical. If TRUE, scales the sample expression
1717
#' @param log logical. If TRUE, log transforms signature and expression data
18-
#'
18+
#' @export
1919
#'
2020
seqImmuCC_LLSR <- function(signature, SampleData, w = NA, QN = T, sig.scale = F, sig.stand = T, sample.scale = T, log = T) {
2121
# Expression profile format standarlization

_pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ reference:
4040
- custom_deconvolution_methods
4141
- deconvolute_cibersort_custom
4242
- deconvolute_epic_custom
43-
- deconvolute_base_custom
43+
- deconvolute_seqimmucc_custom
4444
- deconvolute_consensus_tme_custom
4545
- title: Cell type mapping
4646
desc: Map cell types and datasets to a controlled vocabulary.
10 Bytes
Binary file not shown.

man/cell_type_tree.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)