Skip to content

Commit

Permalink
Update RA_pcs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
N3ha-Rao authored Dec 6, 2024
1 parent 34fd745 commit 729eca9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions RA_pcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Python code to obtain RA_pcs.txt from ra_pruned.evec

# Read the input file
input_file = "ra_pruned.evec"
output_file = "RA_pcs.txt"

with open(input_file, 'r') as f:
lines = f.readlines()

# Remove the first line
lines.pop(0)

# Split the first column into two columns and remove the last column
formatted_lines = []
for line in lines:
split_line = line.split()
split_column = split_line[0].split(":")
formatted_line = split_column + split_line[1:-1]
formatted_lines.append(formatted_line)

# Add header with consistent spacing
header = "FID IID PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10\n"

# Write to the output file
with open(output_file, 'w') as f:
f.write(header)
for line in formatted_lines[1:]:
f.write(' '.join(line) + '\n')

0 comments on commit 729eca9

Please sign in to comment.