import time from rpy2.robjects.packages import importr from rpy2 import robjects import pandas as pd from rpy2.robjects import pandas2ri maftools = importr("maftools") # 读取 MAF 文件 # 读取 maf 文件 maf_df = pd.read_csv('example.maf', sep='\t', comment='#') # 转为 csv 文件 maf_df.to_csv('example.csv', index=False) # 1. 准备数据 data = pd.read_csv('example.csv') # df = pd.DataFrame(df_maf) print(data) # for name, values in data.iteritems(): # print(name) # # 将 DataFrame 转为 R 中的 DataFrame # maf = pandas2ri.py2rpy_pandasdataframe(df_maf) # # # # # # # # 调用 maftools 中的 read.maf() 函数读取 MAF 文件 # maf_parsed = robjects.r('read.maf')(maf) # # # # # 调用 maftools 中的 oncogenes() 函数进行数据分析 # onco = robjects.r('oncogenes')(maf_parsed)