【问题标题】:How to read a transition matrix into Cytoscape for Markov Chain modelling?如何将转换矩阵读入 Cytoscape 以进行马尔可夫链建模?
【发布时间】:2019-09-12 22:18:08
【问题描述】:

我想将转换矩阵读入 Cytoscape 以进行马尔可夫链建模。例如,我从这篇文章中借用了下面的转换矩阵(包括 R 代码): Creating three-state Markov chain plot

Cytoscape 如何读取这样的transitionMatrix

谢谢。

转换矩阵的格式

transitionMatrix 是这样的:

       tired angry calm
 tired   0.5   0.5  0.0
 angry   0.0   0.2  0.8
 calm    0.8   0.0  0.2

R 代码

 pre<-cbind(c(rep("tired",100),rep("angry",100),rep("calm",100)))
 post<-cbind(c(rep("tired",50),rep("angry",70),rep("calm",100),rep("tired",80)))
 df<-cbind(pre,post)
 df<-as.data.frame(df)
 colnames(df)<-c("pre","post")
 states<-c("tired","angry","calm")
 probsCase<-function(i,j){
   sum(as.character(df$pre)==states[i] & 
   as.character(df$post)==states[j])/sum(as.character(df$pre)==states[i])
 }
 transitionMatrix<-outer(1:3,1:3,Vectorize(probsCase))
 colnames(transitionMatrix)<-states
 rownames(transitionMatrix)<-states

【问题讨论】:

    标签: r format transition markov-chains cytoscape


    【解决方案1】:

    有一个名为 aMatReader 的应用程序可以让您读取邻接矩阵。

    -- 滑板车

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多