Aging Clock running python script

Viewed 23

Hi Stack Overflow Community,

I have very little experience with Python, but want to run the following script which I found on Github: https://github.com/Meyer-DH/AgingClock

It is an aging predictor for RNA-Seq data, which I want to apply on my own dataset. To test out the script I first wanted to just use the example given on github. However, I already failed at running the script even with this data.

Here is what I got:

import numpy as np
import pandas as pd

cd /Users/....
df = pd.read_csv('GSE65765_CPM.csv', sep='\t')

Now calling the data frame I have imported works and I want to apply the first function to make it binary:

make_binary(df, filter_genes='WBG')

The return when I call the function however looks like this: enter image description here

So instead of having it binarized I only receive the column with the gene name ID's. The question is probably very silly, but perhaps someone can help me with it.

Thank you in advance!

1 Answers

tl;dr: You're doing it wrong. ;-)

The test_predict() function already knows the proper calling sequence. Recommend you follow its lead.

Correct input dataframe should look like this:

(Pdb) l
 13         :return: A binarized copy of the original data without meta-information
 14         '''
 15         breakpoint()
 16  ->     df_bin = df.copy()
 17         df_bin = df_bin.filter(regex=filter_genes)  # get the gene columns
 18         df_bin[df_bin == 0] = np.nan  # mask 0-genes that skew the median
(Pdb) p df
            WBGene00197333  WBGene00198386  ...  WBGene00010967  WBGene00014473
SRR1793993             0.0             0.0  ...       78.117815        0.000000
SRR1793991             0.0             0.0  ...       59.618577        0.000000
SRR1793994             0.0             0.0  ...       86.492735        0.016913
SRR1793992             0.0             0.0  ...       76.459508        0.000000

[4 rows x 46755 columns]
(Pdb) 

OTOH presenting an input dataframe of improper shape will yield the zero-column output that you see. This transpose is an important step:

https://github.com/Meyer-DH/AgingClock/blob/b6980/src/biological_age_prediction.py#L72

    cpm_df = cpm_df.T
Related