Skip to content

Commit

Permalink
rm feather package
Browse files Browse the repository at this point in the history
  • Loading branch information
kspan committed Mar 23, 2021
1 parent 7bb897e commit 0e243fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
20 changes: 12 additions & 8 deletions R/class_ScenicOptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,14 @@ dbVersion <- function(dbs)
#' @rdname ScenicOptions-class
#' @export
dbLoadingAttempt <- function(dbFilePath){
ret <- FALSE
ret <- tryCatch({
md <- feather::feather_metadata(dbFilePath)
md$path
md$dim[2] == length(md$types)
randomCol <- sample(names(md$types),1)
ret <- FALSE
ret <- tryCatch({
rf <- arrow::ReadableFile$create(dbFilePath)
fr <- arrow::FeatherReader$create(rf)
fr$version
genesInDb <- names(fr)
randomCol <- sample(genesInDb, 1)
fr$Read(randomCol)
rnk <- RcisTarget::importRankings(dbFilePath, columns=randomCol)
return(TRUE)
}
Expand All @@ -497,10 +499,12 @@ checkAnnots <- function(object, motifAnnot)
allFeaturesInAnnot <- unlist(motifAnnot[,1]) # motif or track
featuresWithAnnot <- lapply(getDatabases(object), function(dbFile)
{
nRnks <- unlist(feather::read_feather(dbFile, columns="features")[,1])
rnktype = "features" #TODO: add as option for custom dbs
nRnks <- getRanking(RcisTarget::importRankings(dbFile, columns = rnktype))
nRnks <- dplyr::pull(nRnks, rnktype)

length(intersect(allFeaturesInAnnot,nRnks))/length(unique(c(allFeaturesInAnnot,nRnks)))
})
return(featuresWithAnnot)
}


11 changes: 8 additions & 3 deletions R/runSCENIC_2_createRegulons.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ runSCENIC_2_createRegulons <- function(scenicOptions,
if(any(!loadAttempt)) stop("It is not possible to load the following databses: \n",
paste(dbs[which(!loadAttempt)], collapse="\n"))

genesInDb <- unique(unlist(lapply(getDatabases(scenicOptions), function(x)
names(feather::feather_metadata(x)[["types"]]))))
genesInDb <- unique(unlist(lapply(getDatabases(scenicOptions), function(dbFilePath) {
rf <- arrow::ReadableFile$create(dbFilePath)
fr <- arrow::FeatherReader$create(rf)
genesInDb <- names(fr)
rnktype <- "features" #TODO: add as option for custom dbs
genesInDb <- genesInDb[genesInDb != rnktype]
})))

## Check if annotation and rankings (potentially) match:
featuresWithAnnot <- checkAnnots(scenicOptions, motifAnnot)
Expand Down Expand Up @@ -208,7 +213,7 @@ runSCENIC_2_createRegulons <- function(scenicOptions,

################################################################
# 2. Prune targets
msg <- paste0(format(Sys.time(), "%H:%M"), "\tRcisTarget: Prunning targets")
msg <- paste0(format(Sys.time(), "%H:%M"), "\tRcisTarget: Pruning targets")
if(getSettings(scenicOptions, "verbose")) message(msg)

dbNames <- getDatabases(scenicOptions)
Expand Down
2 changes: 1 addition & 1 deletion R/runSCENIC_2_createRegulons_Original.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
#'
#' ################################################################
#' # 2. Prune targets
#' msg <- paste0(format(Sys.time(), "%H:%M"), "\tRcisTarget: Prunning targets")
#' msg <- paste0(format(Sys.time(), "%H:%M"), "\tRcisTarget: Pruning targets")
#' if(getSettings(scenicOptions, "verbose")) message(msg)
#'
#' dbNames <- getDatabases(scenicOptions)
Expand Down

0 comments on commit 0e243fd

Please sign in to comment.