ChAMP分析TCGA结直肠癌甲基化数据实战

2023-11-23 03:50

本文主要是介绍ChAMP分析TCGA结直肠癌甲基化数据实战,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前面用几篇推文详细介绍了ChAMP包用于甲基化分析的流程,并使用肠癌领域的GSE149282进行了演示。

16.ChAMP分析甲基化数据:标准流程

17.ChAMP分析甲基化数据:从β值矩阵开始的流程

下面我们用TCGA-COAD和TCGA-READ的甲基化数据再做一次演示,从IDAT文件开始。

有了这个结果之后,你就可以去做各种联合分析~

太长不看版

下面的步骤都是在服务器上做的,因为一共有812个样本,至少需要64+G的内存,一般的个人电脑就不要尝试了,需要这个分析结果的可以私聊我,有偿获取!

去掉日志文件就是做了以下几个分析:

library(ChAMP)myDir="./coreadidatAllinone"
myLoad <- champ.load(myDir)
save(myLoad,file="coread_methy_myload.rdata")myNorm <- champ.norm(beta = myLoad$beta,cores = 20)
save(myNorm,file = "coread_methy_mynorm.rdata")champ.SVD(beta = myNorm |> as.data.frame(), pd=myLoad$pd)myDMP <- champ.DMP()
myDMR <- champ.DMR()
save(myDMP,myDMR,file = "coread_methy_dmpr.rdata")myGSEA <- champ.GSEA()
save(myGSEA,file = "coread_methy_gsea.rdata")

下面是分步版本,日志文件太多了…

数据准备

数据下载可以用之前介绍过的TCGAbiolinks包,也可以直接去GDC官网下载。

下载后把所有的IDAT文件放在一个文件夹中:

812个IDAT文件

我是用下面的代码,用什么方法都行,只要把所有的IDAT放在一个文件夹下就可以了。

lapply(list.files("./coread_idat/",recursive = T,pattern = "idat$",full.names = T),file.copy, to = "./coreadidatAllinone/")

然后在GDC官网下载gdc_sample_sheet这个文件,这个文件可以帮助我们制作自己的样本信息csv文件。

gdc_sample_sheet

sample_sheet <- read.table("gdc_sample_sheet.2022-08-21.tsv",sep = "\t",header = T)

之后按照CnAMP包的要求制作csv文件,可以参考历史推文:xxxxxxxxxxx

pd <- sample_sheet[,c("File.Name","Project.ID","Sample.ID","Sample.Type")]
pd$Sentrix_ID <- substr(pd$File.Name,1,36) 
pd$Sentrix_Position <- substr(pd$File.Name,38,41) 
pd$Sample_Group <- ifelse(pd$Sample.Type == "Solid Tissue Normal","normal","tumor")
pd <- pd[,c(3,7,2,5,6)]
names(pd)[c(1,3)] <- c("Sample_Name","Project")pd1 <- pd[duplicated(pd$Sentrix_ID),]

把这个文件保存到coreadidatAllinone这个文件夹下即可:

write.csv(pd1,file = "./coreadidatAllinone/sample_sheet.csv",quote = F,row.names = F)

读取数据

# 加载R包
#suppressMessages(library(ChAMP))
library(ChAMP)

非常简单,指定合适的路径,里面有IDAT文件和相应的样本信息csv文件,就不会出错。

# 指定文件夹路径
myDir="./coreadidatAllinone"myLoad <- champ.load(myDir)

下面是加载日志文件:

