Skip to content

Commit

Permalink
fixed a bug in compare2groups(): when there is only one column in pda…
Browse files Browse the repository at this point in the history
…ta, eset can not be subsetted
  • Loading branch information
QingfeiPan committed Aug 6, 2024
1 parent 7507829 commit 4ccef62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/differential_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ compare2groups <- function(input_eset,
if ((group_by %in% colnames(Biobase::pData(input_eset))) == FALSE) {stop('The group_by column,', group_by, ', was not found in the input set. Please check and re-try.')}

pd <- Biobase::pData(input_eset)
g1.cells <- row.names(pd[pd[,group_by] %in% g1,])
g1.cells <- row.names(pd)[pd[,group_by] %in% g1]
if (length(g1.cells) > 0) {cat("\t", length(g1.cells), "cells were found for g1.\n")} else {stop('No cell was found for g1. Please check and re-try.')}
g0.cells <- row.names(pd[pd[,group_by] %in% g0,])
g0.cells <- row.names(pd)[pd[,group_by] %in% g0]
if (length(g0.cells) > 0) {cat("\t", length(g0.cells), "cells were found for g0.\n")} else {stop('No cell was found for g0. Please check and re-try.')}

## prepare matrix for limma
use_samples <- c(g1.cells, g0.cells)
exp_mat <- Biobase::exprs(input_eset[, use_samples])
exp_mat <- Biobase::exprs(input_eset)[, use_samples]

## calculate the average and percentage
exp_mat.g1 <- as.matrix(exp_mat[, g1.cells, drop = FALSE])
Expand Down

0 comments on commit 4ccef62

Please sign in to comment.