Bayesian generalized linear model (GLM) | 贝叶斯广义线性回归实例

学习GLM的时候在网上找不到比较通俗易懂的教程。这里以一个实例应用来介绍GLM。

We used a Bayesian generalized linear model (GLM) to assign every gene to one or more cell populations, as previously described (Zeisel et al., 2015).

在单细胞RNA-seq的分析中,可以用GLM来寻找marker。

贝叶斯 + 广义 + 线性回归

线性回归:这个最基础,大部分人应该都知道。为什么找marker问题可以转化为线性回归问题?我们可以把每一个基因的表达当作自变量,把最终的类别作为因变量,拟合线性模型,然后根据系数的分布来得到marker。

广义:因变量(响应变量)可以服从多种分布(思考:为什么下文要用负二项分布);

贝叶斯:是一种新的思维方式,所有的系数都有自己的分布。

The GLM models the measured gene expression of a cell as realizations of a Negative Binomial probability distribution whose mean is determined by a linear combination of K predictors xi with coefficient bi.

For each cell, the outcome and predictors are known and the aim is to determine the posterior probability distributions of the coefficients.

As predictors, we use a continuous Baseline predictor and a categorical Cell Type predictor. The Baseline predictor value is the cell’s molecule count normalized to the average molecule count of all cells and takes account of the fact that we expect every gene to have a baseline expression proportional to the total number of expressed molecules within a particular cell. While the Cell Type predictor is set to 1 for the cluster BackSPIN assignation of the cell, and 0 for the other classes. From the definition of the model it follows that the coefficient bk for a Cell Type predictor xk can be interpreted as the additional number of molecules of a particular gene that are present as a result of the cell being of cell type k. A more detailed description of the model, including explanation of the prior probabilities used for the fitting as well as the full source code of the model, is provided elsewhere (Zeisel et al., 2015). The Stan (http://mc-stan.org) source is copied below for completeness:

data {
int < lower = 0 > N; # number of outcomes
int < lower = 0 > K; # number of predictors
matrix < lower = 0 > [N,K] x; # predictor matrix
int y[N]; # outcomes
}
parameters {
vector < lower = 1 > [K] beta; # coefficients
real < lower = 0.001 > r; # overdispersion
}
model {
vector < lower = 0.001 > [N] mu;
vector < lower = 1.001 > [N] rv;
# priors
r !cauchy(0, 1);
beta !pareto(1, 1.5);
# vectorize the overdispersion
for (n in 1:N) {
rv[n] < - square(r + 1) - 1;
}
# regression
mu < - x * (beta - 1) + 0.001;
y !neg_binomial(mu ./ rv, 1 / rv[1]);
}

To determine which genes are higher than basal expression in each population we compared the posterior probability distributions of the Baseline coefficient and the Cell Type coefficient. A gene was considered as marking a cell population if (1) its cell-typespecific coefficient exceeded the Baseline coefficient with 99.8% (95% for the mouse adult) posterior probability, and (2) the median of its posterior distribution did not fall below a threshold q set to 35% of the median posterior probability of the highest expressing group, and (3) the median of the highest-expressing cell type was greater than 0.4. For every gene this corresponds to a binary pattern (0 if the conditions are not met and 1 if they are), and genes can therefore be grouped according to their binarized expression patterns.

We use those binarized patterns to call transcription factor specificity. Our definition of a transcription factor gene was based of annotations provided by the merged annotation of PANTHER GO (Mi et al., 2013) and FANTOM5 (Okazaki et al., 2002), this list was further curated and missing genes and occasional misannotations corrected.

The feature selection procedure is based on the largest difference between the observed coefficient of variation (CV) and the predicted CV (estimated by a non-linear noise model learned from the data) See Figure S1C. In particular, Support Vector Regression (SVR, Smola and Vapnik, 1997) was used for this purpose (scikit-learn python implementation, default parameters with gamma = 0.06; Pedregosa et al., 2011).

特征选取:寻找观察CV值和预测CV值之间的最大差异。

SVR支持向量回归

Similarities between clusters within a species were summarized using a Pearson’s correlation coefficient calculated on the binarized matrix (Figures 1C and 1D).

参考:从线性模型到广义线性模型(1)——模型假设篇

原文地址:https://www.cnblogs.com/leezx/p/8620519.html

时间: 2024-08-07 07:31:35

Bayesian generalized linear model (GLM) | 贝叶斯广义线性回归实例的相关文章

Generalized Linear Model

最近一直在回顾linear regression model和logistic regression model,但对其中的一些问题都很疑惑不解,知道我看到广义线性模型即Generalized Linear Model后才恍然大悟原来这些模型是这样推导的,在这里与诸位分享一下,具体更多细节可以参考Andrew Ng的课程. 一.指数分布 广义线性模型都是由指数分布出发来推导的,所以在介绍GLM之前先讲讲什么是指数分布.指数分布的形式如下: η是参数,T(y)是y的充分统计量,即T(y)可以完全表

朴素贝叶斯算法 &amp; 应用实例

转载请注明出处:http://www.cnblogs.com/marc01in/p/4775440.html 引 和师弟师妹聊天时经常提及,若有志于从事数据挖掘.机器学习方面的工作,在大学阶段就要把基础知识都带上. 机器学习在大数据浪潮中逐渐展示她的魅力,其实<概率论>.<微积分>.<线性代数>.<运筹学>.<信息论>等几门课程算是前置课程,当然要转化为工程应用的话,编程技能也是需要的,而作为信息管理专业的同学,对于信息的理解.数据的敏感都是很好

朴素贝叶斯算法的实例

贝叶斯的应用 过滤垃圾邮件 贝叶斯分类器的著名的应用就是垃圾邮件过滤了,这方面推荐想详细了解的可以去看看<黑客与画家>或是<数学之美>中对应的章节,贝叶斯的基础实现看这里 数据集 两个文件夹,分别是正常邮件和垃圾邮件,其中各有25封邮件 测试方法 从50封邮件中随机选取10封做为测试数据 实现细节 1.首先我们需要将文本转成我们需要的向量的样子,这里需要使用一点正则表达式2.由于采取交叉验证的方式,随机过程会导致每次的结果不尽相同 1 #coding=utf-8 2 from nu

朴素贝叶斯python小样本实例

朴素贝叶斯优点:在数据较少的情况下仍然有效,可以处理多类别问题缺点:对于输入数据的准备方式较为敏感适用数据类型:标称型数据朴素贝叶斯决策理论的核心思想:选择具有最高概率的决策朴素贝叶斯的一般过程(1)收集数据:可以使用任何方法.(2)准备数据:需要数值型或者布尔型数据.(3)分析数据:有大量特征时,回值特征作用不大,此时使用直方图效果更好(4)训练算法:计算不同的独立也正的条件概率(5)测试算法:计算错误率(6)使用算法:一个常见的朴素贝叶斯应用是文档分类.可以在任意的分类场景中使用朴素贝叶斯分

朴素贝叶斯基础概念-实例

假设一个镇里有60%男性和40%女性.女性穿裤子的人数和穿裙子的人数一样,所有男性都穿裤子(正常男性都穿裙子).一个人在远处随机看到了一个穿裤子的人,预测这个人是男生还是女生?为什么? A:数女性事件,B:是穿的是裤子的事件 P(A)是看到是女性的概率,在这里是40% P(A~)是看到是男性的概率,在这里是60% P(B|A)是女性穿裤子的概率,在这里是50% P(B|A~)是男性穿裤子的概率,在这里是100% P(B)是穿裤子的概率,P(B) = P(B|A)P(A) + P(B|A~)P(A

Bayesian Statistics for Genetics | 贝叶斯与遗传学

Common sense reduced to computation - Pierre-Simon, marquis de Laplace (1749–1827) Inventor of Bayesian inference 贝叶斯方法的逻辑十分接近人脑的思维:人脑的优势不是计算,在纯数值计算方面,可以说几十年前的计算器就已经超过人脑了. 人脑的核心能力在于推理,而记忆在推理中扮演了重要的角色,我们都是基于已知的常识来做出推理.贝叶斯推断也是如此,先验就是常识,在我们有了新的观测数据后,就可以

贝叶斯思想——李文哲老师听课笔记

ML-最大似然估计 MAP-最大后验估计 贝叶斯估计 三者的关系及区别 一.机器学习 核心思想是从past experience中学习出规则,从而对新的事物进行预测.对于监督学习来说,有用的样本数目越多,训练越准确. 用下图来表示机器学习的过程及包含的知识: 简单来说就是: 首先要定义我们的假设空间(Model assumption):如线性分类,线性回归,逻辑回归,SVM,深度学习网络等. 如何衡量我们学出来的模型的好坏?定义损失函数(目标函数),lost function,如square l

从贝叶斯方法谈到贝叶斯网络

0 引言 事实上,介绍贝叶斯定理.贝叶斯方法.贝叶斯推断的资料.书籍不少,比如<数理统计学简史>,以及<统计决策论及贝叶斯分析 James O.Berger著>等等,然介绍贝叶斯网络的中文资料则非常少,中文书籍总共也没几本,有的多是英文资料,但初学者一上来就扔给他一堆英文论文,因无基础和语言的障碍而读得异常吃力导致无法继续读下去则是非常可惜的(当然,有了一定的基础后,便可阅读更多的英文资料). 11月9日上午,机器学习班第9次课,邹博讲贝叶斯网络,其帮助大家提炼了贝叶斯网络的几个关

转载-- 从贝叶斯方法谈到贝叶斯网络

从贝叶斯方法谈到贝叶斯网络 0 引言 事实上,介绍贝叶斯定理.贝叶斯方法.贝叶斯推断的资料.书籍不少,比如<数理统计学简史>,以及<统计决策论及贝叶斯分析 James O.Berger著>等等,然介绍贝叶斯网络的中文资料则非常少,中文书籍总共也没几本,有的多是英文资料,但初学者一上来就扔给他一堆英文论文,因无基础和语言的障碍而读得异常吃力导致无法继续读下去则是非常可惜的(当然,有了一定的基础后,便可阅读更多的英文资料). 11月9日上午,机器学习班 第9次课,邹讲贝叶斯网络,其帮助