Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: xCell2
Type: Package
Title: A Tool for Generic Cell Type Enrichment Analysis
Version: 0.99.5
Version: 0.99.5001
Authors@R:
c(person(given = "Almog",
family = "Angel",
Expand All @@ -23,7 +23,6 @@ Imports:
SummarizedExperiment,
Rfast,
singscore,
ontoProc,
ontologyIndex,
tibble,
dplyr,
Expand Down
32 changes: 30 additions & 2 deletions R/xCell2GetLineage.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#' If no output file is specified, the function returns a list of cell type dependencies.
#' If an output file is specified, the function writes the cell type dependencies to a TSV file.
#'
#' @importFrom ontoProc getOnto
#' @importFrom ontologyIndex get_descendants get_ancestors
#' @importFrom dplyr select mutate rowwise
#' @importFrom tibble as_tibble
Expand Down Expand Up @@ -57,7 +56,7 @@ xCell2GetLineage <- function(labels, outFile = NULL) {
lineageOut <- labelsUniq %>%
dplyr::mutate(descendants = "", ancestors = "")
} else {
cl <- ontoProc::getOnto(ontoname = "cellOnto", year_added = "2023")
cl <- getOntoLocal(ontoname = "cellOnto", year_added = "2023")
labelsUniq$descendants <- NA
labelsUniq$ancestors <- NA
for (i in seq_len(nrow(labelsUniq))) {
Expand Down Expand Up @@ -99,3 +98,32 @@ xCell2GetLineage <- function(labels, outFile = NULL) {
warning("It is recommended that you manually check the cell type lineage file: ", outFile)
}
}

getOntoLocal = function( ontoname="cellOnto", year_added = "2023" ) {
stopifnot(ontoname %in% c("caro", "cellLineOnto", "cellOnto", "cellosaurusOnto", "chebi_full",
"chebi_lite", "diseaseOnto", "efoOnto", "goOnto", "hcaoOnto", "mondo",
"patoOnto", "PROnto", "uberon", "Pronto")) # only Pronto will get a 2021 PRO

ah = AnnotationHub::AnnotationHub()
opd = AnnotationHub::query(ah, "ontoProcData")
meta = mcols(opd)
tmp = meta |> as.data.frame() |> dplyr::filter(grepl(year_added, rdatadateadded)) |> dplyr::select(title, description)


if (year_added == "2023") {
if( ontoname %in% c("caro", "cellLineOnto")) stop("this ontology not updated in 2023, use a different year_added value")
ontoname = paste0(ontoname, "_")
stopifnot(length(grep(ontoname, tmp$title))==1)
}
else if (year_added == "2022") {
ontoname = paste0(ontoname, "_")
stopifnot(length(grep(ontoname, tmp$title))==1)
}
else if (year_added == "2021") {
stopifnot(length(grep(paste0("^", ontoname, "$"), tmp$title))==1)
}
tmp = tmp |> filter(grepl(ontoname, title))
tag = rownames(tmp)
stopifnot(length(tag)==1)
ah[[tag]]
}