Comments (2)
Hi!
I have tried it with feather 0.3.3 and RcisTarget (from github) 1.5.0 and it seems to work. Can you check if it works for you with this:
topicsRcisTarget <- function(
object,
genome,
pathToDb,
reduced_database = FALSE,
nesThreshold = 3,
rocthr = 0.005,
maxRank = 20000,
nCores = 1,
...
){
# Check input
if(length(object@binarized.regions.to.Rct) < 1){
stop('Please, run binarizedcisTopicsToCtx() first.')
}
# Check dependencies
if(! "RcisTarget" %in% installed.packages()){
stop('Please, install RcisTaregt: \n install_github("aertslab/RcisTarget")')
} else {
require(RcisTarget)
}
if (genome == 'hg19'){
data(motifAnnotations_hgnc)
motifAnnot <- motifAnnotations_hgnc
if(rocthr!=0.005 | maxRank!=20000){
warning("For Homo sapiens the recommended settings are: rocthr=0.005, maxRank=20000")
}
}
else if (genome == 'mm9'){
data(motifAnnotations_mgi)
motifAnnot <- motifAnnotations_mgi
if(rocthr!=0.005 | maxRank!=20000){
warning("For Mus musculus the recommended settings are: rocthr=0.005, maxRank=20000")
}
}
else if (genome == 'dm3'){
data(motifAnnotations_dmel)
motifAnnot <- motifAnnotations_dmel
if(rocthr!=0.01 | maxRank!=5000){
warning("For Drosophila melanogaster the recommended settings are: rocthr=0.01, maxRank=5000")
}
}
else if (genome == 'dm6'){
data(motifAnnotations_dmel)
motifAnnot <- motifAnnotations_dmel
if(rocthr!=0.01 | maxRank!=5000){
warning("For Drosophila melanogaster the recommended settings are: rocthr=0.01, maxRank=5000")
}
} else {
stop('The genome required is not available! Try using the liftover option.')
}
topicsList <- object@binarized.regions.to.Rct
extension <- strsplit(pathToDb, "\\.")[[1]][length(strsplit(pathToDb, "\\.")[[1]])]
if (extension == 'feather'){
columnsinRanking <- feather::feather_metadata(pathToDb)[["dim"]][2]-1
}
else if (extension == "parquet"){
pq <- arrow::parquet_file_reader(pathToDb)
columnsinRanking <- pq$GetSchema()$num_fields()-1
}
else{
stop("Database format must be feather or parquet.")
}
if (reduced_database == FALSE){
ctxreg <- unique(as.vector(unlist(object@binarized.regions.to.Rct)))
motifRankings <- importRankings(pathToDb, columns = c('features', ctxreg))
}
else{
motifRankings <- importRankings(pathToDb)
ctxregions <- colnames(getRanking(motifRankings))[-1]
topicsList <- llply(1:length(topicsList), function(i) topicsList[[i]][which(topicsList[[i]] %in% ctxregions)])
names(topicsList) <- names(object@binarized.regions.to.Rct)
}
if (length(topicsList) < nCores){
print(paste('The number of cores (', nCores, ') is higher than the number of topics (', length(topicsList),').', sep=''))
}
if(nCores > 1){
cl <- makeCluster(nCores, type = "SOCK")
registerDoSNOW(cl)
print(paste('Exporting data to clusters...'))
clusterEvalQ(cl, library(feather), library(RcisTarget))
clusterExport(cl, c("topicsList", "motifRankings", "motifAnnot", "nesThreshold", "rocthr", "columnsinRanking", "maxRank"), envir=environment())
print(paste('Running RcisTarget...'))
cisTopic.cisTarget <- suppressWarnings(llply(1:length(topicsList), function (i) cisTarget(topicsList[[i]],
motifRankings,
motifAnnot = motifAnnot,
nesThreshold = nesThreshold,
aucMaxRank = rocthr * columnsinRanking,
geneErnMmaxRank = maxRank,
nCores=1
), .parallel = TRUE))
stopCluster(cl)
}
else{
cisTopic.cisTarget <- suppressWarnings(llply(1:length(topicsList), function (i) cisTarget(topicsList[[i]],
motifRankings,
motifAnnot = motifAnnot,
nesThreshold = nesThreshold,
aucMaxRank = rocthr * columnsinRanking,
geneErnMmaxRank = maxRank,
nCores=1
)))
}
object.binarized.RcisTarget <- list()
for (i in 1:length(cisTopic.cisTarget)){
if(nrow(cisTopic.cisTarget[[i]]) > 0){
colnames(cisTopic.cisTarget[[i]])[c(1, 7, 9)] <- c('cisTopic', 'nEnrRegions', 'enrichedRegions')
cisTopic.cisTarget[[i]]$cisTopic <- rep(paste('Topic', i, sep='_'), nrow(cisTopic.cisTarget[[i]]))
object.binarized.RcisTarget[[i]] <- addLogo(cisTopic.cisTarget[[i]])
} else {
cisTopic.cisTarget[[i]] <- NULL
}
}
object@binarized.RcisTarget <- object.binarized.RcisTarget
return(object)
}
I would also lower the number of cores a bit, because it will load the feather database in each of them (and that can take up a lot of memory).
Let me know if this solves it!
C
from cistopic.
Unfortunately, same issue. I am wondering if i am having a docker-related issue. My RStudio is running on a docker container and i am starting to think this is causing the issue. I can run the command with ncores=1 (although it does take forever); the error comes up with ncores>1. As far as i recall, i had to do the same thing for SCENIC.
from cistopic.
Related Issues (20)
- Question about createcisTopicObject HOT 1
- installation issue with ubuntu 20.04 HOT 3
- possibility to use BAM files from bulk ChIP HOT 1
- annotateRegions with own dataset HOT 1
- createcisTopicObject and genomic coordinates incompatibility error HOT 3
- input from fragments.tsv.gz? HOT 1
- Installation issue HOT 2
- Tutorial Dataset files HOT 1
- tSNE Clustering Thresholds HOT 1
- LDA run with Python and LogLikelihhod HOT 1
- How can I run cisTopic in R 4.0 HOT 2
- Ununsed Arguement error in cisTopic/TcisTarget HOT 1
- cisTopicObject <- selectModel(cisTopicObject) Error in .Call("rs_createGD") : C symbol name "rs_createGD" not in load table HOT 1
- Unused argument error while running topicsRcisTarget
- add cisTopic output to Seurat object? HOT 1
- Running Cistopic HOT 1
- Installation error "Failed to install 'unknown package' from Github: ..." HOT 1
- Loading Multiome data
- sha256sum download failed HOT 1
- Error in metadataFeather(path) : Invalid: Not a feather file HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cistopic.