生物领域从业者咨询生物数据上马尔可夫链与随机游走技术问题
Hey there! Let's work through your confusion with the Markov chain and random walk concepts in that bioinformatics paper—since tying these statistical ideas back to biological intuition is usually the key to getting it to click. First, let's recap your background and then dive into each question and actionable steps.
背景与已掌握内容
You've already got a solid foundation:
- 微阵列数据: Produces a
G×Smatrix, where columns represent samples, rows represent genes, and values are gene expression levels. - 通路: A set of genes that interact to perform specific functions, with cross-talk between different pathways.
The paper's goal is to expand a target pathway by incorporating genes from other pathways that likely interact with it.
流程拆解与疑问解答
Let's go through each step and unpack your questions:
步骤1-2: 构建共表达网络与加权度
- You're using Pearson correlation coefficients on the
G×Smatrix to build an undirected weightedG×Ggene co-expression network. - Calculating each gene's weighted degree
d(sum of all its correlation coefficients).
This part makes sense—you're quantifying how strongly each gene is connected to others based on expression similarity.
步骤3: 转移概率矩阵P (疑问Q1)
- Q1: Why is this called a transition probability matrix? How to intuit this biologically?
Think of each gene as a "state" in a Markov chain. The valueP_ijis the probability that if you're currently "at" genei, you'll "move to" genejnext.
Biologically, this maps directly to co-expression: genes with higher correlation coefficients (stronger edges in the network) are more likely to work together in cellular processes. So the random walk's transition probability mimics how biological signals or functional associations "flow" between genes—if gene A is tightly co-expressed with gene B, studying A naturally leads you to B, just like the walk would jump from A to B frequently.
To build this matrix, you'll normalize each row of the co-expression matrix by the gene's weighted degree d—this ensures each row sums to 1 (a requirement for valid transition probabilities).
步骤4: 设置吸收态子网络 (疑问Q2)
- You're taking the initial transition matrix and modifying it (via formula 3) to make your 15-gene target subnetwork into absorbing states (transition probability of 1 to themselves).
- Q2: When does the second condition in formula 3 give a probability of 0? You thought non-subnetwork nodes should retain their
P_ijvalues.
Absorbing states mean once the random walk reaches a node in your target subnetwork, it can never leave it (soP'_ii = 1for alliin the subnetwork).
The second condition in formula 3 is almost certainly: if i is a subnetwork node and j is NOT a subnetwork node, then P'_ij = 0. This prevents the walk from leaving the target pathway once it's there.
You're right that non-subnetwork nodes keep their original P_ij values for transitions to other non-subnetwork nodes. The only change is that when a non-subnetwork node transitions to a subnetwork node, the next step will be absorbed. This setup lets us measure which external genes are most likely to "flow into" the target pathway—these are the top candidates for expanding the pathway.
步骤6+: 游走概率与关联函数的逻辑
You're confused about dividing the joint probability of visiting edge E(i,j) by the probability of a walk starting at x with length L. Here's the intuitive breakdown:
- The joint probability of visiting
E(i,j)is the total frequency that this edge is traversed during random walks across the network. - The probability of a walk starting at
xwith lengthLis the distribution of where you end up (or the total probability mass of all walks starting atxoverLsteps).
Dividing these two is a normalization step to calculate a conditional association score: it tells you, given that we start at gene x, how likely are we to traverse edge E(i,j) (and thus connect x to the target pathway). Genes with higher scores are more strongly linked to your target pathway, because walks starting from them frequently lead into the pathway.
实现与学习建议
Here are practical tips to help you grasp this and implement it in R or Python:
Intuition-Building Exercises
- Small Network Simulation: Draw a tiny network (e.g., 10 genes, 5 in your target subnetwork) on paper. Manually calculate transition probabilities, mark absorbing states, and simulate 5-10 random walks. This will make the absorption and probability flow tangible.
R/Python Implementation Steps
- Build Co-Expression Matrix:
- In R: Use
cor(your_matrix, method = "pearson") - In Python: Use
numpy.corrcoef(your_matrix.T)(note: transpose since numpy expects samples as rows)
- In R: Use
- Calculate Weighted Degree: Sum each row of the co-expression matrix (rows = genes).
- Build Transition Matrix: Normalize each row by its weighted degree (so each row sums to 1).
- Set Absorbing States:
- Create a boolean vector marking which genes are in your target subnetwork.
- For each absorbing gene
i, set all values in rowito 0, then setP[i, i] = 1.
- Simulate Random Walks:
- For small networks: Use a loop to sample the next node based on the transition probabilities, track visited edges/nodes.
- For large networks: Use matrix exponentiation (
P ** Lin Python with numpy, or%^%in R withexpmpackage) to compute the probability distribution afterLsteps—this is faster than simulating individual walks.
- Compute Association Scores: Divide the edge visit probabilities by the starting walk probabilities to get normalized scores for each candidate gene.
Learning Resources
- Focus on bioinformatics-specific random walk tutorials (avoid pure stats textbooks unless you need to dive deeper into Markov chain theory). Many university bioinformatics courses have lecture notes that tie these methods directly to gene network analysis.
- Explore the
igraphpackage (R/Python) — it has built-in functions for random walks and Markov chain calculations, with examples that map to biological networks.
内容的提问来源于stack exchange,提问作者J. Doe

