[c49071]: / Input_files / tsv2pkl.py

Download this file

21 lines (19 with data), 958 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#When eigenvec or tsv are converted to PKL, the PANDAS version and model version should be the same as DNNGP.
#So, please run the program in a DNNGP environment.
import pandas as pd
########Set path section
inpath=r".\wheat599_pc95.tsv" #Set input path
outpath=r".\wheat599_pc95.pkl" #Set output path
########Conversion format section
inpath=inpath.replace('\\','/') #Replace '\' with '/' in the input path.
outpath=outpath.replace('\\','/') #Replace '\' with '/' in the output path.
if "eigenvec" in inpath:
Gene = pd.read_csv(inpath, sep='\t',header=0,index_col=1) #read eigenvec file.
del Gene['#FID'] #Delete the '#FID' column
Gene.to_pickle(outpath) #output pkl file
elif "csv" in inpath:
Gene = pd.read_csv(inpath, sep=',',header=0,index_col=0) #read csv file.
Gene.to_pickle(outpath) #output pkl file
else:
Gene = pd.read_csv(inpath, sep='\t',header=0,index_col=0) #read tsv file.
Gene.to_pickle(outpath) #output pkl file