CscoreTool接HicExplorer進(jìn)行A/B分析

主要提及summary文件的生成過程

summary文件具體內(nèi)容:

第1列). Read Name 名稱

第2列). 染色體

第3列). 位置

第4列). 方向

第5列). 染色體

第6列). 位置

第7列). 方向

首先由hicexplorer中hicBuildMatrix建立矩陣時,參數(shù)-outBam生成一個bam文件

Output bam file to process. Optional parameter. A bam file containing all valid Hi-C reads can be created using this option. This bam file could be useful to inspect the distribution of valid Hi-C reads pairs or for other downstream analyses, but is not used by any HiCExplorer tool. Computation will be significantly longer if this option is set.

由此bam文件生成CscoreTool所需要的summary文件

首先將成對數(shù)據(jù)合并為一行
#!/usr/bin/python
# -*- coding: UTF-8 -*-

old = open('/home/panda/桌面/new_m1-1.bed','r')
new = open('/home/panda/桌面/new_m1-1.bed','w')

line0 = old.readline()
while line0:
    line = line0.rstrip().split('\t')
    line1 = old.readline().rstrip().split('\t')
    line2 = (line[0] + '\t' + line[1] + '\t' + line[2] + '\t' + line[3] + '\t' + line[4] + '\t' + line[5] + '\t' + line1[0] + '\t' + line1[1] + '\t' + line1[2] + '\t' + line1[3] + '\t' + line1[4] + '\t' + line1[5] + '\n')
    new.write(line2)
    line0 = old.readline()
其次提取summary文件所需信息
#!/usr/bin/python
# -*- coding: UTF-8 -*-

old = open('/home/panda/桌面/new_m1-1.bed','r')
new = open('/home/panda/桌面/new_new_M1-1.summary','w')

line0 = old.readline()
while line0:
    line = line0.rstrip().split('\t')
    line1 = (line[3] + '\t' + line[0] + '\t' + line[1] + '\t' + line[5] + '\t' + line[6] + '\t' + line[7] + '\t' + line[11] + '\n')
    new.write(line1)
    line0 = old.readline()

2、此外windows.bed文件的生成(該文件用于指定要分析的基因組窗口大?。?/h3>

下載CscoreTool文件夾中有g(shù)enerateEqualLengthBed.cpp文件

對generateEqualLengthBed.cpp執(zhí)行命令

$ g++ -o generateEqualLengthBed generateEqualLengthBed.cpp

生成一個可執(zhí)行文件generateEqualLengthBed

###執(zhí)行以下命令生成windows.bed
###對于常見物種chrSizes.txt(染色體大小文件)可以直接下載,直接執(zhí)行下面的命令
$ generateEqualLengthBed <chrSizes.txt> <out.bed> <windowsize>

###不常見的物種,chrSizes.txt可以由samtools生成的**reference.fasta.fai**文件代替
###執(zhí)行以下命令
$ samtools faidx reference.fasta  ##會生成reference.fasta.fai文件
$ generateEqualLengthBed <reference.fasta.fai> <out.bed> <windowsize>  ##生成windows.bed文件

番外,文件中特定列的內(nèi)容替換

###將第一列內(nèi)容替換為:chr1
#!/usr/bin/python
# -*- coding: UTF-8 -*-

old = open('/home/panda/桌面/M2.bedGraph','r')
new = open('/home/panda/桌面/new_M2.bedGraph','w')

line0 = old.readline()
while line0:
    line = line0.rstrip().split('\t')
    a = 'chr1'
    line[0] = a
    line1 = (line[0] + '\t' + line[1] + '\t' + line[2] +'\t' + line[3] + '\n')
    new.write(line1)
    line0 = old.readline()
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容