Skip to content

Commit 58991ae

Browse files
committed
map cell clusters when replicating subgroups
1 parent 95405c9 commit 58991ae

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

R/cell_deconvolution.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,12 +1972,6 @@ replicate_deconvolution_subgroups = function(deconv_res, deconvolution_test){
19721972
deconv_subgroups = deconv_res[["Deconvolution subgroups composition"]]
19731973
iterations = find.maximum.iteration(deconv_subgroups)
19741974

1975-
if (is.infinite(iterations) && iterations < 0) {
1976-
warning("No subgroups to replicate")
1977-
deconvolution_test = deconvolution_test[,colnames(deconvolution_test)%in%colnames(deconv_res[["Deconvolution matrix"]])] # Filter for features not found in the deconv_res (low variance, zeros, etc)
1978-
return(deconvolution_test)
1979-
}
1980-
19811975
## Extract the deconv feature without the cluster type
19821976
features_with_clusters <- colnames(deconv_res[["Deconvolution matrix"]])
19831977

@@ -1988,6 +1982,15 @@ replicate_deconvolution_subgroups = function(deconv_res, deconvolution_test){
19881982
# Create df to map the features with their corresponding clusters
19891983
map <- data.frame(base = base_names, suffix = cluster_suffixes, stringsAsFactors = FALSE)
19901984

1985+
if (is.infinite(iterations) && iterations < 0) {
1986+
warning("No subgroups to replicate")
1987+
## Paste the corresponding clusters to the deconvolution features
1988+
colnames(deconvolution_test) <- paste0(colnames(deconvolution_test), map$suffix[match(colnames(deconvolution_test), map$base)])
1989+
1990+
deconvolution_test = deconvolution_test[,colnames(deconvolution_test)%in%colnames(deconv_res[["Deconvolution matrix"]])] # Filter for features not found in the deconv_res (low variance, zeros, etc)
1991+
return(data.frame(deconvolution_test))
1992+
}
1993+
19911994
# Create same groups composition
19921995
for (m in 1:iterations) {
19931996
base_groups = list()

0 commit comments

Comments
 (0)