Skip to content

Commit

Permalink
Update for Revision
Browse files Browse the repository at this point in the history
  • Loading branch information
fmbauer committed Aug 21, 2024
1 parent 5a8f8a2 commit a59b0bb
Show file tree
Hide file tree
Showing 17 changed files with 3,904 additions and 19 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
krs_P0,krs_P1,krs_P2,krs_P3
0.0,0.0,0.00017052912290617433,0.0002639360971845172
0.00030060005993207334,0.0003582225540406684,0.0003787090107898672,0.0005878974281014213
0.00044721850705771904,0.0005099354157625003,0.0005293977378133673,0.0007788794713755109
0.0007076956728384689,0.0007912561003321214,0.0008179937456090164,0.001136797958505673
0.0012439486905185975,0.001421589926878574,0.0014890102492802891,0.0021042846811132315
0.0018322014804505213,0.002039472680292055,0.0021128653148593125,0.0029360538909289397
0.002384477564170751,0.002621203931688025,0.0027151712043451816,0.003714215409340092
0.0029074020173606757,0.0032334247218034993,0.003353539995024071,0.004661301125794276
0.0033544799676322374,0.0037071827615338575,0.003818903007081381,0.005348097899723868
0.003841456358814563,0.004238172138510451,0.004348583938850652,0.006065645409674563
0.004448695408992153,0.0049252443784889135,0.0050497436571144425,0.007060388972815897
0.0051922276392787434,0.005711097929493183,0.005858329743300231,0.008144736935591987
0.006009119489235185,0.006589851708842187,0.0067629276347532016,0.009320885345363641
0.006794111383041575,0.0074456784235855345,0.007626097894736625,0.010433750244366815
0.00752066784488896,0.008247972167972666,0.00844678654315839,0.01148557970231376
0.008227800762961176,0.009011227191472522,0.009234757201750394,0.012478658032991974
0.008912014899166277,0.009743016804967312,0.009979565366570207,0.013421518633049518
0.009553410227769076,0.010450037830167966,0.010704008547184339,0.014317611997971613
0.010175522502462795,0.011119133674319517,0.011387487467945996,0.015166986031929347
0.010766689797009423,0.011760686756671477,0.012050648632763188,0.015966920670494517
0.011309126160439298,0.012362199220631118,0.012666534600045933,0.016723108825701893
0.01184126749619731,0.012933082378686045,0.013247954249351076,0.017426580021822857
0.01233037571802794,0.013468270029243643,0.013797743578893112,0.01808835937385587
0.012792179805177314,0.013973060953707485,0.014316979646544674,0.01870558571242662
0.013235633622205045,0.01445726780634857,0.014808268901562529,0.019278974377453337
0.013657353280786327,0.014910090838265928,0.015273225137247189,0.019817931647864113
0.01405346747054703,0.015338675964600684,0.015713917033839994,0.02032697924508732
0.014429109558180718,0.015742803051402365,0.01613230045559699,0.02080321403822758
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
krs_P0,krs_P1,krs_P2,krs_P3
0.0,0.0,1.9430892282840468e-05,2.2408180607858668e-05
5.5027925338934905e-05,6.826716630416238e-05,5.320759985603394e-05,7.600784925532395e-05
0.00011203395217468929,0.00011202883695429011,8.815328530471953e-05,9.226258911869482e-05
0.00017030582106829597,0.00015726468298626946,0.00012233757082492677,0.00010778878403559057
0.00022730754411132877,0.00021526480697424514,0.00018268410355329678,0.00019196498038546737
0.0003058158425913934,0.0002754816042110409,0.00023375185812113172,0.0002467555643484848
0.00037452300544379015,0.00032982375190437647,0.00028269002813894836,0.00029270551693698284
0.00044742187621365115,0.00039218135696868293,0.00034221195797950365,0.00038320957754690074
0.0005352897920579016,0.00045952171076536356,0.00040034239816824836,0.00045505926144392956
0.000612699344329978,0.0005220390047803186,0.0004616909789997843,0.0005150404934228325
0.0006825275095356637,0.0005937970232029881,0.0005246879607362602,0.0006074087509265712
0.0007667786021254421,0.000656363613812417,0.0005841546498663003,0.0006850671611360848
0.0008387394705520445,0.000714815098840523,0.0006479033086303231,0.0007489306664414173
0.000908545057434724,0.0007687765629103327,0.0006982929802068331,0.0008192415237033828
0.0009829909277261413,0.0008248930355557927,0.0007470888886993556,0.0008871461887639607
0.0010482058506291574,0.0008754134805907748,0.0007962170696908162,0.0009427873356395898
0.001112470660991921,0.0009273665831752263,0.0008463833640968701,0.0009975618088725118
0.0011867469852760374,0.0009786612742115665,0.000885676872422532,0.0010435497517856677
0.0012461236747786212,0.0010271001744623428,0.000925719743264234,0.0010835879639137362
0.0013038731939664415,0.0010700551070369092,0.0009646139558703474,0.0011194749772571024
0.0013648188022824654,0.0011138048910001959,0.001004352476126638,0.0011598376677215616
0.00141989062262217,0.0011556916361055891,0.0010376690082156595,0.0011854866184403709
0.00146972943819261,0.0011968355965489392,0.0010716148471816018,0.0012150109562342262
0.0015262787346216064,0.0012386196775563258,0.0011022436672833583,0.0012359671188702656
0.001574266180167995,0.0012760567717592247,0.0011237042520546216,0.0012569080906360093
0.0016183514430844665,0.0013165830656533043,0.0011476324954841593,0.0012719659435486649
0.0016704098046616944,0.0013453009399376835,0.0011729131158262887,0.0012806813570484905
0.0017098060381409148,0.0013749576875269698,0.0011973396838137354,0.0012883717096179382
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,53 @@
import seaborn as sns
from scipy.stats import linregress
import os
from statsmodels.stats.multicomp import pairwise_tukeyhsd
import scikit_posthocs as sp
from statannotations.Annotator import Annotator
import pingouin as pg
from scipy.stats import shapiro, levene
from statsmodels.stats.anova import anova_lm
from statsmodels.formula.api import ols
import scikit_posthocs as sp
from statannotations.Annotator import Annotator

