Question: i have an issue with my python code that i need to fix as you can see i ' m trying to loop throught a

i have an issue with my python code that i need to fix as you can see i'm trying to loop throught a data frame and find values but it won't work ?# Loop through rows and perform statistical tests
for i in range(df_len):
flu_values = np.log(df.iloc[i, df.columns.isin(flu_sample_names)].tolist())
rsv_values = np.log(df.iloc[i, df.columns.isin(rsv_sample_names)].tolist())
# One-sample t-test for flu samples
df.at[i, "mean_flu_ratio"]= np.mean(flu_values)
df.at[i,"p_value_flu"]= stats.ttest_1samp(np.log(df.iloc[i, df.columns.isin(flu_sample_names)].tolist()),0.0).pvalue
# One-sample t-test for rsv samples
df.at[i, "mean_rsv_ratio"]= np.mean(rsv_values)
df.at[i,"p_value_rsv"]= stats.ttest_1samp(rsv_values, 0.0).pvalue
# Correct p-values for multiple testing using Bonferroni correction
df["corrected_p_value_rsv"]= df["p_value_rsv"]* df_len
df["corrected_p_value_flu"]= df["p_value_flu"]* df_len
# Mark genes differentially expressed based on conditions
df["Selected_rsv_feature"]=(df["corrected_p_value_rsv"]<0.05) & (np.abs(df["mean_rsv_ratio"])>1)
df["Selected_flu_feature"]=(df["corrected_p_value_flu"]<0.05) & (np.abs(df["mean_flu_ratio"])>1)
# If it passes either condition, set Selected_feature = True
df["Selected_feature"]= df["Selected_rsv_feature"]| df["Selected_flu_feature"]i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!