Ausführen einer nichtparametrischen Statistikanalyse unter Verwendung eines Python JupyterHub-Skripts, aber ich habe NANPython

Python-Programme
Anonymous
 Ausführen einer nichtparametrischen Statistikanalyse unter Verwendung eines Python JupyterHub-Skripts, aber ich habe NAN

Post by Anonymous »

Ich möchte VCL als Ergebnisantwort in 3 verschiedenen Inkubationszeiten (1H, 2H, 3H) und 4 Behandlungsbedingungen (LT, LC, HTF, MRS) vergleichen. Siehe Code unten < /p>

Code: Select all

import pandas as pd
from scipy.stats import mannwhitneyu
from itertools import combinations
from statsmodels.stats.multitest import multipletests

# Clean column names if needed
df1.columns = df1.columns.str.strip().str.replace(' ', '_')

# Clean string values
df1['Treatment'] = df1['Treatment'].str.strip()
df1['Incubation_time'] = df1['Incubation_time'].astype(str).str.strip()

# Step 1: Exclude 0H incubation
df_no0H = df1[df1['Incubation_time'] != '0H']

# Step 2: Subset to only 1H time
df_1H = df_no0H[df_no0H['Incubation_time'] == '1H']

# Step 3: Prepare VCL data for 4 treatment groups
treatments = ['LT', 'LC', 'HTF', 'MRS']
group_data = {
t: df_1H[df_1H['Treatment'] == t]['VCL'].dropna().values
for t in treatments
}

# Step 4: Mann-Whitney U test for all pairs
results = []
pairs = list(combinations(treatments, 2))

for a, b in pairs:
if len(group_data[a]) >= 3 and len(group_data[b]) >= 3:
stat, p = mannwhitneyu(group_data[a], group_data[b], alternative='two-sided')
results.append({'Comparison': f'{a} vs {b}', 'U': stat, 'p-value': p})
else:
results.append({'Comparison': f'{a} vs {b}', 'U': None, 'p-value': None})

# Step 5: Bonferroni correction
pvals = [r['p-value'] for r in results if r['p-value'] is not None]
_, corrected, _, _ = multipletests(pvals, method='bonferroni')

# Add corrected p-values back into results
i = 0
for r in results:
if r['p-value'] is not None:
r['p-value (Bonferroni)'] = corrected[i]
i += 1
else:
r['p-value (Bonferroni)'] = None

# Step 6: Convert to DataFrame for display
results_df = pd.DataFrame(results)
print(results_df)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post