1.0 Introduction

The aim of this document is to explore by visualisation and modeling the results of season 1 trials. Season 1 is refered to the period of Sept 2022 to July 2023. In season 1 there were 2 main trials: soybean trial in the Ipunga village with 20 on-field experiments; and the common beans trials on 20 farmers fields in the Nambala village. these two villages are located in the Southern Highlands of Tanzania. Alongside these trials there were maize control plots. at each experimental site there were 3 main treatments and control: (1) tripple Superphosephate (TSP) fertilizers, (2) Rhizobium inoculation, (3) combination of rhizobium inoculation and TSP fertiliser. The non-treatment plots were set as control with no inputs.

The purpose of these experiments was to assess the effects of TSP fertiliser and inoculation on the grain and biomass yields of soybeans and beans. I will also, explore how variability in field management and field conditions such as soil influenced the results I see. For this version, I will start with soybean data season 1. the sample size is 20 farmers. each farmer represents a replicate in the experiment/trial.

2.0 Analyses

the first chunk of codes below loads the needed packages for my data analysis:

# Prerequisite packages
library(tidyverse)
library(reshape2)
library(ggpubr)
library(patchwork)
library(corrplot)

The dataframes and subsets needed for the indended analyses

## importing datafile of soybean experiment
ipungatrial <- read_csv("SOYA2true.csv")
ipungatrial2 <- read_csv("soyaN.csv")
## melting dataframe above to allow for creating a boxplot
ipunga <- melt(ipungatrial, id.vars='farmer_ID', measure.vars=c('controlGRAIN_t.ha', 'tspGRAIN_t.ha', 'inocuGRAIN_t.ha', 'tsp_inocuGRAIN_t.ha'))
#melting ipungatrial df for creating biomas yield boxplot
ipunga3 <- melt(ipungatrial, id.vars='farmer_ID', measure.vars=c('controlBIO_t.ha', 'tspBIO_t.ha', 'inocuBIO_t.ha', 'tspinocuBIO_t.ha'))
colnames(ipunga3) <- c("farmer_ID", "treatment", "yieldbiomas")
#renaming the variables in ipungaN dataframe
ipungaN <- melt(ipungatrial, id.vars='farmer_ID', measure.vars=c('controlgrainN_kg.ha', 'tspgrainN_kg.ha', 'inocugrainN_kg.ha', 'tsp_inocugrainN_kg.ha'))
colnames(ipungaN) <- c("farmer_ID", "treatment2", "grain_N")
ipungaNreduced <- ipungaN %>% select(farmer_ID, grain_N)
##renaming the variables in ipungaNB dataframe
ipungaNB <- melt(ipungatrial, id.vars='farmer_ID', measure.vars=c('controlBIO_Nkg.ha', 'tspBIO_Nkg.ha', 'inocuBIO_Nkg.ha', 'tspinocuBIO_Nkg.ha'))
colnames(ipungaNB) <- c("farmer_ID", "treatment", "Biomas_N")

2.1 Assesing yield variability attributable to farmer management, soil characteristics and treatments.

In Figure 1, I examine yield differences while exclusively focusing on control plots. This isolates the impact of field management and soil fertility on grain yields for the 20 participating farmers. The observed disparities are expected to be primarily associated with the variability in these factors. Figure 2 assess yield disparities across treatments. A scatter plots is employed to compare grain yields across distinct treatments. Each treatment is distinguished by varying colors or markers, facilitating a clear visual separation

#geom_point
plotb <- ggplot(ipungatrial, aes(x = farmer_ID, y = controlGRAIN_t.ha, color = farmer_ID)) + geom_point(size = 3)+ 
  ylab("grain yield (t/ha)") +
  xlab("farmers ")+
  ggtitle("Figure 1: Scatter plot of soybean yield among farmers \n(n=20)")+
  theme(plot.title = element_text(size = rel(1.5), hjust = 0.5)) +
  theme(plot.subtitle = element_text(size = rel(1.0), hjust = 0.5)) +
  theme(axis.title.y = element_text(size = rel(1.2), angle = 90, face = "bold")) +
  theme(axis.title.x = element_text(size = rel(1.2), angle = 360, face ="bold")) +
  theme(panel.border = element_rect(linetype = "solid", fill = NA)) +
  theme(axis.text.x = element_text(size = 12, 
    angle = 360,color ="black", face = "bold")) +
  theme(axis.text.y = element_text(size = 12,
    color ="black",face ="bold")) +
  theme(panel.background = element_blank())+
  theme(legend.position = "none")
plotb
## Warning: Removed 1 rows containing missing values (`geom_point()`).
plotc
## Warning: Removed 4 rows containing missing values (`geom_point()`).

Figure 1 above shows that yields among farmers vary, this might be due variability in management practices and soil. for instance the low yield for farmer 4 which had less than 0.5t/ha might be due to lack or late weeding see photo below.