dir = os.path.dirname(os.path.abspath(__file__))

'''FIGURE 3'''
'''SUP. FIGURE 2'''
# 'load data'
idx = ['P0','P1','P2','P3']
P_lvl = [1.8,3.3,4.6,7.7]
a_axial = pd.read_csv(dir + '/a_axial.csv')
r_crown = pd.read_csv(dir + '/r_crown.csv')
r_leaves = pd.read_csv(dir + '/r_leaves.csv')
rootshoot = pd.read_csv(dir + '/root_shoot_ratio.csv')
response_data = pd.read_excel(dir + '/response_data.xlsx')
krs_df = pd.read_csv(dir + '/KRS_results.csv')
krs_sd_df = pd.read_csv(dir + '/KRS_results_sd.csv')

'''PANEL A'''
# Conduct Shapiro-Wilk test for normality
stat, p = shapiro(a_axial['value'])
print(f'Shapiro-Wilk test statistic: {stat}, p-value: {p}')
shapiro_results = {}
for group, values in a_axial.groupby('variable')['value']:
stat, p = shapiro(values)
shapiro_results[group] = (stat, p)
print(f'Group: {group}, Shapiro-Wilk test statistic: {stat}, p-value: {p}')

# Levene test for homogeneity of variances
grouped_values = [values for name, values in a_axial.groupby('variable')['value']]
levene_stat, levene_p = levene(*grouped_values)
print(f'Levene test statistic: {levene_stat}, p-value: {levene_p}')

model = ols('value ~ C(variable)', data=a_axial).fit()
anova_results = anova_lm(model)
print(anova_results)

#Plot
plt.subplots(figsize=(6,4))
tukey_df = posthoc_tukey(a_axial, val_col="value", group_col="variable")
print(tukey_df)
remove = np.tril(np.ones(tukey_df.shape), k=0).astype("bool")
tukey_df[remove] = np.nan
molten_df = tukey_df.melt(ignore_index=False).reset_index().dropna()
Expand All @@ -39,6 +72,26 @@
plt.show()

'''PANEL B'''
# Conduct Shapiro-Wilk test for normality
stat, p = shapiro(r_crown['value'])
print(f'Shapiro-Wilk test statistic: {stat}, p-value: {p}')
shapiro_results = {}
for group, values in r_crown.groupby('variable')['value']:
stat, p = shapiro(values)
shapiro_results[group] = (stat, p)
print(f'Group: {group}, Shapiro-Wilk test statistic: {stat}, p-value: {p}')


# Levene test for homogeneity of variances
grouped_values = [values for name, values in r_crown.groupby('variable')['value']]
levene_stat, levene_p = levene(*grouped_values)
print(f'Levene test statistic: {levene_stat}, p-value: {levene_p}')

model = ols('value ~ C(variable)', data=r_crown).fit()
anova_results = anova_lm(model)
print(anova_results)

