Skip to content

Commit

Permalink
subset (for ora)
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Mar 4, 2024
1 parent 2eae0a2 commit 1bc48b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/doGSEA.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#'
#' @param zeroPerc genes >= the percentage of count zero sample will be excluded.
#' Default to zero, not recommended in GSEA
#' @param bg_filter filter the background for those in table
#' @importFrom MKmisc mod.t.test
#' @return GSEA results from clusterProfiler
#' @export
doGSEA <- function(stana, candSp=NULL, cl=NULL, eps=1e-2, how=mean,
zeroPerc=0, rankMethod="modt", target="pathway") {
zeroPerc=0, rankMethod="modt", target="pathway", bg_filter=TRUE) {
if (is.null(candSp)) {candSp <- stana@ids[1]}
if (is.null(cl)) {cl <- stana@cl}
if (length(cl)!=2) {stop("Only the two group is supported")}
Expand All @@ -33,6 +34,7 @@ doGSEA <- function(stana, candSp=NULL, cl=NULL, eps=1e-2, how=mean,
}

## If filter based on number of zero per KOs
sub <- unique(row.names(ko_df_filt))
ko_df_filt <- data.frame(ko_df_filt[ rowSums(ko_df_filt!=0) >= (dim(ko_df_filt)[2] * zeroPerc), ]) |>
`colnames<-`(colnames(ko_df_filt))

Expand All @@ -58,6 +60,11 @@ doGSEA <- function(stana, candSp=NULL, cl=NULL, eps=1e-2, how=mean,
}
kopgsea$V1 <- kopgsea$V1 |> strsplit(":") |>
vapply("[",2,FUN.VALUE="a")

if (bg_filter) {
kopgsea <- kopgsea[kopgsea$V2 %in% sub, ]
}
print(dim(kopgsea))
## Return all the value regardless of P
enr <- clusterProfiler::GSEA(ko_sum,
TERM2GENE = kopgsea, pvalueCutoff=1)
Expand Down
5 changes: 4 additions & 1 deletion man/doGSEA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1bc48b4

Please sign in to comment.