单细胞数据高级分析之初步降维和聚类 | Dimensionality reduction | Clustering

Dimensionality reduction.

Throughout the manuscript we use diffusion maps, a non-linear dimensionality reduction technique37. We calculate a cell-to-cell distance matrix using 1 - Pearson correlation and use the diffuse function of the diffusionMap R package with default parameters to obtain the first 50 DMCs. To determine the significant DMCs, we look at the reduction of eigenvalues associated with DMCs. We determine all dimensions with an eigenvalue of at least 4% relative to the sum of the first 50 eigenvalues as significant, and scale all dimensions to have mean 0 and standard deviation of 1.

Initial clustering of all cells.

To identify contaminating cell populations and assess  overall heterogeneity in the data, we clustered all single cells. We first combined all Drop-seq samples and normalized the data (21,566 cells, 10,791 protein-coding genes detected in at least 3 cells and mean UMI at least 0.005) using regularized negative binomial regression as outlined above (correcting for sequencing depth related factors and cell cycle). We identified 731 highly variable genes; that is, genes for which the z-scored standard deviation was at least 1. We used the variable genes to perform dimensionality reduction using diffusion maps as outlined above (with relative eigenvalue cutoff of 2%), which returned 10 significant dimensions.

For clustering we used a modularity optimization algorithm that finds community structure in the data with Jaccard similarities (neighbourhood size 9, Euclidean distance in diffusion map coordinates) as edge weights between cells38. With the goal of overclustering the data to identify rare populations, the small neighbourhood size resulted in 15 clusters, of which two were clearly separated from the rest and expressed marker genes expected from contaminating cells (Neurod6 from excitatory neurons, Igfbp7 from epithelial cells). These cells represent rare cellular contaminants in the original sample (2.6% and 1%), and were excluded from further analysis, leaving 20,788 cells.

# for clustering

dim.red <- function(expr, max.dim, ev.red.th, plot.title=NA, do.scale.result=FALSE) {
  cat(‘Dimensionality reduction via diffusion maps using‘, nrow(expr), ‘genes and‘, ncol(expr), ‘cells\n‘)
  if (sum(is.na(expr)) > 0) {
    dmat <- 1 - cor(expr, use = ‘pairwise.complete.obs‘)
  } else {
    dmat <- 1 - cor(expr)
  }

  max.dim <- min(max.dim, nrow(dmat)/2)
  dmap <- diffuse(dmat, neigen=max.dim, maxdim=max.dim)
  ev <- dmap$eigenvals

  ev.red <- ev/sum(ev)
  evdim <- rev(which(ev.red > ev.red.th))[1]

  if (is.character(plot.title)) {
    plot(ev, ylim=c(0, max(ev)), main = plot.title)
    abline(v=evdim + 0.5, col=‘blue‘)
  }

  evdim <- max(2, evdim, na.rm=TRUE)
  cat(‘Using‘, evdim, ‘significant DM coordinates\n‘)

  colnames(dmap$X) <- paste0(‘DMC‘, 1:ncol(dmap$X))
  res <- dmap$X[, 1:evdim]
  if (do.scale.result) {
    res <- scale(dmap$X[, 1:evdim])
  }
  return(res)
}

# jaccard similarity
# rows in ‘mat‘ are cells
jacc.sim <- function(mat, k) {
  # generate a sparse nearest neighbor matrix
  nn.indices <- get.knn(mat, k)$nn.index
  j <- as.numeric(t(nn.indices))
  i <- ((1:length(j))-1) %/% k + 1
  nn.mat <- sparseMatrix(i=i, j=j, x=1)
  rm(nn.indices, i, j)
  # turn nn matrix into SNN matrix and then into Jaccard similarity
  snn <- nn.mat %*% t(nn.mat)
  snn.summary <- summary(snn)
  snn <- sparseMatrix(i=snn.summary$i, j=snn.summary$j, x=snn.summary$x/(2*k-snn.summary$x))
  rm(snn.summary)
  return(snn)
}

cluster.the.data.simple <- function(cm, expr, k, sel.g=NA, min.mean=0.001,
                                    min.cells=3, z.th=1, ev.red.th=0.02, seed=NULL,
                                    max.dim=50) {
  if (all(is.na(sel.g))) {
    # no genes specified, use most variable genes
    goi <- rownames(expr)[apply(cm[rownames(expr), ]>0, 1, sum) >= min.cells & apply(cm[rownames(expr), ], 1, mean) >= min.mean]
    sspr <- apply(expr[goi, ]^2, 1, sum)
    sel.g <- goi[scale(sqrt(sspr)) > z.th]
  }
  cat(sprintf(‘Selected %d variable genes\n‘, length(sel.g)))
  sel.g <- intersect(sel.g, rownames(expr))
  cat(sprintf(‘%d of these are in expression matrix.\n‘, length(sel.g)))

  if (is.numeric(seed)) {
    set.seed(seed)
  }

  dm <- dim.red(expr[sel.g, ], max.dim, ev.red.th, do.scale.result = TRUE)

  sim.mat <- jacc.sim(dm, k)

  gr <- graph_from_adjacency_matrix(sim.mat, mode=‘undirected‘, weighted=TRUE, diag=FALSE)
  cl <- as.numeric(membership(cluster_louvain(gr)))

  results <- list()
  results$dm <- dm
  results$clustering <- cl
  results$sel.g <- sel.g
  results$sim.mat <- sim.mat
  results$gr <- gr
  cat(‘Clustering table\n‘)
  print(table(results$clustering))
  return(results)
}

  

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

时间: 2024-07-29 13:19:36

单细胞数据高级分析之初步降维和聚类 | Dimensionality reduction | Clustering的相关文章