[===========================]
[<<<< ChAMP.LOAD START >>>>>]
-----------------------------[ Loading Data with ChAMP Method ]
----------------------------------
Note that ChAMP method will NOT return rgSet or mset, they object defined by minfi. Which means, if you use ChAMP method to load data, you can not use SWAN or FunctionNormliazation method in champ.norm() (you can use BMIQ or PBC still). But All other function should not be influenced.[===========================]
[<<<< ChAMP.IMPORT START >>>>>]
-----------------------------[ Section 1: Read PD Files Start ]CSV Directory: ./coreadidatAllinone/sample_sheet.csvFind CSV SuccessReading CSV FileReplace Sentrix_Position into ArrayReplace Sentrix_ID into SlideThere is NO Pool_ID in your pd file.There is NO Sample_Plate in your pd file.There is NO Sample_Well in your pd file.
[ Section 1: Read PD file Done ][ Section 2: Read IDAT files Start ]Loading:./coreadidatAllinone/4edebe4a-9fb7-4d84-a260-97feb38fb16a_noid_Grn.idat ---- (1/406)
Warning in readChar(con, nchars = n) :truncating string with embedded nulsLoading:./coreadidatAllinone/25df3fb5-44fe-41b0-92ad-cf30bdb62584_noid_Grn.idat ---- (2/406)
Warning in readChar(con, nchars = n) :truncating string with embedded nulsLoading:./coreadidatAllinone/f946a265-a27e-4c20-bd53-266ab6aa3de6_noid_Grn.idat ---- (3/406)Loading:./coreadidatAllinone/4220d653-e946-4741-8864-cc8246939003_noid_Red.idat ---- (405/406)
Warning in readChar(con, nchars = n) :truncating string with embedded nulsLoading:./coreadidatAllinone/b9623ff8-8fd4-4124-bd08-b128767ea60a_noid_Red.idat ---- (406/406)
Warning in readChar(con, nchars = n) :truncating string with embedded nuls
## ........Extract Mean value for Green and Red Channel SuccessYour Red Green Channel contains 622399 probes.
[ Section 2: Read IDAT Files Done ][ Section 3: Use Annotation Start ]Reading 450K Annotation >>Fetching NEGATIVE ControlProbe.Totally, there are 613 control probes in Annotation.Your data set contains 613 control probes.Generating Meth and UnMeth MatrixExtracting Meth Matrix...Totally there are 485512 Meth probes in 450K Annotation.Your data set contains 485512 Meth probes.Extracting UnMeth Matrix...Totally there are 485512 UnMeth probes in 450K Annotation.Your data set contains 485512 UnMeth probes.Generating beta MatrixGenerating M MatrixGenerating intensity MatrixCalculating Detect P valueCounting Beads
[ Section 3: Use Annotation Done ][<<<<< ChAMP.IMPORT END >>>>>>]
[===========================]
[You may want to process champ.filter() next.][===========================]
[<<<< ChAMP.FILTER START >>>>>]
-----------------------------In New version ChAMP, champ.filter() function has been set to do filtering on the result of champ.import(). You can use champ.import() + champ.filter() to do Data Loading, or set "method" parameter in champ.load() as "ChAMP" to get the same effect.This function is provided for user need to do filtering on some beta (or M) matrix, which contained most filtering system in champ.load except beadcount. User need to input beta matrix, pd file themselves. If you want to do filterintg on detP matrix and Bead Count, you also need to input a detected P matrix and Bead Count information.Note that if you want to filter more data matrix, say beta, M, intensity... please make sure they have exactly the same rownames and colnames.[ Section 1:  Check Input Start ]You have inputed beta,intensity for Analysis.pd file provided, checking if it's in accord with Data Matrix...pd file check success.Parameter filterDetP is TRUE, checking if detP in accord with Data Matrix...detP check success.Parameter filterBeads is TRUE, checking if beadcount in accord with Data Matrix...beadcount check success.parameter autoimpute is TRUE. Checking if the conditions are fulfilled...!!! ProbeCutoff is 0, which means you have no needs to do imputation. autoimpute has been reset FALSE.Checking Finished :filterDetP,filterBeads,filterMultiHit,filterSNPs,filterNoCG,filterXY would be done on beta,intensity.You also provided :detP,beadcount .
[ Section 1: Check Input Done ][ Section 2: Filtering Start >>Filtering Detect P value StartThe fraction of failed positions per sampleYou may need to delete samples with high proportion of failed probes:Failed CpG Fraction.
TCGA-DC-6158-01A         0.0036394569
TCGA-F5-6864-01A         0.0170891760
TCGA-EI-6917-01A         0.0266790522
TCGA-AF-2690-01A         0.0019216827
TCGA-EI-6513-01A         0.0011801974
TCGA-EI-6885-01A         0.0056970785
TCGA-DT-5265-01A         0.0030545074
TCGA-AG-A036-11A         0.0004613686
TCGA-F5-6810-01A         0.0058433159
TCGA-EI-6506-01A         0.0021276508
TCGA-EI-6510-01A         0.0025993178
TCGA-EI-7002-01A         0.0132252138
## ...
TCGA-DM-A28C-01A         0.0013367332
TCGA-A6-5664-01A         0.0021297105
TCGA-D5-6533-01A         0.0019093246Filtering probes with a detection p-value above 0.01.Removing 59892 probes.If a large number of probes have been removed, ChAMP suggests you to identify potentially bad samplesFiltering BeadCount StartFiltering probes with a beadcount <3 in at least 5% of samples.Removing 205 probesFiltering NoCG StartOnly Keep CpGs, removing 1636 probes from the analysis.Filtering SNPs StartUsing general 450K SNP list for filtering.Filtering probes with SNPs as identified in Zhou's Nucleic Acids Research Paper 2016.Removing 47713 probes from the analysis.Filtering MultiHit StartFiltering probes that align to multiple locations as identified in Nordlund et alRemoving 10 probes from the analysis.Filtering XY StartFiltering probes located on X,Y chromosome, removing 8124 probes from the analysis.Updating PD fileFixing Outliers StartReplacing all value smaller/equal to 0 with smallest positive value.Replacing all value greater/equal to 1 with largest value below 1..
[ Section 2: Filtering Done ]All filterings are Done, now you have 367932 probes and 406 samples.[<<<<< ChAMP.FILTER END >>>>>>]
[===========================]
[You may want to process champ.QC() next.][<<<<< ChAMP.LOAD END >>>>>>]
[===========================]
[You may want to process champ.QC() next.]
save(myLoad,file="coread_methy_myload.rdata")

预处理

# 数据预处理,聚类树由于样本太多显示不出来会报错
champ.QC() 

densityplot

MDSplot

myNorm <- champ.norm(beta = myLoad$beta,cores = 20)

日志文件:

[===========================]
[>>>>> ChAMP.NORM START <<<<<<]
-----------------------------
champ.norm Results will be saved in ./CHAMP_Normalization/
[ SWAN method call for BOTH rgSet and mset input, FunctionalNormalization call for rgset only , while PBC and BMIQ only needs beta value. Please set parameter correctly. ]Note that,BMIQ function may fail for bad quality samples (Samples did not even show beta distribution).
20 cores will be used to do parallel BMIQ computing.
[>>>>> ChAMP.NORM END <<<<<<]
[===========================]
[You may want to process champ.SVD() next.]
save(myNorm,file = "coread_methy_mynorm.rdata")
champ.SVD(beta = myNorm |> as.data.frame(), # 这里需要注意pd=myLoad$pd)

SVD

[===========================]
[<<<<< ChAMP.SVD START >>>>>]
-----------------------------
champ.SVD Results will be saved in ./CHAMP_SVDimages/ .Your beta parameter is data.frame format. ChAMP is now changing it to matrix.
[SVD analysis will be proceed with 367932 probes and 406 samples.][ champ.SVD() will only check the dimensions between data and pd, instead if checking if Sample_Names are correctly matched (because some user may have no Sample_Names in their pd file),thus please make sure your pd file is in accord with your data sets (beta) and (rgSet).]<Sample_Group>(character):tumor, normal
<Slide>(character):4edebe4a-9fb7-4d84-a260-97feb38fb16a, 25df3fb5-44fe-41b0-92ad-cf30bdb62584, f946a265-a27e-4c20-bd53-266ab6aa3de6, 50348bd8-7c8d-47d8-9d95-a1e20e5decc8, f3bd946a-f42f-4343-8de5-6092ab6de36b, 57628681-9510-4bdc-8183-c3ae5fbf5b6b, 95b971ce-8e6f-46dc-ab85-a7b729cc9944, 1ffe442d-6bc6-445e-8b68-0d3ed6552dec, 98a4f10a-a045-492a-a621-fe1f3b117103, 5d6285d0-d714-4c2e-836f-47dc65ad598c, 1679e880-0db3-4a64-9a40-9f962314aa9e, 
##.....
2853c315-b9f3-409e-bb60-25b05a5cfa64, 39cb9c2e-63a8-4513-a5f8-a657f4ec43b6, d16d1d2e-6ebf-4b72-8840-fcc9d3c2dd52, 4220d653-e946-4741-8864-cc8246939003, b9623ff8-8fd4-4124-bd08-b128767ea60a
[champ.SVD have automatically select ALL factors contain at least two different values from your pd(sample_sheet.csv), if you don't want to analysis some of them, please remove them manually from your pd variable then retry champ.SVD().]<Sample_Name>
<Project>
<Array>
[Factors are ignored because they only indicate Name or Project, or they contain ONLY ONE value across all Samples.][<<<<<< ChAMP.SVD END >>>>>>]
[===========================]
[If the batch effect is not significant, you may want to process champ.DMP() or champ.DMR() or champ.BlockFinder() next, otherwise, you may want to run champ.runCombat() to eliminat batch effect, then rerun champ.SVD() to check corrected result.]Sample_Group     Slide[1,] 2.289393e-26 0.4906548[2,] 3.959362e-03 0.4906548[3,] 8.836284e-01 0.4906548[4,] 7.938020e-17 0.4906548[5,] 3.373293e-14 0.4906548[6,] 9.808115e-01 0.4906548[7,] 4.995617e-08 0.4906548[8,] 1.220760e-06 0.4906548[9,] 1.619588e-04 0.4906548
[10,] 2.288907e-02 0.4906548
[11,] 6.407854e-01 0.4906548
[12,] 5.390941e-02 0.4906548
[13,] 1.308536e-02 0.4906548
[14,] 6.585889e-01 0.4906548
[15,] 2.557036e-02 0.4906548
[16,] 5.390941e-02 0.4906548
[17,] 2.045547e-02 0.4906548
[18,] 4.091545e-02 0.4906548
[19,] 1.601403e-02 0.4906548
[20,] 6.241584e-01 0.4906548

差异分析

myDMP <- champ.DMP()

日志文件:

[===========================]
[<<<<< ChAMP.DMP START >>>>>]----------------------------
!!! Important !!! New Modification has been made on champ.DMP(): (1): In this version champ.DMP() if your pheno parameter contains more than two groups of phenotypes, champ.DMP() would do pairewise differential methylated analysis between each pair of them. But you can also specify compare.group to only do comparasion between any two of them.(2): champ.DMP() now support numeric as pheno, and will do linear regression on them. So covariates like age could be inputted in this function. You need to make sure your inputted "pheno" parameter is "numeric" type.--------------------------------[ Section 1:  Check Input Pheno Start ]You pheno is character type.Your pheno information contains following groups. >><tumor>:363 samples.<normal>:43 samples.[The power of statistics analysis on groups contain very few samples may not strong.]pheno contains only 2 phenotypescompare.group parameter is NULL, two pheno types will be added into Compare List.tumor_to_normal compare group : tumor, normal[ Section 1:  Check Input Pheno Done ][ Section 2:  Find Differential Methylated CpGs Start ]-----------------------------Start to Compare : tumor, normalContrast MatrixContrasts
Levels    ptumor-pnormalpnormal             -1ptumor               1You have found 212017 significant MVPs with a BH adjusted P-value below 0.05.Calculate DMP for tumor and normal done.[ Section 2:  Find Numeric Vector Related CpGs Done ][ Section 3:  Match Annotation Start ][ Section 3:  Match Annotation Done ][<<<<<< ChAMP.DMP END >>>>>>]
[===========================]
[You may want to process DMP.GUI() or champ.GSEA() next.]
myDMR <- champ.DMR()

日志文件:

[===========================]
[<<<<< ChAMP.DMR START >>>>>]
-----------------------------
!!! important !!! We just upgrate champ.DMR() function, since now champ.DMP() could works on multiple phenotypes, but ProbeLasso can only works on one DMP result, so if your pheno parameter contains more than 2 phenotypes, and you want to use ProbeLasso function, you MUST specify compare.group=c("A","B"). Bumphunter and DMRcate should not be influenced.[ Section 1:  Check Input Pheno Start ]You pheno is character type.Your pheno information contains following groups. >><tumor>:363 samples.<normal>:43 samples.[ Section 1:  Check Input Pheno Done ][ Section 2:  Run DMR Algorithm Start ]Loading required package: IlluminaHumanMethylation450kanno.ilmn12.hg19
3 cores will be used to do parallel Bumphunter computing.
According to your data set, champ.DMR() detected 6693 clusters contains MORE THAN 7 probes within300 maxGap. These clusters will be used to find DMR.[bumphunterEngine] Parallelizing using 3 workers/cores (backend: doParallelMC, version: 1.0.17).
[bumphunterEngine] Computing coefficients.
[bumphunterEngine] Smoothing coefficients.
Loading required package: rngtools
[bumphunterEngine] Performing 250 bootstraps.
[bumphunterEngine] Computing marginal bootstrap p-values.
[bumphunterEngine] Smoothing bootstrap coefficients.
[bumphunterEngine] cutoff: 0.473
[bumphunterEngine] Finding regions.
[bumphunterEngine] Found 3289 bumps.
[bumphunterEngine] Computing regions for each bootstrap.
[bumphunterEngine] Estimating p-values and FWER.
Bumphunter detected 1226 DMRs with P value <= 0.05.[ Section 2:  Run DMR Algorithm Done ][<<<<<< ChAMP.DMR END >>>>>>]
[===========================]
[You may want to process DMR.GUI() or champ.GSEA() next.]
save(myDMP,myDMR,file = "coread_methy_dmpr.rdata")

富集分析

# 富集分析
myGSEA <- champ.GSEA()

日志文件:

[===========================]
[<<<< ChAMP.GSEA START >>>>>]
-----------------------------
<< Prepare Gene List Ready  >>
<< Start Do GSEA on each Gene List  >>
<< Do GSEA on Gene list DMP>>
<< Pale Fisher Exact Test will be used to do GSEA >><< The category information is downloaded from MsigDB, and only simple Fisher Exact Test will be used to calculate GSEA. This method is suitable if your genes has equalivalent probability to be enriched. If you are using CpGs mapping genes, gometh method is recommended.>> 
<< Done for Gene list DMP >>
<< Do GSEA on Gene list DMR>>
<< Pale Fisher Exact Test will be used to do GSEA >><< The category information is downloaded from MsigDB, and only simple Fisher Exact Test will be used to calculate GSEA. This method is suitable if your genes has equalivalent probability to be enriched. If you are using CpGs mapping genes, gometh method is recommended.>> 
<< Done for Gene list DMR >>
[<<<<< ChAMP.GSEA END >>>>>>]
[===========================]
save(myGSEA,file = "coread_methy_gsea.rdata")

ChAMP实在是太简单了,不管多少样本都是几行代码完事,你值得拥有!

这篇关于ChAMP分析TCGA结直肠癌甲基化数据实战的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/415126

相关文章

[职场] 公务员的利弊分析 #知识分享#经验分享#其他

公务员的利弊分析     公务员作为一种稳定的职业选择,一直备受人们的关注。然而,就像任何其他职业一样,公务员职位也有其利与弊。本文将对公务员的利弊进行分析,帮助读者更好地了解这一职业的特点。 利: 1. 稳定的职业:公务员职位通常具有较高的稳定性,一旦进入公务员队伍,往往可以享受到稳定的工作环境和薪资待遇。这对于那些追求稳定的人来说,是一个很大的优势。 2. 薪资福利优厚:公务员的薪资和

【服务器运维】MySQL数据存储至数据盘

查看磁盘及分区 [root@MySQL tmp]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical)

React+TS前台项目实战(十七)-- 全局常用组件Dropdown封装

文章目录 前言Dropdown组件1. 功能分析2. 代码+详细注释3. 使用方式4. 效果展示 总结 前言 今天这篇主要讲全局Dropdown组件封装,可根据UI设计师要求自定义修改。 Dropdown组件 1. 功能分析 (1)通过position属性,可以控制下拉选项的位置 (2)通过传入width属性, 可以自定义下拉选项的宽度 (3)通过传入classN

SQL Server中,查询数据库中有多少个表,以及数据库其余类型数据统计查询

sqlserver查询数据库中有多少个表 sql server 数表:select count(1) from sysobjects where xtype='U'数视图:select count(1) from sysobjects where xtype='V'数存储过程select count(1) from sysobjects where xtype='P' SE

高度内卷下,企业如何通过VOC(客户之声)做好竞争分析?

VOC,即客户之声,是一种通过收集和分析客户反馈、需求和期望,来洞察市场趋势和竞争对手动态的方法。在高度内卷的市场环境下,VOC不仅能够帮助企业了解客户的真实需求,还能为企业提供宝贵的竞争情报,助力企业在竞争中占据有利地位。 那么,企业该如何通过VOC(客户之声)做好竞争分析呢?深圳天行健企业管理咨询公司解析如下: 首先,要建立完善的VOC收集机制。这包括通过线上渠道(如社交媒体、官网留言

数据时代的数字企业

1.写在前面 讨论数据治理在数字企业中的影响和必要性,并介绍数据治理的核心内容和实践方法。作者强调了数据质量、数据安全、数据隐私和数据合规等方面是数据治理的核心内容,并介绍了具体的实践措施和案例分析。企业需要重视这些方面以实现数字化转型和业务增长。 数字化转型行业小伙伴可以加入我的星球,初衷成为各位数字化转型参考库,星球内容每周更新 个人工作经验资料全部放在这里,包含数据治理、数据要

如何在Java中处理JSON数据?

如何在Java中处理JSON数据? 大家好,我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天我们将探讨在Java中如何处理JSON数据。JSON(JavaScript Object Notation)作为一种轻量级的数据交换格式,在现代应用程序中被广泛使用。Java通过多种库和API提供了处理JSON的能力,我们将深入了解其用法和最佳

两个基因相关性CPTAC蛋白组数据

目录 蛋白数据下载 ①蛋白数据下载 1,TCGA-选择泛癌数据  2,TCGA-TCPA 3,CPTAC(非TCGA) ②蛋白相关性分析 1,数据整理 2,蛋白相关性分析 PCAS在线分析 蛋白数据下载 CPTAC蛋白组学数据库介绍及数据下载分析 – 王进的个人网站 (jingege.wang) ①蛋白数据下载 可以下载泛癌蛋白数据:UCSC Xena (xena

PyTorch模型_trace实战:深入理解与应用

pytorch使用trace模型 1、使用trace生成torchscript模型2、使用trace的模型预测 1、使用trace生成torchscript模型 def save_trace(model, input, save_path):traced_script_model = torch.jit.trace(model, input)<

中国341城市生态系统服务价值数据集(2000-2020年)

生态系统服务反映了人类直接或者间接从自然生态系统中获得的各种惠益,对支撑和维持人类生存和福祉起着重要基础作用。目前针对全国城市尺度的生态系统服务价值的长期评估还相对较少。我们在Xie等(2017)的静态生态系统服务当量因子表基础上,选取净初级生产力,降水量,生物迁移阻力,土壤侵蚀度和道路密度五个变量,对生态系统供给服务、调节服务、支持服务和文化服务共4大类和11小类的当量因子进行了时空调整,计算了