美文网首页下游数据分析
R语言分析6:TIDE评分

R语言分析6:TIDE评分

作者: 小程的学习笔记 | 来源:发表于2023-10-26 10:31 被阅读0次

    TIDE(http://tide.dfci.harvard.edu/代表肿瘤免疫功能障碍和排斥,用于评估免疫疗法在不同风险组中的潜在临床疗效,反映肿瘤免疫逃避的潜在能力,较高的TIDE评分与较差的ICI疗效相关。

    1. 表达矩阵预处理

    # TCGA-STADfpkm表达矩阵
    STAD_Expr[1:4, 1:4]
    #           TCGA-BR-A4J4-01A-12R-A251-31 TCGA-BR-A4IZ-01A-32R-A251-31 TCGA-RD-A7C1-01A-11R-A32D-31 TCGA-BR-6852-01A-11R-1884-13
    # 5_8S_rRNA                       0.0866                       0.4991                       1.0460                       0.1388
    # 5S_rRNA                         0.0000                       0.2676                       2.6896                       0.3327
    # 7SK                             0.3533                       0.2546                       1.2531                       0.2813
    # A1BG                            0.0197                       0.0358                       0.1067                       0.1153
    
    # 临床信息,含风险评分
    clin_info[1:4, 1:5]
    #   riskscore          entity_submitter_id status time riskgroup
    # 1 0.5443136 TCGA-BR-A4J4-01A-12R-A251-31      0   16 Low
    # 2 1.9722861 TCGA-BR-A4IZ-01A-32R-A251-31      1  273 High
    # 3 1.1310911 TCGA-RD-A7C1-01A-11R-A32D-31      1  507 High
    # 4 0.7301153 TCGA-BR-6852-01A-11R-1884-13      0 1367 Low
    
    dt <- as.data.frame(t(STAD_Expr))  
    identical(rownames(dt), clin_info$entity_submitter_id) # 保险检查一下行名是否一致  
    # [1] TRUE
    
    dt$score <- clin_info$riskscore # 在表达矩阵中新增风险评分列
    dt$riskgroup <- clin_info$riskgroup # 在表达矩阵中新增风险分组列
    
    df <- dt[order(dt$score, decreasing = F),] # 按风险评分把矩阵升序排列  
    
    df$id <- c(1:length(df$score)) # 新增id列  
    df$id2 <- paste(df$riskgroup, df$id, sep = '_') # 将风险分组和id串联  
    rownames(df) <- df$id2 # 修改为行名  
    
    df <- df[,1:59427] # 去掉新增列,仅保留表达矩阵  
    df <- t(df) # 转置  
    
    # 将矩阵重新转换为数值型:  
    df2 <- apply(df, 2, as.numeric)  
    row.names(df2) <- row.names(df)  
    df2[1:6,1:6]
    #            Low_1  Low_2  Low_3  Low_4  Low_5  Low_6
    # 5_8S_rRNA 0.0000 0.2109 0.2046 0.6394 0.2617 0.0000
    # 5S_rRNA   0.3354 0.7560 0.5184 0.4585 0.7506 0.2370
    # 7SK       0.0720 0.1613 0.2518 0.1967 0.3115 0.2108
    # A1BG      0.0222 0.0681 0.0272 0.0486 0.0298 0.0188
    # A1BG-AS1  0.1054 0.0238 0.0323 0.0000 0.0668 0.0186
    # A1CF      0.0426 0.0083 3.9530 0.1316 3.8196 0.0262
    
    # 计算方法: 表达量减去每个基因所在样本的均值(即按行计算均值,再用每个表达量-均值)
    Expr <- t(apply(df2, 1, function(x){x-(mean(x))})) # 均值标准化  
    Expr[1:6,1:6]
    #                 Low_1       Low_2        Low_3        Low_4       Low_5       Low_6
    # 5_8S_rRNA -0.92326170 -0.71236170 -0.718661702 -0.283861702 -0.66156170 -0.92326170
    # 5S_rRNA   -0.17608644  0.24451356  0.006913564 -0.052986436  0.23911356 -0.27448644
    # 7SK       -0.11633750 -0.02703750  0.063462500  0.008362500  0.12316250  0.02246250
    # A1BG      -0.02267952  0.02322048 -0.017679521  0.003720479 -0.01507952 -0.02607952
    # A1BG-AS1  -0.04596277 -0.12756277 -0.119062766 -0.151362766 -0.08456277 -0.13276277
    # A1CF      -1.62320053 -1.65750053  2.287199468 -1.534200532  2.15379947 -1.63960053
    
    write.table(Expr, file = 'TIDE.txt', sep = "\t", quote = F, row.names = T) # 矩阵保存到本地
    

    2. TIDE评分计算

    1. 进入官网(http://tide.dfci.harvard.edu/login/
    2. 在菜单栏第一个‘Response Prediction'选项页面下拉,上传整理好的制表符分隔文本格式的表达矩阵(首行Tab一下,保持列名对齐),'Cancer type'选择Other,'Previous immunotherapy'保持默认No,然后点击 'Predict response' 即可静待结果
    3. 分析完成后,会直接跳转到预测结果报告页,下拉导出csv文件即可
    TIDE-1

    3. 结果可视化

    # 读入结果表:  
    result <- read.csv('TIDE_result.csv')  
    colnames(result)
    
    # 根据行名新增分组列:  
    result$Risk <- ifelse(  
      str_sub(result$Patient, 1, 1) == 'L', 'Low_Risk', 'High_Risk'  
    )  
    # 转换为因子,调整顺序:  
    result$Risk <- factor(result$Risk, levels = c('Low_Risk','High_Risk'))  
    
    # 小提琴图展示结果:  
    # 1.TIDE小提琴图:  
    my_comparisons <- list( c("Low_Risk", "High_Risk")) # 添加比较分组  
    p1 <- ggviolin(result, x = 'Risk', y = 'TIDE', fill = 'Risk',  
                   palette = c("#2E9FDF", "#E7B800"),  
                   add = 'boxplot', add.params = list(fill = "white")) +  
      stat_compare_means(comparisons = my_comparisons, label = "p.signif", bracket.size=0.5, tip.length = 0.02, method = 't.test')  
    p1  
    
    # 2.Dysfunction小提琴图:
    # dysfunction score的计算原理:免疫失调作用的基因拥有更高的权重,再乘以表达量  
    p2 <- ggviolin(result, x = 'Risk', y = 'Dysfunction', fill = 'Risk',  
                   palette = c("#2E9FDF", "#E7B800"),  
                   add = 'boxplot', add.params = list(fill = "white")) +  
      stat_compare_means(comparisons = my_comparisons, label = "p.signif", bracket.size=0.5, tip.length = 0.02, method = 't.test')  
    p2
    
    # Exclusion小提琴图:  
    # exclusion score是由免疫排斥的基因拥有更高的权重,再乘以表达量得到
    p3 <- ggviolin(result, x = 'Risk', y = 'Exclusion', fill = 'Risk',  
                   palette = c("#2E9FDF", "#E7B800"),  
                   add = 'boxplot', add.params = list(fill = "white")) +  
      stat_compare_means(comparisons = my_comparisons, label = "p.signif", bracket.size=0.5, tip.length = 0.02, method = 't.test')  
    p3
    
    # MSI小提琴图:  
    colnames(result)[6]  
    colnames(result)[6] <- c('MSI') # 简化一下列名  
    p4 <- ggviolin(result, x = 'Risk', y = 'MSI', fill = 'Risk',  
                   palette = c("#2E9FDF", "#E7B800"),  
                   add = 'boxplot', add.params = list(fill = "white")) +  
      stat_compare_means(comparisons = my_comparisons, label = "p.signif", bracket.size=0.5, tip.length = 0.02, method = 't.test')  
    p4
    
    p <- p1 + p2 + p3 + p4  
    p
    
    TIDE-2

    ★ 高风险组的TIDE评分、Exclusion评分和Dysfunction评分显著升高,MSI评分较低,说明高风险组患者的免疫逃逸潜力增大,免疫检查点抑制治疗(ICI)疗效可能较差

    相关文章

      网友评论

        本文标题:R语言分析6:TIDE评分

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