Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

Do you think physicians should have unions? Why or why not?

Answered: 1 week ago