Coder Social home page Coder Social logo

Accessing topics fits about cistopic HOT 3 CLOSED

aertslab avatar aertslab commented on June 21, 2024
Accessing topics fits

from cistopic.

Comments (3)

cbravo93 avatar cbravo93 commented on June 21, 2024

Hi Tim,

The unnormalized cell assignments throughtout the sampling iterations are stored in [email protected]$document_expects; while the corresponding unnormalized region assignments are stored in [email protected]$topics. I have added this to the selectModel() and the cisTopic class documentation.

For normalising cell assignments you can do:

#Z-score
norm_assig <- scale([email protected]$document_expects, center=TRUE, scale=TRUE)

#Probability
alpha <- [email protected][['runModels']]$alpha/length([email protected]$topic_sums)
norm_assig <- apply([email protected]$document_sums, 2, function(x) {(x + alpha)/sum(x + alpha)})

For normalising the regions, you can take a look to getRegionsScores(). The normalised topic scores for each region will be stored in [email protected] then.

Hope this is helpful!

from cistopic.

timydaley avatar timydaley commented on June 21, 2024

The document expects and topics are null. Code and results are shown below. Data is from Buenrostro 2018 and downloaded from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE96769

library(cisTopic)
countsMM = Matrix::readMM("scATACseq_counts2.txt")
cellNames = scan("cellNames2.txt", what = character())
head(cellNames)
categories = c("HSC", "MPP", "LMPP", "CMP", "CLP", "MEP", "GMP", "MCP", "mono", "UNK", "pDC")
matchCategory <- function(s, categories){
for(k in categories){
if(grepl(toString(k), s)){
return(k)
}
}
return("NA")
}
cellTypes = sapply(cellNames, function(s) matchCategory(toString(s), categories))
counts = as.matrix(countsMM)
dim(counts)
rows2keep = which(rowSums(counts) > 10)
counts = counts[rows2keep, ]
cells2keep = which(colSums(counts) > 50)
counts = counts[ ,cells2keep]
cellTypes = cellTypes[cells2keep]
dim(counts)
colnames(counts) = 1:dim(counts)[2]
peaks = read.table("GSE96769_PeakFile_20160207.bed")
peaks = peaks[rows2keep, ]
rownames(counts) = paste0(peaks[,1], ":", peaks[,2], "-", peaks[,3])
cisTopicObject = createcisTopicObject(count.matrix = counts, project.name='test')
counts.cisTopics = runModels(cisTopicObject, topic=17, nCores=1, burnin = 250, iterations = 500, addModels=FALSE)

summary([email protected]$topics)
Length Class Mode
0 NULL NULL
summary([email protected])
Length Class Mode
0 NULL NULL
[email protected]
NULL
[email protected]$document_expects
NULL
[email protected]$topics
NULL

from cistopic.

cbravo93 avatar cbravo93 commented on June 21, 2024

Hi Tim,

You need to run selectModel first to fill the selected.model slot.

counts.cisTopics <- selectModel(counts.cisTopics)

Otherwise, since you only have a model, you can find it in counts.cisTopics@models.

from cistopic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.