Hamony

作者: LET149 | 来源:发表于2023-11-05 09:09 被阅读0次

    官网: https://github.com/immunogenomics/harmony

    文章: https://www.nature.com/articles/s41592-019-0619-0

    学习博文:

    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. 说明一
      1. RunHarmony() 进行的数据整合,是依赖merge 但未整合数据的 PC 进行的
      1. RunHarmony() 并不会改变未整合前的任何数据,而是产生一个新的降维数据 harmony;此数据放在 @reductions$harmony@feature.loadings 这个 slot
      1. 因为RunHarmony() 并未改变未整合前的任何数据,所以用 Harmony 进行数据整合后并不会改变 差异分析 等分析结果
    2. 说明二

    @reductions$harmony@feature.loadings 中数据解读:

      1. @reductions$harmony@cell.embeddings: 各个细胞在 harmony 这个降维方式中的坐标
      1. @reductions$harmony@feature.loadings: 各个 feature(gene)harmony 中的 embedding,数值大小代表 feature 对这个 harmony 维度的贡献程度;数值越大贡献越大
      1. 数据整合后,后续的 降维聚类 分析都在 @reductions$harmony@cell.embeddings 的基础上进行

    相关文章

      网友评论

          本文标题:Hamony

          本文链接:https://www.haomeiwen.com/subject/guioultx.html