Seurat -- Cluster the cells --第一部分

news2024/10/6 12:33:10

文章目录

    • brief
    • KNN(k-nearest neighbor)简介部分
    • SNN(shared nearest neighbor)简介部分
    • Annoy算法理解
    • Jaccard index
    • Seurat进行聚类的步骤
    • 可视化部分
    • subcluster之间的marker gene
    • 具体参数

brief

seurat 官方教程的解释如下:
在这里插入图片描述

  • 大概是第一步利用PCA降维结果作为input,计算euclidean distance从而构建KNN graph,然后根据两两细胞间的Jaccard similarity 重新构建SNN graph。
  • 第二步 partition this graph

==================================================================================

KNN(k-nearest neighbor)简介部分

在这里插入图片描述

  • 上面的描述可以认为是KNN的原理或者思想。
  • 我们需要关注的是如何快速从数据集中找到和目标样本最接近的K个样本?
    如果数据量很小,我们可以根据距离度量公式计算一个距离度量表,然后排序后筛选K个最近邻。如果数据量很大,再计算每个数据点的距离会很耗费资源,所以需要特殊的实现方法以节省资源,比如KDtree,Annoy等。

================================================================================

SNN(shared nearest neighbor)简介部分

下面的内容来自博客:
原文链接:https://blog.csdn.net/qq_40793975/article/details/84817018

共享最近邻相似度(Shared Nearest Neighbour,简称SNN)基于这样一个事实,如果两个点都与一些相同的点相似,则即使直接的相似性度量不能指出,他们也相似,更具体地说,只要两个对象都在对方的最近邻表中,SNN相似度就是他们共享的近邻个数,计算过程如下图所示。需要注意的是,这里用来获取最近邻表时所使用的邻近性度量可以是任何有意义的相似性或相异性度量。

在这里插入图片描述

下面通过一个实例进行直观的说明,假设两个对象A、B(黑色的)都有8个最近邻,且这两个对象之间相互包含,这些最近邻中有4个(灰色的)是A、B共享的,因此这两个对象之间的SNN相似度为4。
在这里插入图片描述
对象之间SNN相似度的相似度图称作SNN相似度图(SNN similarity graph),由于许多对象之间的SNN相似度为0,因此SNN相似度图非常稀疏。
  SNN相似度解决了使用直接相似度时出现的一些问题,首先,他可以处理如下情况,一个对象碰巧与另一个对象相对较近,但是两者分属于不同的簇,由于在这种情况下,两个对象一般不包含许多的共享近邻,因此他们的SNN密度很低。另一种情况是,当处理不同密度的簇时,由于一对对象之间的相似度不依赖于两者之间的距离,而是两者的共享近邻,因此SNN密度会根据簇的密度进行合适的伸缩。

=================================================================================

Annoy算法理解

这里推荐一篇知乎。
个人认为这里只需要简单知道 what’s that ? what to do ?

  • 是什么?
    一种数据的存储和搜索方法
  • 干什么?
    利用特殊的数据储存和搜索方法实现快速的返回 Top K 相似的数据
    =================================================================================

Jaccard index

下面的内容来自百度百科:
Jaccard index , 又称为Jaccard相似系数(Jaccard similarity coefficient)用于比较有限样本集之间的相似性与差异性。Jaccard系数值越大,样本相似度越高。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

Seurat进行聚类的步骤

pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)

================================================================================

可视化部分

  • UMAP非线性降维
# If you haven't installed UMAP, you can do so via reticulate::py_install(packages =
# 'umap-learn')
pbmc <- RunUMAP(pbmc, dims = 1:10)
# note that you can set `label = TRUE` or use the LabelClusters function to help label
# individual clusters
DimPlot(pbmc, reduction = "umap")
  • marker gene 可视化部分
# 小提琴图
VlnPlot(pbmc, features = c("MS4A1", "CD79A"))
# 山脊图
RidgePlot(object = pbmc_small, features = 'PC_1')
# 散点图
CellScatter(object = pbmc_small, cell1 = 'ATAGGAGAAACAGA', cell2 = 'CATCAGGATGCACA')
# 气泡图
cd_genes <- c("CD247", "CD3E", "CD9")
DotPlot(object = pbmc_small, features = cd_genes)
# feature plot
FeaturePlot(pbmc, features = c("MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP",
    "CD8A"))

