TCGA 数据分析实战 —— 突变及拷贝数分析

TCGA 数据分析实战 —— 突变及拷贝数分析

文章目录

  • TCGA 数据分析实战 —— 突变及拷贝数分析
    • 前言
    • 基因组分析
      • 数据预处理
      • 识别 recurrent CNV
      • recurrent CNV 基因注释
    • 基因组变异可视化
      • OncoPrint
      • circos plot
      • 部分区域可视化

前言

在介绍完 TCGAbiolinks 的查询下载和数据分析功能之后,我们简单展示几个示例,来练练手,加深对这个包的理解和使用

我们主要从基因组、转录组和表观组 3 个维度分别举例来进行说明。

基因组分析

拷贝数变异(CNV)在癌症的发生和发展研究中扮演重要的角色。由于基因组重排(如染色体缺失、重复、插入和易位),导致染色体片段的扩增或删失。

CNV 是大于 1kb 的基因组区域发生拷贝数的扩增和删失。

TCGA 的数据可以分为三个等级:

  • level 1: 原始的测序数据(fastafastq等
  • level 2: 比对好的 bam 文件
  • level 3: 经过标准化处理的数据

我们需要获取到 level 3 的数据来进行分析,来识别癌症基因组变异

数据预处理

我们分析的是 legacy 数据库中 Affymetrix Genome-Wide Human SNP Array 6.0 平台的数据

获取 20GBMLGG 样本的 CNV 数据

library(TCGAbiolinks) # 2.30.4
library(tidyverse)

query.gbm.nocnv <- GDCquery(
    project = "TCGA-GBM",
    data.category = "Copy Number Variation",
    data.type = "Masked Copy Number Segment",
    access = "open"
)
# 只挑选 20 个样本
query.gbm.nocnv$results[[1]] <- query.gbm.nocnv$results[[1]][1:20,]

GDCdownload(query.gbm.nocnv)

cnvMatrix <- GDCprepare(query.gbm.nocnv) %>%
    filter(abs(Segment_Mean) > 0.3) %>%
    mutate(label = if_else(Segment_Mean < -0.3, 0, 1)) %>%
    dplyr::select(-Segment_Mean, -GDC_Aliquot) %>%
    rename_with(~ c("Chromosome", "Start", "End", "Num.of.Markers", "Sample.Name", "Aberration")) %>%
    mutate(Chromosome = ifelse(Chromosome == "X", 23, Chromosome),
           Chromosome = ifelse(Chromosome == "Y", 24, Chromosome),
           Chromosome = as.integer(Chromosome)) %>%
    dplyr::select(c(5, 1:4, 6)) %>%
    # 注意要转换为 data.frame 格式
    as.data.frame()

查看 cnv 矩阵

cnvMatrix[1:3,1:3]
#                    Sample.Name Chromosome     Start
# 1 TCGA-16-1056-10A-01D-0517-01          2 212458388
# 2 TCGA-16-1056-10A-01D-0517-01          2 229437826
# 3 TCGA-16-1056-10A-01D-0517-01          2 232263591

识别 recurrent CNV

癌症相关的 CNV 会在许多样本中反复出现,我们使用 GAIA 包来识别这种显著的 recurrent CNV

GAIA 算法基于随机排列的统计检验,同时考虑样本内的显著性和同质性,以重复迭代的方式删除区间内的峰,直至剩下的峰没有显著性为止识别显著的 CNV


处理探针数据,这个需要从 GDC Reference Files 中下载相应版本的探针集合。

TCGA 数据分析实战 —— 突变及拷贝数分析_第1张图片

将文件读取进来,并进行相应的处理

markersMatrix <-  readr::read_tsv(
        "~/Downloads/snp6.na35.remap.hg38.subset.txt",
        show_col_types = FALSE
    )  %>%
    dplyr::filter(freqcnv == FALSE) %>%  # use for GISTIC
    dplyr::select(1:3) %>%
    rename_with(~c("Probe.Name", "Chromosome", "Start")) %>%
    mutate(Chromosome = ifelse(Chromosome == "X", 23, Chromosome),
           Chromosome = ifelse(Chromosome == "Y", 24, Chromosome),
           Chromosome = as.integer(Chromosome)) %>%
    dplyr::filter(!duplicated(Probe.Name)) %>%
    as.data.frame %>%
    arrange(Chromosome, Start)  # 排序是重要的

运行 gaia,识别 recurrent CNV

library(gaia)

set.seed(200)
markers_obj <- load_markers(as.data.frame(markersMatrix_filtered))
nbsamples <- length(unique(cnvMatrix$Sample.Name))
cnv_obj <- load_cnv(cnvMatrix, markers_obj, nbsamples)
suppressWarnings({
  cancer <- "GBM"
  results <- runGAIA(
    cnv_obj, markers_obj,
    output_file_name = paste0("~/Downloads/GAIA_", cancer, "_flt.txt"),
    # 指定需要分析的变异类型,-1 分析所有的变异
    aberrations = -1,
    # 指定需要分析的染色体,默认为 -1,表示所有染色体
    chromosomes = -1,
    # 使用近似的方式可以加快计算速度
    approximation = TRUE,
    # 设置迭代次数
    num_iterations = 5000,
    threshold = 0.25
  )
})

在运行 load_cnvrunGAIA 时经常会报错,可以使用下面修改后的代码。

load_cnv <- function(segmentation_matrix, markers_list, num_of_samples){
    
    message("Loading Copy Number Data");
    
    # Detect the chromosomes
    
    chromosomes <- as.numeric(sort(unique(names(markers_list))));
    
    chromosomes <- chromosomes[which(!is.na(chromosomes))];
    
    # Detect the aberration kinds
    
    aberration_kinds <- 1:length(unique(segmentation_matrix[,6]));
    
    names(aberration_kinds) <- sort(unique(segmentation_matrix[,6]));
    
    # Detect the samples
    
    samples <- 1:num_of_samples;
    
    if(!is.numeric(segmentation_matrix[,1])){
        
        sample_names <- unique(segmentation_matrix[,1]);
        
        for(i in 1:length(sample_names)){
            
            segmentation_matrix[which(segmentation_matrix[,1]==sample_names[i]),1] <- i;
            
        }
        
    }
    
    region_list <- list();
    
    # Create the final structure list of the returned list
    
    for(k in 1:length(aberration_kinds)){
        
        region_list[[ aberration_kinds[k] ]] <- list();
        
        for(i in 1:length(chromosomes) ){
            
            region_list[[ aberration_kinds[k] ]][[ chromosomes[i] ]] <- matrix(0, length(samples), ncol(markers_list[[ chromosomes[i] ]]));
            
            rownames(region_list[[ aberration_kinds[k] ]][[ chromosomes[i] ]]) <- samples;
            
            colnames(region_list[[ aberration_kinds[k] ]][[ chromosomes[i] ]]) <- c(1:ncol(markers_list[[ chromosomes[i] ]]));
            
        }
        
    }
    
    for(k in 1:length(aberration_kinds)){
        
        ab_ids <- which(segmentation_matrix[,6]==names(aberration_kinds[k]));
        
        # In this matrix all regions aberrant as aberration_kinds[k] are stored
        
        tmp_matrix1 <- segmentation_matrix[ab_ids,];
        
        if(class(tmp_matrix1)=="numeric"){
            
            tmp_matrix1 <- t(as.matrix(tmp_matrix1));
            
        }
        
        for(i in 1:length(chromosomes) ){
            
            # In this matrix all regions aberrant as aberration_kinds[k] for the i-th chromsome are stored
            
            tmp_matrix2 <- tmp_matrix1[which(tmp_matrix1[,2]=

你可能感兴趣的:(生信数据库,R,数据分析实战,数据分析,网络,数据挖掘)