bin-map绘图,参数调整(test)
2024-03-26 本文已影响0人
花生学生信
每15行划分成一个bin,如果一个bin里15个值的和小于等于8,则将15个值都替换为0,如果一个bin里15个数的和大于等于22,则将15个值都替换为2,如过bin里的15个数的和大于8小于22,则将15个值都替换为1
###t.py
#########/public/home/fengting/demo/psvcp/test/zyy26bk/example7/hhzils/parent/H7L29_IR64/quncall/bin/plot
import sys
input_file = sys.argv[1]
output_file = sys.argv[2]
with open(input_file, 'r') as file:
lines = file.readlines()
data = [line.strip().split('\t') for line in lines]
for i in range(0, len(data), 15):
bin_values = [int(row[2]) for row in data[i:i+15] if i+15 <= len(data)]
bin_sum = sum(bin_values)
if bin_sum <= 8:
for j in range(i, min(i+15, len(data))):
data[j][2] = '0'
elif bin_sum >= 22:
for j in range(i, min(i+15, len(data))):
data[j][2] = '2'
else:
for j in range(i, min(i+15, len(data))):
data[j][2] = '1'
with open(output_file, 'w') as file:
for row in data:
file.write('\t'.join(row) + '\n')
调整前后
调整前后变化
把连续的坐标整合
##lxu.py
import sys
input_file = sys.argv[1]
with open(input_file, 'r') as file:
lines = file.readlines()
data = [line.strip().split('\t') for line in lines]
current_num = None
start_coord = None
end_coord = None
for row in data:
coord = row[1]
num = row[2]
if num == current_num:
end_coord = coord
else:
if current_num is not None:
print(row[0] + '\t' + start_coord + '\t' + end_coord + '\t' + current_num)
current_num = num
start_coord = coord
end_coord = coord
# Print the last interval
if current_num is not None:
print(data[-1][0] + '\t' + start_coord + '\t' + end_coord + '\t' + current_num)
整合后
如果不进行第一步的调整,bin的数目有4万2千个
circos报错,只能画2万5千个bin
发现用circos画bin确实不适合,然后发现rectchr可以把圆画成长方形,尝试中