查看原文
其他

加速你的单细胞数据分析

JunJunLab 老俊俊的生信笔记 2022-08-17



在知识的洪流中不知所措

1引言

很明显现在的单细胞 数据量,通量,样本量 都是越来越多,越来越大。普通的笔记本根本 hold 不住,此外消耗的时间也非常久。非常流行的 seurat R 包里的一些函数在大数据面前也会运行变慢。该团队提出了基于 future 框架来对函数运行进行并行化, 加速函数的运行速度,减少分析时间

2安装

install.packages('future')

3测试

library(future)
# change the current plan to access parallelization
plan("multiprocess", workers = 4)
plan()
## multiprocess:
## - args: function (expr, envir = parent.frame(),
## substitute = TRUE, lazy = FALSE, seed = NULL, globals = TRUE, workers = 4, gc = FALSE, earlySignal = FALSE, label = NULL, ...)
## - tweaked: TRUE
## - call: plan("multiprocess", workers = 4)

支持下面这些函数并行化:

  • NormalizeData
  • ScaleData
  • JackStraw
  • FindMarkers
  • FindIntegrationAnchors
  • FindClusters - if clustering over multiple resolutions

示例:

library(Seurat)
pbmc <- readRDS("../data/pbmc3k_final.rds")

# Enable parallelization
plan("multiprocess", workers = 4)
markers <- FindMarkers(pbmc, ident.1 = "NK", verbose = FALSE)

时间对比:

报错解决:

Error in getGlobalsAndPackages(expr, envir = envir, globals = TRUE) :
  The total size of the X globals that need
  to be exported for the future expression ('FUN()') is X GiB.
  This exceeds the maximum allowed size of 500.00 MiB (option 'future.globals.maxSize'). The X largest globals are ...

For certain functions, each worker needs access to certain global variables. If these are larger than the default limit, you will see this error. To get around this, you can set options(future.globals.maxSize = X), where X is the maximum allowed size in bytes. So to set it to 1GB, you would run options(future.globals.maxSize = 1000 * 1024^2). Note that this will increase your RAM usage so set this number mindfully.

4结尾

大家可以试试在自己的分析当中。





  老俊俊生信交流群 (微信交流群满200人后需收取20元入群费用)QQ,


老俊俊微信:


知识星球:



今天的分享就到这里了,敬请期待下一篇!

最后欢迎大家分享转发,您的点赞是对我的鼓励肯定

如果觉得对您帮助很大,赏杯快乐水喝喝吧!



  





Cell 教我学画图之累积分布曲线

Molecular Cell 文章 ribosome pausing 结果复现 (终)

Molecular Cell 文章 ribosome pausing 结果复现 (四)

Molecular Cell 文章 ribosome pausing 结果复现 (三)

Molecular Cell 文章 ribosome pausing 结果复现 (二) (PCR 去重)

Molecular Cell 文章 ribosome pausing 结果复现 (一)

SAM 文件 flag 研究 (续)

将 UMI 添加到 read 名称里并去除 UMI 序列

FASTX 处理 fasta 和 fastq 文件

如何计算 read 的 covergae

◀...


您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存