-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I'm trying to use the PBMC model to predict cell type labels for an in-house dataset:
pred_res <- predict_scClassifyJoint(exprsMat_test = exprsMat,
trainRes = pbmc_model,
algorithm = "WKNN",
features = c("limma"),
similarity = c("pearson", "spearman"),
prob_threshold = 0.7,
verbose = TRUE)
Since I’m using both "pearson" and "spearman" as similarities, does that mean the predictions are ensembled across these methods?
I noticed that in the scClassify:::calEnsembleRes function (link here), a weight vector of length 60 is generated. Then weight[keep] is passed to scClassify:::getResByWeights, but it still contains all 60 values.
Then the following code breaks if res only includes two values
> res
pearson_WKNN_limma spearman_WKNN_limma
"CD4+ T cell" "CD4+ T cell_Cytotoxic T cell_Natural killer cell"
##break
mat <- vapply(seq_len(length(resType)), function(i) {
ifelse(res %in% resType[i], 1, 0) * weight
}, numeric(length(res)))
To fix it, I think it should be:
mat <- vapply(seq_len(length(resType)), function(i) {
as.numeric(res == resType[i]) * weight
}, numeric(length(weight)))
But even after fixing that, I ran into another issue when assigning row and column names:
colnames(mat) <- resType
rownames(mat) <- names(res)
This fails because mat has 60 rows (from weight), but names(res) only has 2 values: "pearson_WKNN_limma" and "spearman_WKNN_limma".
So I'm a bit confused — is this a bug in how getResByWeights() expects the input, or am I misunderstanding how the ensembling is supposed to work?