#Plot
plt.subplots(figsize=(6,4))
tukey_df = posthoc_tukey(r_crown, val_col="value", group_col="variable")
remove = np.tril(np.ones(tukey_df.shape), k=0).astype("bool")
Expand All @@ -57,6 +110,23 @@
plt.show()

'''PANEL C'''
# Conduct Shapiro-Wilk test for normality
shapiro_results = {}
for group, values in r_leaves.groupby('variable')['value']:
stat, p = shapiro(values)
shapiro_results[group] = (stat, p)
print(f'Group: {group}, Shapiro-Wilk test statistic: {stat}, p-value: {p}')

# Levene test for homogeneity of variances
grouped_values = [values for name, values in r_leaves.groupby('variable')['value']]
levene_stat, levene_p = levene(*grouped_values)
print(f'Levene test statistic: {levene_stat}, p-value: {levene_p}')

model = ols('value ~ C(variable)', data=r_leaves).fit()
anova_results = anova_lm(model)
print(anova_results)

#Plot
plt.subplots(figsize=(6,4))
tukey_df = posthoc_tukey(r_leaves, val_col="value", group_col="variable")
remove = np.tril(np.ones(tukey_df.shape), k=0).astype("bool")
Expand All @@ -75,7 +145,7 @@
plt.show()

'''PANEL D'''
rootshoot['root_shoot'] = rootshoot.root_dm / rootshoot.shoot_dm
rootshoot['root_shoot'] = rootshoot.root_dm / (rootshoot.shoot_dm+rootshoot.root_dm)
grouped = rootshoot.groupby('level')
def standard_error(x):
return np.std(x, ddof=1) / np.sqrt(x.count())
Expand All @@ -96,29 +166,30 @@ def standard_error(x):
plt.text(x, result['root_shoot_mean'].loc[result['level'] == level].values[0] + 0.1, level, ha='center')
plt.plot(x_values, y_fit, linestyle='--', color='red', label='Linear Regression Line')
plt.text(
2.5, 1.3, f"R²: {r_value**2:.2f}",
0.5, 0.6, f"R²: {r_value**2:.2f}",
bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 10})
ax.set_xlabel('Pcal mg 100g$^{-1}$')
ax.set_ylabel('[-]')
plt.xlim(1.5, 8)
plt.ylim(0.6, 2)
plt.ylim(0.3, 0.7)
plt.legend()
plt.tight_layout()
plt.show()


'''FIGURE 5'''
'''FIGURE 3'''
'''PLOT PANEL A'''
data = pd.read_excel('C:/Users/mobil/Desktop/Experiment_Rhizotrons/response_curves/response_data.xlsx')
adjusted_data = data[(data['Pcal'] >= 1.8) & (data['Pcal'] <= 7.3)]
#data = pd.read_excel('C:/Users/mobil/Desktop/Experiment_Rhizotrons/response_curves/response_data.xlsx')
data = response_data
adjusted_data = data[(data['Pcal'] >= 1.8) & (data['Pcal'] <= 7.7)]
X = adjusted_data[['Pcal']]
y = adjusted_data['a_axial']
X_with_const = sm.add_constant(X)
model = sm.OLS(y, X_with_const).fit()
print(model.summary())
p_value = model.pvalues[1]
print(f"P-value for 'Pcal': {p_value}")
pcal_values = np.linspace(1.8, 7.3, 500)
pcal_values = np.linspace(1.8, 7.7, 500)
X_plot = sm.add_constant(pcal_values) # Remember to add constant for prediction
predictions = model.predict(X_plot)
r_squared = model.rsquared
Expand All @@ -129,7 +200,7 @@ def standard_error(x):
plt.text(x=0.5, y=0.1, s=f'R² = {r_squared:.4f}\nP-value = {p_value:.4g}', fontsize=12, transform=plt.gca().transAxes)
plt.xlabel('P$_{Cal}$ (g 100g$^{-1}$)')
plt.ylabel('axial root radii (cm)')
plt.xlim(1.6, 7.5)
plt.xlim(1.6, 8)
plt.ylim(0.02, 0.12)
plt.show()

Expand All @@ -152,7 +223,7 @@ def standard_error(x):
plt.xlabel('P$_{Cal}$/DM')
plt.ylabel('crown root elongation (cm d^-1)')
plt.xlim(0, 0.0011)
plt.ylim(0, 7.8)
plt.ylim(0, 8)
plt.ticklabel_format(axis= 'both',style = 'scientific',scilimits=(-2,5))
plt.show()

