This is a test version of Biostars. For the public version, visit https://www.biostars.org.
T test in python

Hi

I am trying to perform t test and ranksum test on my data. My input csv file looks like :

SRA ID  ERR169499              ERR169498              ERR169497
Label           1                      0                      1
TaxID     PRJEB3251_ERR169499  PRJEB3251_ERR169499    PRJEB3251_ERR169499
333046    0.05                 0.99                   99.61
1049      0.03                 2.34                   34.33
337090    0.01                 9.78                   23.22
99007     22.33                2.90                   0.00

I want to calculate the T- Test and rank sum test for every TaxID as in for every row. The code I have so far is :

 df = pd.read_csv('final_out_transposed.csv')
 for row in df.iterrows():
     tt_val, p_ttest = ttest_ind(df.sum_case, df.sum_ctrl)
     tr_val, p_ranksum = ranksums(df.sum_case, df.sum_ctrl)
     print(tt_val)
     print(p_ttest)
     print(tr_val)
     print(p_ranksum)

It is not helping me. I am guessing i have to use groupby. Any help will be highly appreciated.

python t test ranksum test

What's the error message? Also, isn't that going to attempt to perform the test on the first 3 header columns?

Check that there are no NAs (manage these with nan_policy), and also check your indices in sum_case and sum_ctrl

0 answers

No answers yet.

Log in to answer this question.