多样本harmony整合去批次单细包分析--day8

#merge进行多组seuratobject数据合并

# 合并多个Seurat对象

gpy.big <- merge(COEA,

                  y = c(xxxx, xxxx, xxxx),

                  add.cell.ids = c("xxxxx", "xxxx", "xxx", "xxxx"),

                  project = "gpy")

#Harmony去批次/基因染色/umap图/差异表达基因和表达式热图

gpy.big <- NormalizeData(gpy.big, normalization.method = "LogNormalize",

scale.factor = 10000) ##后面是函数的默认值

#根据前5000个高变基因及进行UMAP

gpy.big <- FindVariableFeatures(gpy.big, selection.method = "vst", nfeatures = 5000) ##默认返回nfeatures =2000

all.genes <- rownames(gpy.big)

gpy.big <- ScaleData(gpy.big, features = all.genes)#中心化

#PCA之后harmony去批次

gpy.big <- RunPCA(gpy.big, features = VariableFeatures(object = gpy.big), verbose = F)

library(harmony)

gpy.big <- gpy.big %>% RunHarmony("orig.ident", plot_covergence = T)

##去批次以后umap

gpy.big<- gpy.big %>%

  RunUMAP(reduction = "harmony", dims = 1:30) %>%

  FindNeighbors(reduction = "harmony", dims = 1:30) %>%

  FindClusters(resolution = 0.1) %>%

  identity()

# 创建一个空的pdf文件,用于保存图形输出

pdf("D:/AXOEA.pdf")

##画图按orig.ident

DimPlot(gpy.big, reduction = "umap",group.by = "orig.ident")

##画图按群

DimPlot(gpy.big, reduction = "umap",label = T)

###寻找差异表达基因(findallmarkers)

##devtools::install_github("immunogenomics/presto")

gpy.big.markers <- FindAllMarkers(gpy.big, only.pos = TRUE)

gpy.big.markers %>%

  group_by(cluster) %>%

  dplyr::filter(avg_log2FC > 1)

##染色

FeaturePlot(gpy.big, features = c("POU5F1", "SOX2", "DNMT3B", "POU3F1"))

##表达式热图

gpy.big.markers %>%

    group_by(cluster) %>%

    dplyr::filter(avg_log2FC > 1) %>%

    slice_head(n = 10) %>%

    ungroup() -> top10

DoHeatmap(gpy.big, features = top10$gene) + NoLegend()

# 关闭pdf设备,保存图形输出

dev.off()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值