subcluster之间的marker gene

# find all markers of cluster 2
cluster2.markers <- FindMarkers(pbmc, ident.1 = 2, min.pct = 0.25)
head(cluster2.markers, n = 5)

# find all markers distinguishing cluster 5 from clusters 0 and 3
cluster5.markers <- FindMarkers(pbmc, ident.1 = 5, ident.2 = c(0, 3), min.pct = 0.25)
head(cluster5.markers, n = 5)

# find markers for every cluster compared to all remaining cells, report only the positive
# ones
pbmc.markers <- FindAllMarkers(pbmc, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
pbmc.markers %>%
    group_by(cluster) %>%
    slice_max(n = 2, order_by = avg_log2FC)

# Seurat has several tests for differential expression which can be set with the test.use parameter
# For example, the ROC test returns the ‘classification power’ for any individual marker (ranging from 0 - random, to 1 - perfect)
cluster0.markers <- FindMarkers(pbmc, ident.1 = 0, logfc.threshold = 0.25, test.use = "roc", only.pos = TRUE)

=================================================================================

具体参数

在这里插入图片描述

  • k.param
    Defines k for the k-nearest neighbor algorithm
    这里最想说的是K为什么不设为奇数而是设为偶数~~

  • return.neighbor
    Return result as Neighbor object. Not used with distance matrix input.

  • compute.SNN
    also compute the shared nearest neighbor graph

  • prune.SNN
    Sets the cutoff for acceptable Jaccard index when computing the neighborhood overlap for the SNN construction. Any edges with values less than or equal to this will be set to 0 and removed from the SNN graph. Essentially sets the stringency of pruning (0 — no pruning, 1 — prune everything).

  • nn.method
    Method for nearest neighbor finding. Options include: rann, annoy

  • n.trees
    More trees gives higher precision when using annoy approximate nearest neighbor search

  • annoy.metric
    Distance metric for annoy. Options include: euclidean, cosine, manhattan, and hamming

  • nn.eps
    Error bound when performing nearest neighbor seach using RANN; default of 0.0 implies exact nearest neighbor search

  • verbose
    Whether or not to print output to the console

  • force.recalc
    Force recalculation of (S)NN.

  • l2.norm
    Take L2Norm of the data

  • cache.index
    Include cached index in returned Neighbor object (only relevant if return.neighbor = TRUE)

  • index
    Precomputed index. Useful if querying new data against existing index to avoid recomputing.

  • features
    Features to use as input for building the (S)NN; used only when dims is NULL

  • reduction
    Reduction to use as input for building the (S)NN

  • dims
    Dimensions of reduction to use as input

  • assay
    Assay to use in construction of (S)NN; used only when dims is NULL

  • do.plot
    Plot SNN graph on tSNE coordinates

  • graph.name
    Optional naming parameter for stored (S)NN graph (or Neighbor object, if return.neighbor = TRUE). Default is assay.name_(s)nn. To store both the neighbor graph and the shared nearest neighbor (SNN) graph, you must supply a vector containing two names to the graph.name parameter. The first element in the vector will be used to store the nearest neighbor (NN) graph, and the second element used to store the SNN graph. If only one name is supplied, only the NN graph is stored

在这里插入图片描述

  • modularity.fxn
    Modularity function (1 = standard; 2 = alternative).

  • initial.membership, node.sizes
    Parameters to pass to the Python leidenalg function.

  • resolution
    Value of the resolution parameter, use a value above (below) 1.0 if you want to obtain a larger (smaller) number of communities.

  • method
    Method for running leiden (defaults to matrix which is fast for small datasets). Enable method = “igraph” to avoid casting large data to a dense matrix.

  • algorithm
    Algorithm for modularity optimization (1 = original Louvain algorithm; 2 = Louvain algorithm with multilevel refinement; 3 = SLM algorithm; 4 = Leiden algorithm). Leiden requires the leidenalg python.

  • n.start
    Number of random starts.

  • n.iter
    Maximal number of iterations per random start.

  • random.seed
    Seed of the random number generator.

  • group.singletons
    Group singletons into nearest cluster. If FALSE, assign all singletons to a “singleton” group

  • temp.file.location
    Directory where intermediate files will be written. Specify the ABSOLUTE path.

  • edge.file.name
    Edge file to use as input for modularity optimizer jar.

  • verbose
    Print output

  • graph.name
    Name of graph to use for the clustering algorithm

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/512963.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Hash碰撞

Hash碰撞 什么是Hash碰撞 Hash碰撞是指两个不同的输入值&#xff0c;经过哈希函数的处理后&#xff0c;得到相同的输出值&#xff0c;这种情况被称之为哈希碰撞。 例如&#xff1a;两个不同的对象&#xff08;object1和object2的值&#xff09;经过Hash函数计算后的&#xf…

科思转债上市价格预测

科思转债 基本信息 转债名称&#xff1a;科思转债&#xff0c;评级&#xff1a;AA-&#xff0c;发行规模&#xff1a;7.249178亿元。 正股名称&#xff1a;科思股份&#xff0c;今日收盘价&#xff1a;67.1元&#xff0c;转股价格&#xff1a;53.03元。 当前转股价值 转债面值…

【进程间通信 之 通信的建立】

目录&#xff1a; 前言进程间通信的目的进程间通信的方式管道1.匿名管道简单示例1 - 消息传输五个特性四种场景简单示例2 - 进程控制对管道的深入理解 2.命名管道简单示例3 -- 不相关进程间通信 system V共享内存简单示例4 - 通知事件消息传输 总结 前言 打怪升级&#xff1a;…

后摩尔时代 , 从有源相控阵天线走向天线阵列微系统

本文围绕高分辨率对地微波成像雷达对天线高效率、低剖面和轻量化的迫切需求 , 分析研究了有源阵列天线的特点、现状、趋势和瓶颈技术 , 针对对集成电路后摩尔时代的发展预测 , 提出了天线阵列微系统概念、内涵和若干前沿科学技术问题 , 分析讨论了天线阵列微系统所涉及的微纳尺…

完全集成的云备份和还原服务——NetApp Cloud Backup

完全集成的云备份和还原服务 NetApp Cloud Backup 提供无缝且经济高效的备份和还原功能&#xff0c;用于保护和归档云端和内部 ONTAP 数据。 为什么选择 NetApp Cloud Backup&#xff1f; 可轻松保护云端和内部 ONTAP 数据 NetApp Cloud Backup 提供无缝且经济高效的备份和还…

科大讯飞星火认知大模型怎么样?

“鉴于SparkDesk服务目前处于内部用户体验阶段&#xff0c;所有与SparkDesk相关的交互内容、技术参数等信息均被视为保密信息。您了解并同意&#xff0c;且有责任对这些保密信息严格保密&#xff0c;您不得以任何方式&#xff08;包括但不限于截图、录屏、拍照等&#xff09;披…

Linux shell编程常用命令(sort排序 uniq重复行 set +-x调试脚本 tr压缩替换字符 cut切片)

sort命令 排序 以行为单位对文件内容进行排序&#xff0c;也可以根据不同的数据类型来排序 比较原则是从首字符向后&#xff0c;依次按ASCII码值进行比较&#xff0c;最后将他们按升序输出。 sort [选项] 参数 cat file | sort 选项-n 按照数字进行排序 -r 反向排序 -u 等同于u…

【源码解析】SpringBoot整合AOP原理解析

AOP介绍 AOP&#xff08;Aspect Oriented Programming&#xff09;是基于切面编程的&#xff0c;可无侵入的在原本功能的切面层添加自定义代码&#xff0c;一般用于日志收集、权限认证等场景。 AOP基本概念 通知&#xff08;Advice&#xff09;: AOP 框架中的增强处理。通知…

L1:提示工程的关键原则

提示工程指南&#xff1a;关键原则 一、 环境配置 chatgpt使用有诸多限制&#xff0c;所以采用国产模型来代替&#xff0c;加载开源的chatGLM模型&#xff0c;使用ChatGLM-6b的INT8版本。 chatGLM6b在LLM匿名竞技场中的排名&#xff1a; import os import torch import war…

[学习笔记] [机器学习] 4. [下]线性回归(正规方程、梯度下降、岭回归)

6. 梯度下降和正规方程的对比 问题梯度下降正规方程学习率需要选择合适的学习率不需要求解特点需要多次迭代求解一次运算得出线性问题可以解决可以解决非线性问题可以解决不可以解决时间复杂度难以直接给出的&#xff08;受到初始值、学习率、迭代次数等多种因素的影响&#x…

学生如何使用chatGTP提升学习能力?

短短两三个月&#xff0c;ChatGPT炸圈范围越来越大&#xff0c;很快就从科技圈来到了教育界。前段时间&#xff0c;北密歇根大学的哲学教授Antony Aumann在批改论文的过程中发现一篇论文好到令人感到震惊。这篇论文逻辑严谨&#xff0c;措辞得当&#xff0c;结构清晰&#xff0…

《JavaEE初阶》Tomcat

《JavaEE初阶》Tomcat 文章目录 《JavaEE初阶》TomcatTomcat是什么下载Tomcat简单介绍Tomcat的文件使用tomcat部署静态页面启动tomcat 部署代码: Tomcat是什么 在学习tomcat之前,我们已经学习了HTTP协议,我们知道HTTP协议是应用层协议. HTTP的客户端是我们的网页和浏览器,而H…

MySQL新增时实现新增或更新操作

MySQL新增时数据重复则更新或不操作&#xff0c;不重复则新增 应用场景实现方案1. REPLACE INTO 语句&#xff1a;2. INSERT INTO ... ON DUPLICATE KEY UPDATE 语句结合事务&#xff1a;3. INSERT INTO ... SELECT ... FROM ... ON DUPLICATE KEY UPDATE 语句&#xff1a;4. 根…

Kyligence一站式数字化建设的新指标

1.数字化时代中小企业的痛点与难点 数字化时代&#xff0c;众多领先企业纷纷利用数字化技术&#xff0c;实现业务精细化运营和降本增效&#xff0c;从而有效提升企业的盈利水平和竞争力。其中最重要的手段就是业务过程数据指标化&#xff0c;通过对指标的定义、监控、分析和洞…

【容器化应用程序设计和开发】2.5 容器化应用程序的安全性和合规性考虑

往期回顾&#xff1a; 第一章&#xff1a;【云原生概念和技术】 第二章&#xff1a;2.1 容器化基础知识和Docker容器 第二章&#xff1a;2.2 Dockerfile 的编写和最佳实践 第二章&#xff1a;2.3 容器编排和Kubernetes调度 第二章&#xff1a;2.4 容器网络和存储 2.5 容器…

python 3.9 安装wordcloud

1. pip install wordcloud 安装不成功&#xff0c;或者安装成功&#xff0c;python ide中不能用。 2. 去网上单独下载适合3.9 的安装包 &#xff0c;网址&#xff1a;https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud 3.选择版本 wordcloud-1.8.1-cp39-cp39-win_amd64…

企业布局新媒体矩阵,如何走得更远?

企业搭建新媒体矩阵有很多好处——扩大品牌声量、丰富内容形式、提高宣传效率、降低运营风险、节省广告成本...... 即便如此&#xff0c;能真正让新媒体矩阵产生如此效果的企业&#xff0c;却是凤毛麟角。 更多的企业&#xff0c;往往冒然入场&#xff0c;也黯然离场&#xff0…

html实现经典坦克大战小游戏

文章目录 1.设计来源1.1 游戏主界面1.2 游戏界面 2.效果和源码2.1 动态效果2.2 源代码 源码下载 作者&#xff1a;xcLeigh 文章地址&#xff1a;https://blog.csdn.net/weixin_43151418/article/details/130617759 html实现经典坦克大战小游戏 ,这是一款很老的游戏&#xff0c;…

矩阵计算(求导)

亚导数 当函数不可微时&#xff0c;不可计算出其普通的导数&#xff0c;此时便需要引入亚导数Example: 函数 y ∣ x ∣ y|x| y∣x∣ 不可微&#xff0c;其亚导数为 ∂ ∣ x ∣ ∂ x { 1 , x > 0 − 1 , x < 0 a , x 0 , a ∈ [ 0 , 1 ] \frac{\partial |x|}{\parti…

KDZD绝缘子表面电导盐密度测试仪

一、简介 智能电导盐密测试仪&#xff0c;也称为直读式等值盐密度测试仪&#xff0c;专为测试智能电导盐密度而设计。系统内置智能电导盐密度计算公式&#xff0c;读数直观。 人机交互采用真彩TFT液晶屏&#xff0c;操作简单&#xff0c;测试参数和结果一目了然。仪器自带微型打…