绘制人类各条染色体缺失/重复统计柱状图。
读取数据文件函数
import pandas as pd
import matplotlib as plt
def read_file(file_path: str):
if file_path.endswith(('.tsv', '.txt')):
# 缺失值填充为NA
return pd.read_csv(file_path, sep='\t').fillna('NA') if os.path.exists(file_path) else pd.DataFrame()
elif file_path.endswith(('.xls', '.xlsx')):
return pd.read_excel(file_path).fillna('NA') if os.path.exists(file_path) else pd.DataFrame()
else:
raise Exception("ERROR FILE FORMAT")
合并绘图数据
def merge_statistics(outdir='./'):
# 读取文件
dataframe1=read_file(file_path=outdir + "data1.tsv")
dataframe2=read_file(file_path