单细胞-拟时序分析-R包SCORPIUS

 注:代码转自生信技能树,仅做学习笔记。icon-default.png?t=M0H8https://mp.weixin.qq.com/s/rho-EPb804bSd8w334BNQw

准备工作, 安装及加载R包,载入数据,查看数据类型。

install.packages("SCORPIUS")
library(SCORPIUS)
data(ginhoux)
ginhoux
class(ginhoux)
str(ginhoux)
c<-ginhoux[[1]]
g<-ginhoux[[2]]

c<-ginhoux[[1]]

g<-ginhoux[[2]]
expression <- ginhoux$expression
group_name <- ginhoux$sample_info$group_name
table(group_name)
dim(expression)
expression[1:4,1:4]

该数据 245个细胞,2000个基因,然后细胞分成了3组

space <- reduce_dimensionality(expression, "spearman")
draw_trajectory_plot(space, group_name, contour = TRUE)
space <- reduce_dimensionality(expression, "spearman")
draw_trajectory_plot(space, group_name, contour = TRUE)
traj <- infer_trajectory(space)
draw_trajectory_plot(space, group_name, traj$path, contour = TRUE)

# warning: setting num_permutations to 10 requires a long time (~30min) to run!
# set it to 0 and define a manual cutoff for the genes (e.g. top 200) for a much shorter execution time.
gimp <- gene_importances(
  expression, 
  traj$time, 
  num_permutations = 10, 
  num_threads = 8, 
  ntree = 10000,
  ntree_perm = 1000
) 
gimp$qvalue <- p.adjust(gimp$pvalue, "BH", length(gimp$pvalue))
gene_sel <- gimp$gene[gimp$qvalue < .05]
expr_sel <- scale_quantile(expression[,gene_sel])

# Draw a time series heatmap
time <- traj$time
draw_trajectory_heatmap(expr_sel, time)

## Also show the progression groupings
draw_trajectory_heatmap(expr_sel, time, 
                        progression_group=group_name)

## 换一个配色
table(group_name)
draw_trajectory_heatmap(
  expr_sel, time, progression_group=group_name,
  progression_group_palette = setNames(RColorBrewer::brewer.pal(3, "Set2"),
                                       levels(group_name))
)

## 基因也可以分组
modules <- extract_modules(scale_quantile(expr_sel))

draw_trajectory_heatmap(expr_sel, time,
                        progression_group=group_name, modules=modules)

 

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值