Figure 3: A photo of unweeded soybean control plot taken in the Ipunga village in April 2023, the soybeans were at the pod filling stage

Figure 3: A photo of unweeded soybean control plot taken in the Ipunga village in April 2023, the soybeans were at the pod filling stage

The low yield for farmer 5 in figure 1 is probably due to poor soil especially low inherit P (4.9mg/kg) compared to farmer 14 who had higher inherit P (16.20 mg/kg) and had over 2t/ha of grain yield.

2.2 Modeling yield disparities across treatments

Figures below depict that there was difference in both grain and biomass yields across treatment. Further analysis using t-test also confirmed that the was significant difference (p<0.05) in grain yield of TSP treatment and that of the control by 0.43 t/ha. Also the yield of inoculation combined with TSP fertiliser had signicantly (p<0.05) more grain yield compared to the control by 0.55t/ha. A similar trend was also observed on the effect of the treatments on biomass yield (figure 5). This observation accentuates the effects of microbial inoculation and fertilization on soybean grain and biomass yields.

#boxplot 1: grainyield
plot1 <- ggplot(ipunga_df, aes(x =treatment, y = g_yield, fill = treatment)) +
  geom_boxplot(width = 0.5, outlier.size = 1.4) + 
    stat_summary(fun = "mean", geom = "point",
               shape = 8,
               size = 3,
               color = "white")+
  labs(x="treatments", y= "grain yield (t/ha)",
       title="Figure4:Soybean grain yields accross treatments",
         subtitle = "(n=20)")+
  theme(plot.title = element_text(size = rel(1.5), hjust = 0.5)) +
  theme(plot.subtitle = element_text(size = rel(1.0), hjust = 0.5)) +
  theme(axis.title.y = element_text(size = rel(1.2), angle = 90, face = "bold")) +
  theme(axis.title.x = element_text(size = rel(1.2), angle = 360, face ="bold")) +
  theme(panel.border = element_rect(linetype = "solid", fill = NA)) +
  theme(axis.text.x = element_text(size = 12, 
    angle = 360,color ="black", face = "bold")) +
  theme(axis.text.y = element_text(size = 12,
    color ="black",face ="bold")) +
  theme(panel.background = element_blank())+
  theme(legend.position = "none")
plot1
plot2
## Warning: Removed 4 rows containing non-finite values (`stat_boxplot()`).
## Warning: Removed 4 rows containing non-finite values (`stat_summary()`).

## summurize (means yields per treatment)
# Group by mean using dplyr
mean_yield <- ipunga_df %>% group_by(treatment) %>% 
  summarise(mean= mean(g_yield), std = sd(g_yield),
            .groups = 'drop') 
print(mean_yield)
## # A tibble: 4 × 3
##   treatment             mean   std
##   <fct>                <dbl> <dbl>
## 1 Control              0.939 0.566
## 2 TSP fertiliser       1.37  0.533
## 3 Inoculation          1.31  0.650
## 4 TSP with Inoculation 1.49  0.587
modelmean_yield <-lm(g_yield~treatment, data = ipunga_df)
summary(modelmean_yield)
## 
## Call:
## lm(formula = g_yield ~ treatment, data = ipunga_df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.91253 -0.44707 -0.09032  0.37393  1.40689 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     0.9393     0.1344   6.990 1.15e-09 ***
## treatmentTSP fertiliser         0.4342     0.1900   2.285  0.02527 *  
## treatmentInoculation            0.3728     0.1900   1.962  0.05366 .  
## treatmentTSP with Inoculation   0.5550     0.1900   2.921  0.00466 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5857 on 72 degrees of freedom
## Multiple R-squared:  0.1167, Adjusted R-squared:  0.07991 
## F-statistic: 3.171 on 3 and 72 DF,  p-value: 0.02934

2.3 Correlation of N concentration in grain and biomass with yields

2.3.1 N concentration in soybean grain and biomass across treatments

Figures below shows difference in levels of N concentration in both grains and biomass accross treatments. The inoculation and TSP fertiliser treatement resulted to more N concentration in both Seed and biomass (stem and leaves) probably due to efficiency in N fixation leading to more N being translocated to both seed and biomass.
plotL <- ggplot(ipungatrial2, aes(x =treatment, y = Grain_N, fill = treatment)) +
  geom_boxplot(width = 0.5, outlier.size = 1.4) + 
    stat_summary(fun = "mean", geom = "point",
               shape = 8,
               size = 3,
               color = "white")+
  labs(x="treatments", y= "N concentration in grain (kg/ha)",
       title="Figure 6: Seed N concentration across treatments",
         subtitle = "(n=20)")+
  theme(plot.title = element_text(size = rel(1.5), hjust = 0.5)) +
  theme(plot.subtitle = element_text(size = rel(1.0), hjust = 0.5)) +
  theme(axis.title.y = element_text(size = rel(1.2), angle = 90, face = "bold")) +
  theme(axis.title.x = element_text(size = rel(1.2), angle = 360, face ="bold")) +
  theme(panel.border = element_rect(linetype = "solid", fill = NA)) +
  theme(axis.text.x = element_text(size = 12, 
    angle = 360,color ="black", face = "bold")) +
  theme(axis.text.y = element_text(size = 12,
    color ="black",face ="bold")) +
  theme(panel.background = element_blank())+
  theme(legend.position = "none")+
  scale_fill_manual(values=c("#808080", "#696969","#778899", "#708090"))
