• heatmap | cell cycle genes in Seurat


    目的:使用bulk 数据,查看HeLa 双胸苷阻断法 细胞同步化 释放 [0, 3, 4.5, 6, 9, 10.5, 12, 15, 18, 19.5, 21, 22.5, 25.5, 30] 小时后 cell cycle 基因的表达情况。

    1.结果

    S phase

    S

    G2M phase

    在这里插入图片描述

    S + G2M phase

    在这里插入图片描述
    不方便看,横过来看:

    在这里插入图片描述

    2.代码

    counts_dir="/home/wangjl/data/rsa/HeLa/"
    
    # 1.load data----
    ##  load raw from featureCounts ----
    HeLa.raw=read.table( paste0(counts_dir, "counts/featureCounts_HeLa_CellCycle16Points_matrix.txt"),
               skip = 1, row.names = 1, header = T)
    
    gene.counts = HeLa.raw[, 6:ncol(HeLa.raw)] #col5 length
    colnames(gene.counts) = sub("map.", "", colnames(gene.counts))
    colnames(gene.counts) = sub("_Aligned.sortedByCoord.out.bam", "", colnames(gene.counts))
    colnames(gene.counts)|>jsonlite::toJSON()
    # ["SRR3535826","SRR3535828","SRR3535830","SRR3535832","SRR3535834","SRR3535835","SRR3535836","SRR3535837",
    # "SRR3535838","SRR3535839","SRR3535840","SRR3535841","SRR3535842","SRR3535843","SRR3616961","SRR3616962"]
    
    gene.counts[1:5, 1:2]
    
    # rm all 0 rows
    dim(gene.counts) #61209    16
    gene.counts = gene.counts[ rowSums(gene.counts)>0, ]
    dim(gene.counts) #42530    16
    
    gene.counts[1:5, 1:10]
    
    gene.length = HeLa.raw[rownames(gene.counts),'Length']
    
    
    
    
    #2. normalize to TPM ----
    gene.tpm=apply(gene.counts, 2, function(x){
      x1=x/gene.length
      x1/sum(x1)*1e6
    })
    dim(gene.tpm)
    head(gene.tpm)
    
    if(0){
      write.table(gene.tpm,    paste0(counts_dir, "counts/HeLa_cellcycle16points.gene.tpm.txt") )
      write.table(gene.length, paste0(counts_dir, "counts/HeLa_cellcycle16points.gene.length.txt") )
      write.table(gene.counts, paste0(counts_dir, "counts/HeLa_cellcycle16points.gene.counts.txt") )
    }
    
    
    
    # (1c) cycle genes from Seurat
    tmp.genes=c(
      Seurat::cc.genes.updated.2019$s.genes,
      Seurat::cc.genes.updated.2019$g2m.genes
    )
    
    laply(cc.genes, length)
    
    
    
    # (2) get tpm
    setdiff(tmp.genes, rownames(gene.tpm))
    dat.heatmap=gene.tpm[ intersect(rownames(gene.tpm), tmp.genes),]
    # OR use all matrix
    #dat.heatmap=gene.tpm #[ intersect(rownames(gene.tpm), tmp.genes),]
    
    # rm all 0 rows
    dat.heatmap=dat.heatmap[rowSums(dat.heatmap)>0,]
    head(dat.heatmap[,1:5])
    dim(dat.heatmap)
    
    library(pheatmap) #https://www.jianshu.com/p/1c55ea64ff3f
    # anno columns
    annotation_col <- data.frame(
      #type = gene.long$type,
      phase = c("S", "G2", "G2", "G2", "M", "G1", "G1", "S", #1-8
              "G2", "G2", "M", "M", "G1", "S",     "G1", "G1"), #9-16
      time=c(0, 3, 4.5, 6, 9, 10.5, 12, 15, 18, 19.5, 21, 22.5, 25.5, 30, 31, 32),
      row.names = rownames(gene.long)
    )
    # set colors
    ann_colors = list(
      phase = c('G1'="#66C2A5", 'S'="#FC8D62", 'G2'="#8DA0CB", 'M'="deeppink")
      #type = c('S'="#ed553b", 'ctrl'="#99b433")
    )
    
    pheatmap(
      dat.heatmap[,1:14],
      #log( dat.heatmap[,1:14] + 1 ), 
      #log(dat.heatmap[, 1:10] + 1), 
      # log(dat.heatmap[, c(16, 1:10, 11:15)] + 1),
      border_color =NA, # "white", 
      color = colorRampPalette(c("navy", "white", "firebrick3"))(50), #自定义颜色
      scale="row",
      cluster_cols = F,
      #cluster_rows = F,
      annotation_col = annotation_col, #set anno for column
      annotation_colors = ann_colors, #set colors
      show_colnames = T,
      #show_rownames = F,
      #angle_col = 315,
    
      #filename =paste0("tmp/HeLa_sync16Timepoints_pheatmap-2.pdf"), width=18.6, height=3.5,
      main="HeLa after sync: 14 time points\n(Seurat::cc.genes)",
      clustering_method = "ward.D2") #聚类方法
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
  • 相关阅读:
    猿创征文|工具百宝箱-代码编辑器-版本控制工具-终端神器-项目与事务跟踪工具-SFTP客户端
    锂电溶液提纯除钙镁用什么工艺,除钙镁树脂设备
    linux下检测CPU性能的mpstat命令安装与用法
    Mybatis一对多关联查询,返回值Map,字段自动映射
    LabVIEW样式检查表4
    华为云Astro的前世今生:用7年时间革新低代码开发观念
    Redis入门完整教程:复制原理
    iOS获取当前网络连接状态WiFi、5G、4G、3G、2G
    install Oracle JDK in Linux:安装oracle JDK in linux
    线性表的顺序存储C++代码
  • 原文地址:https://blog.csdn.net/wangjunliang/article/details/134482848