Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/bigomics/playbase
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokwee committed Oct 31, 2023
2 parents 5bd7f02 + 514a7dd commit a822299
Show file tree
Hide file tree
Showing 56 changed files with 162 additions and 241 deletions.
2 changes: 1 addition & 1 deletion R/compute2-genesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ compute_testGenesets <- function(pgx,
## Load huge geneset matrix
## -----------------------------------------------------------

G <- playdata::GSET_SPARSEG_XL
G <- playdata::GSETxGENE

## -----------------------------------------------------------
## Filter genes
Expand Down
44 changes: 13 additions & 31 deletions R/pgx-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ read.as_matrix.SAVE <- function(file) {
#' Read data file as matrix
#'
#' @param file Path to input data file
#' @param skip_row_check (default `FALSE`) Flag to skip the removal
#' of empty rows
#'
#' @return Matrix object containing data from file
#'
Expand All @@ -749,7 +751,7 @@ read.as_matrix.SAVE <- function(file) {
#' mymatrix <- read.as_matrix(mydata.csv)
#' }
#' @export
read.as_matrix <- function(file) {
read.as_matrix <- function(file, skip_row_check = FALSE) {
## read delimited table automatically determine separator. allow
## duplicated rownames. This implements with faster fread.
x0 <- data.table::fread(
Expand All @@ -771,9 +773,11 @@ read.as_matrix <- function(file) {
rownames(x) <- x0[[1]][sel]
}
## drop any rows with 100% missing value (sometimes added by not-so-Excel...)
zero.row <- which(rowSums(is.na(x)) == ncol(x))
if (length(zero.row)) {
x <- x[-zero.row, , drop = FALSE]
if (!skip_row_check) { # Flag to bypass (used on contrast.csv ingest), as it can contain full NA rows
zero.row <- which(rowSums(is.na(x)) == ncol(x))
if (length(zero.row)) {
x <- x[-zero.row, , drop = FALSE]
}
}
## drop any 100% missing columns (sometimes added by not-so-Excel...)
zero.col <- which(colSums(is.na(x)) == nrow(x))
Expand Down Expand Up @@ -1656,41 +1660,19 @@ pgx.getGeneFamilies <- function(genes, min.size = 10, max.size = 500) {
#' @return A list containing the extracted gene set collections.
#'
#' @export
pgx.getGeneSetCollections <- function(gsets, min.size = 10, max.size = 500) {
pgx.getGeneSetCollections <- function(gsets = rownames(playdata::GSETxGENE)) {
## -----------------------------------------------------------------------------
## Gene set collections
## -----------------------------------------------------------------------------

collections <- list(
"Hallmark collection" = gsets[grep("HALLMARK", gsets)],
"Pathway related" = gsets[grep("pathway", gsets, ignore.case = TRUE)],
"Metabolism related" = gsets[grep("metaboli", gsets, ignore.case = TRUE)],
"Signalling related" = gsets[grep("signal", gsets, ignore.case = TRUE)],
"T-cell related" = gsets[grep("tcell|t-cell|t[ ]cell", gsets, ignore.case = TRUE)],
"B-cell related" = gsets[grep("bcell]b-cell|b[ ]cell", gsets, ignore.case = TRUE)],
"Response related" = gsets[grep("response", gsets, ignore.case = TRUE)],
"Cancer related" = gsets[grep("cancer", gsets, ignore.case = TRUE)],
"Immune related" = gsets[grep("immune", gsets, ignore.case = TRUE)],
"Cell differentiation" = gsets[grep("differentiation", gsets, ignore.case = TRUE)],
"Checkpoint related" = gsets[grep("checkpoint", gsets, ignore.case = TRUE)],
"IL gene sets" = gsets[grep("IL[1-9]{1,2}", gsets, ignore.case = TRUE)],
"Aging" = gsets[grep("aging", gsets, ignore.case = TRUE)],
"Disease" = gsets[grep("jensen|disease|covid|diabetes", gsets, ignore.case = TRUE)],
)

collections[["<all>"]] <- gsets ## X is sorted
collections <- collections[which(sapply(collections, length) >= 10)]
collections <- collections[order(names(collections))]
collections <- list()

## ----------- add main collections from gene set prefixes
gsets.db <- sub(":.*", "", gsets)
gsets.db <- sub("_.*", "", gsets)
gsets.db <- sub(":.*", "", gsets.db)
gsets.groups <- tapply(gsets, gsets.db, list)
collections <- c(collections, gsets.groups)

## ----------- filter on size
nsize <- sapply(collections, length)
sel <- which(nsize >= min.size & nsize < max.size)
collections <- collections[sel]
collections[["<all>"]] <- gsets
return(collections)
}

Expand Down
2 changes: 1 addition & 1 deletion R/pgx-signature.R
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pgx.addEnrichmentSignaturesH5 <- function(h5.file, X = NULL, mc.cores = 0,

## ---------------------- ONLY HALLMARK FOR NOW -----------------------

G <- playdata::GSET_SPARSEG_XL
G <- playdata::GSETxGENE
sel <- grep("HALLMARK|C[1-9]|^GO", rownames(G))
sel <- grep("HALLMARK", rownames(G))
genes <- intersect(colnames(G), rownames(X))
Expand Down
4 changes: 2 additions & 2 deletions man/calc.edge.similarity.Rd

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

6 changes: 3 additions & 3 deletions man/check_duplicate_cols.Rd

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

4 changes: 2 additions & 2 deletions man/compute_cellcycle_gender.Rd

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

4 changes: 2 additions & 2 deletions man/compute_deconvolution.Rd

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

4 changes: 2 additions & 2 deletions man/compute_drugActivityEnrichment.Rd

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

4 changes: 2 additions & 2 deletions man/compute_drugSensitivityEnrichment.Rd

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

9 changes: 5 additions & 4 deletions man/compute_extra.Rd

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

4 changes: 2 additions & 2 deletions man/compute_omicsGraphs.Rd

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

3 changes: 2 additions & 1 deletion man/createSparseGenesetMatrix.Rd

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

2 changes: 1 addition & 1 deletion man/dot-RGimputation.Rd

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

2 changes: 1 addition & 1 deletion man/expandAnnotationMatrix.Rd

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

12 changes: 3 additions & 9 deletions man/expandPhenoMatrix.Rd

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

2 changes: 1 addition & 1 deletion man/fit.weibull2.Rd

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

6 changes: 3 additions & 3 deletions man/getGOgraph.Rd

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

2 changes: 1 addition & 1 deletion man/graph.cut_crossings.Rd

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

6 changes: 3 additions & 3 deletions man/hclustGraph.Rd

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

2 changes: 1 addition & 1 deletion man/itercluster_louvain.Rd

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

2 changes: 1 addition & 1 deletion man/length_encode.Rd

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

23 changes: 23 additions & 0 deletions man/mat2gmt.Rd

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

2 changes: 1 addition & 1 deletion man/mixHivePlot.Rd

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

4 changes: 2 additions & 2 deletions man/pgx.SeuratBatchIntegrate.Rd

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

2 changes: 1 addition & 1 deletion man/pgx._addSourceSink.Rd

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

Loading

0 comments on commit a822299

Please sign in to comment.