大数据之高级分析如何从天气中获取洞察力

自然灾害似乎是不可避免的,让我们在大自然的手中感到脆弱.考虑到今天围绕着我们的所有数据和技术,这怎么可能呢?专家能否在预测方面做得更好,甚至试图避免更多自然灾害或更有效地减少资源损失? 答案是肯定和否定.有时我们知道龙卷风会袭来,我们无法防止这种情况造成的损失.我们知道洪水会因飓风而发生,当地人可以努力有效地减少损失.但它们通常不能防止发生损害.我们知道可能会发生冰暴和冰雹风暴,但我们不能总是防止对房屋或汽车造成损害. 虽然预测自然力量可能很困难,但我们可以使用机器智能从这些情况中有效地捕获更多

全基因组重测序基础及高级分析知识汇总

全基因组重测序基础及高级分析知识汇总 oddxix 已关注 2018.09.20 17:04 字数 11355 阅读 212评论 0喜欢 6 转自:http://www.360doc.com/content/18/0208/11/19913717_728563847.shtml 全基因组重测序是通过对已有参考序列(Reference Sequence)的物种的不同个体进行基因组测序,并以此为基础进行个体或群体水平的遗传差异性分析.通过全基因组重测序,研究者可以找到大量的单核苷酸多态性位点(SNP

一站式大数据敏捷分析平台

OpenFEA是一站式大数据敏捷分析系统,融合了内存计算.集群运算.机器学习.交互分析.可视化分析等技术,涵盖数据收集.数据探索.构建模型.模型发布等功能,分析性能卓越,使用简便,无需复杂编程即可快速实现大数据分析,助力数据分析师激扬数据,塑造业务标杆.          数据收集         OpenFEA能够融合更多类型的数据来进行运算,支持关系型数据源. Hadoop数据源.数据文件.第三方数据源. 支持数据源与接口/格式的双向自定义机制.表示各种复杂结构或LOAD和STORE各类数据

第二篇:智能电网(Smart Grid)中的数据工程与大数据案例分析

前言 上篇文章中讲到,在智能电网的控制与管理侧中,数据的分析和挖掘.可视化等工作属于核心环节.除此之外,二次侧中需要对数据进行采集,数据共享平台的搭建显然也涉及到数据的管理.那么在智能电网领域中,数据工程到底是如何实施的呢? 本文将以IBM的Itelligent Utility Network产品为例阐述智能电网中的数据工程,它是IBM声称传统电网向智能电网转变的整体方案(看过上篇文章的童鞋想必会清楚这样的说法是片面狭隘的,它只能算是智能电网中的数据工程). 另一方面,如今是一个数据爆炸的时代,

通过WireShark抓取iOS联网数据实例分析

本文转载至http://blog.csdn.net/lixing333/article/details/7782539 iosiphone网络filter工具 我在另外一篇博客里,介绍了一款比Wireshark更轻量.更好用的软件:Charles: http://blog.csdn.net/lixing333/article/details/42776187 今天闲的没事干,想试着分析iOS应用的网络数据传输方式.以前就曾经想过这么做,但是由于无法得到iPhone的联网数据,一直没成功.今天尝试

基于Jpcap的TCP/IP数据包分析(一)

基于Jpcap的TCP/IP数据包分析原作:赵新辉目 录第一章 以太网的结构和TCP/IP1.1 以太网的结构1.1.1 基于网络架构的以太网1.1.2 以太网的数据交换1.1.3 以太网帧的结构1.2 IP数据报的构成 1.2.1 IP地址1.2.2 路由1.2.3 IP数据报的构成1.2.4 其他报文结构1.3 TCP/UDP1.3.1 TCP/UDP的作用1.3.2 TCP和UDP报文的结构第二章 Jpcap类库2.1 Jpcap的使用2.1.1 Jpcap的运行环境的安装2.1.2 Jp

北风网 零基础到数据(大数据)分析专家-首席分析师

详情请交流  QQ  709639943 00.北风网 零基础到数据(大数据)分析专家-首席分析师 00.快速上手JMeter 00.Jmeter 00.2017年Java web开发工程师成长之路 00.R语言速成实战 00.R语言数据分析实战 00.Python+Django+Ansible Playbook自动化运维项目实战 00.Java深入微服务原理改造房产销售平台 00.Python3入门机器学习 经典算法与应用 00.老司机学python篇:第一季(基础速过.机器学习入门) 00.

报表模板 — 在项目管理中应用数据报表分析

项目管理是在项目活动中运用专门的知识.技能.工具和方法,使项目能在有限资源下,实现或超过设定的需求和期望的过程,是对成功地达成一系列目标相关的活动的整体监测和管控. 无论是在大型工程.软件开发.系统制造之类的项目管理中运用报表数据分析的方法及时掌握项目运行情况,也能科学准确的预测项目成本与风险.常见的会将项目中的各种资源.工时.材料.效能等数据形成分析报表.大屏看板. 葡萄城行业报表模板库此次发布了包含人员效能分析.项目资源分析.计费工时分析.结算时间分析等8张在项目管理中运用的典型报表模板.

大数据案例分析

摘自https://www.cnblogs.com/ShaYeBlog/p/5872113.html 一.大数据分析在商业上的应用 1.体育赛事预测 世界杯期间,谷歌.百度.微软和高盛等公司都推出了比赛结果预测平台.百度预测结果最为亮眼,预测全程64场比赛,准确率为67%,进入淘汰赛后准确率为94%.现在互联网公司取代章鱼保罗试水赛事预测也意味着未来的体育赛事会被大数据预测所掌控. “在百度对世界杯的预测中,我们一共考虑了团队实力.主场优势.最近表现.世界杯整体表现和博彩公司的赔率等五个因素,这