Hamony
学习博文:
https://www.jianshu.com/p/7c43dc99c4b1
https://www.jianshu.com/p/d1cb5a7f19af
require(Seurat)
require(ggplot2)
require(dplyr)
require(harmony)
require(cowplot)
#----------------------------------------------------------------------------------------------#
object_used_1 <- Dmel_ovary_CD_filtered_by_3_200_feature_over_600_mito_less_20_kept_mito_gene_HVF_1100_dim_6_doublet_removed
object_used_1$orig.ident <- "CD"
object_used_2 <- Dmel_ovary_HSD_filtered_by_3_200_feature_over_600_mito_less_20_kept_mito_gene_HVF_1100_dim_6_doublet_removed
object_used_2$orig.ident <- "HSD"
#----------------------------------------------------------------------------------------------#
#Merge the two seurat objects to one
object_merged <- merge(object_used_1, object_used_2)
#----------------------------------------------------------------------------------------------#
#Normalize the merged seurat object
object_merged <- NormalizeData(object_merged, normalization.method = "LogNormalize", scale.factor = 10000)
#Call the high variable features of the merged seurat object based on the normalized UMI matrix
object_merged <- FindVariableFeatures(object_merged, selection.method = "vst", nfeatures = 2000)
#Scaled the normalized UMI matrix
genes_all <- rownames(object_merged)
object_merged <- ScaleData(object_merged, features = genes_all)
#PCA based on the scaled normalized UMI matrix
object_merged <- RunPCA(object_merged, features = VariableFeatures(object = object_merged))
#----------------------------------------------------------------------------------------------#
#Integrate two sample by RunHarmony() based on the PCA results of merged Seurat object; dims.use, the PC used; max.iter.harmony, the iteration number of RunHarmony()
object_harmonied <- RunHarmony(object_merged, group.by.vars = "orig.ident", plot_convergence = TRUE)
#----------------------------------------------------------------------------------------------#
#Downstream analysis of integrated seurat object
object_harmonied <- RunTSNE(object_harmonied, reduction = "harmony", dims = 1:20)
object_harmonied <- RunUMAP(object_harmonied, reduction = "harmony", dims = 1:20)
object_harmonied <- FindNeighbors(object_harmonied, reduction = "harmony", dims = 1:20)
object_harmonied <- FindClusters(object_harmonied, resolution = 0.7)
1. 说明一
RunHarmony()
进行的数据整合,是依赖merge
但未整合数据的PC
进行的
RunHarmony()
并不会改变未整合前的任何数据,而是产生一个新的降维数据harmony
;此数据放在@[email protected]
这个 slot 中
- 因为
RunHarmony()
并未改变未整合前的任何数据,所以用Harmony
进行数据整合后并不会改变 差异分析 等分析结果
2. 说明二
@[email protected]
中数据解读:
@[email protected]
: 各个细胞在harmony
这个降维方式中的坐标
@[email protected]
: 各个feature(gene)
在harmony
中的embedding
,数值大小代表feature
对这个harmony
维度的贡献程度;数值越大贡献越大
- 数据整合后,后续的 降维 和 聚类 分析都在
@[email protected]
的基础上进行
共有 0 条评论