Expand All @@ -172,6 +243,49 @@ def standard_error(x):
plt.plot(Pcal_observed_range, r_leaf_pred, color='black')
plt.xlabel('P$_{Cal}$ (g 100g$^{-1}$)')
plt.ylabel('leaf elongation rate (cm d^-1)$')
plt.xlim(1.6, 7.5)
plt.xlim(1.6, 8)
plt.ylim(2.5, 15.5)
plt.show()


'''Supplementary Figure 4'''
df = pd.DataFrame(rootshoot)
df['shoot_dm + root_dm'] = df['shoot_dm'] + df['root_dm']
level_mapping = {"P0": 1.8, "P1": 3.3, "P2": 4.6, "P3": 7.7}
df['level'] = df['level'].map(level_mapping)
df_grouped = df.groupby('level').agg(['mean', 'std'])

plt.figure(figsize=(6,4))
plt.plot(df_grouped.index, df_grouped['shoot_dm']['mean'], marker='o',label = 'Biomass shoot')
plt.fill_between(df_grouped.index, df_grouped['shoot_dm']['mean'] - df_grouped['shoot_dm']['std'],
df_grouped['shoot_dm']['mean'] + df_grouped['shoot_dm']['std'], alpha=0.2)
plt.plot(df_grouped.index, df_grouped['root_dm']['mean'], marker='o', label = 'Biomass root')
plt.fill_between(df_grouped.index, df_grouped['root_dm']['mean'] - df_grouped['root_dm']['std'],
df_grouped['root_dm']['mean'] + df_grouped['root_dm']['std'], alpha=0.2)
plt.plot(df_grouped.index, df_grouped['shoot_dm + root_dm']['mean'], marker='o', label = 'Biomass plant')
plt.fill_between(df_grouped.index, df_grouped['shoot_dm + root_dm']['mean'] - df_grouped['shoot_dm + root_dm']['std'],
df_grouped['shoot_dm + root_dm']['mean'] + df_grouped['shoot_dm + root_dm']['std'], alpha=0.2)
plt.xlabel('P$_{soil}$')
plt.ylabel('Dry biomass [g]')
plt.ylim(1,11)
plt.xlim(1.6, 8)
plt.legend()
plt.show()

'''Supplementary Figure 5'''

rows_to_plot = [6, 13, 20, 27]
line_styles = ['-', '--', '-.', ':']
point_markers = ['o', 's', 'D', '^']
legend_labels = ['7 DAS', '14 DAS', '21 DAS', '28 DAS']
plt.figure(figsize=(10, 7))
for i, row in enumerate(rows_to_plot):
values = krs_df.loc[row, ['krs_P0', 'krs_P1', 'krs_P2', 'krs_P3']].values
std_devs = krs_sd_df.loc[row, ['krs_P0', 'krs_P1', 'krs_P2', 'krs_P3']].values
plt.errorbar(P_lvl, values, yerr=std_devs, fmt=line_styles[i] + point_markers[i], capsize=5, color='black', label=legend_labels[i])
plt.xlabel('P$_{soil}$')
plt.ylabel('K$_{rs}$ (cm² d$^{-1}$)')
plt.ylim(0, 0.025)
plt.grid()
plt.legend()
plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,24 @@ variable,value
P0,0.4069888296703522
P0,0.20145526095972843
P0,2.655896231882634
P0,6.004191905485569
P0,1.835820484698392
P0,1.5983496513785964
P0,7.137807992205309
P1,0.2461394157898003
P1,1.0849921000228604
P1,0.7224329768288287
P1,0.9130196835680513
P1,1.0643374230432476
P1,0.7861815374918731
P1,2.1601997215510345
P1,1.566359007372194
P1,1.3008379043428926
P2,0.2695678868844662
P2,0.19231977713775533
P2,0.7041493736558947
P2,0.19578787288601868
P2,4.904461163412021
P2,2.006413428677393
P2,2.7375809064243106
P2,2.539780555797498
P2,1.9164469200335799
P3,0.7362927320999927
P3,3.7840653191149354
P3,3.1386825176005466
P3,8.095972841254206
P3,6.593720347825664
P3,5.649212327296748
Binary file not shown.
2 changes: 1 addition & 1 deletion experimental/pdef/simulation/sim.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys;
CPBdir = "../../.."
CPBdir = "../.."
sys.path.append(CPBdir + "/src");
sys.path.append(CPBdir);
sys.path.append("../../..");
Expand Down
Loading

0 comments on commit a59b0bb

Please sign in to comment.