plotL
plotZ

2.3.2 Correlation of N concentration in grain and biomass with grain and biomass yields

The figure below reveals a strong correlation (r² = 0.97) between nitrogen concentration in soybean grain and subsequent grain yields, and a similarly noteworthy correlation (r² = 0.78) between nitrogen concentration in biomass and biomass yields. This highlights the substantial impact of inoculation and phosphorus (P) fertilizer on soybean yields, as these factors exhibit a positive relationship with nitrogen concentration in both grain and biomass, leading to an increase in overall yields (figure 6 and 7).

# Subset the relevant columns
subset_data <- ipungatrial2[, c("grainyield", "biomassyield", "Grain_N", "treatment", "Biomas_N")]

# Convert 'Treatment' to a factor with appropriate levels
subset_data$treatment <- factor(subset_data$treatment, levels = c("control", "tsp", "inoculation", "tsp_inoc"))

# Calculate the correlation matrix
cor_matrix <- cor(subset_data[, c("grainyield", "biomassyield", "Grain_N", "Biomas_N")])
print(cor_matrix)
##              grainyield biomassyield   Grain_N  Biomas_N
## grainyield    1.0000000    0.4541737 0.9876737 0.6047616
## biomassyield  0.4541737    1.0000000 0.4465578 0.8726414
## Grain_N       0.9876737    0.4465578 1.0000000 0.5758160
## Biomas_N      0.6047616    0.8726414 0.5758160 1.0000000
# Create a correlation matrix heatmap
corrplot(cor_matrix, method = "color", type = "upper", addrect = 3)

3.0 Conclusion

4.0 References

sessionInfo()
## R version 4.3.2 (2023-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
## 
## Matrix products: default
## 
## 
## locale:
## [1] LC_COLLATE=English_United Kingdom.utf8 
## [2] LC_CTYPE=English_United Kingdom.utf8   
## [3] LC_MONETARY=English_United Kingdom.utf8
## [4] LC_NUMERIC=C                           
## [5] LC_TIME=English_United Kingdom.utf8    
## 
## time zone: Africa/Nairobi
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] klippy_0.0.0.9500 corrplot_0.92     patchwork_1.1.3   ggpubr_0.6.0     
##  [5] reshape2_1.4.4    lubridate_1.9.3   forcats_1.0.0     stringr_1.5.0    
##  [9] dplyr_1.1.3       purrr_1.0.2       readr_2.1.4       tidyr_1.3.0      
## [13] tibble_3.2.1      ggplot2_3.4.4     tidyverse_2.0.0  
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.4      xfun_0.41         bslib_0.5.1       rstatix_0.7.2    
##  [5] lattice_0.22-5    tzdb_0.4.0        vctrs_0.6.4       tools_4.3.2      
##  [9] generics_0.1.3    parallel_4.3.2    fansi_1.0.5       highr_0.10       
## [13] pkgconfig_2.0.3   Matrix_1.6-1.1    assertthat_0.2.1  lifecycle_1.0.4  
## [17] compiler_4.3.2    farver_2.1.1      munsell_0.5.0     carData_3.0-5    
## [21] htmltools_0.5.7   sass_0.4.7        yaml_2.3.7        pillar_1.9.0     
## [25] car_3.1-2         crayon_1.5.2      jquerylib_0.1.4   cachem_1.0.8     
## [29] abind_1.4-5       nlme_3.1-163      tidyselect_1.2.0  digest_0.6.33    
## [33] stringi_1.7.12    splines_4.3.2     labeling_0.4.3    cowplot_1.1.1    
## [37] fastmap_1.1.1     grid_4.3.2        colorspace_2.1-0  cli_3.6.1        
## [41] magrittr_2.0.3    utf8_1.2.4        broom_1.0.5       withr_2.5.2      
## [45] scales_1.2.1      backports_1.4.1   bit64_4.0.5       timechange_0.2.0 
## [49] rmarkdown_2.25    bit_4.0.5         ggsignif_0.6.4    hms_1.1.3        
## [53] evaluate_0.23     knitr_1.45        mgcv_1.9-0        rlang_1.1.2      
## [57] Rcpp_1.0.11       glue_1.6.2        rstudioapi_0.15.0 vroom_1.6.4      
## [61] jsonlite_1.8.7    R6_2.5.1          plyr_1.8.9