class: center, middle, inverse, title-slide .title[ # Plant System Modelling Workshop (PSMW)
6-10th July 2025, IIT Palakkad ] .author[ ### Deepak Jaiswal (
dj@iitpkd.ac.in
) ] --- # 🌿 What is Programming? - Programming = writing **instructions** for a computer - Like writing a lab **protocol** - Instead of a human assistant, your **computer follows the instructions** --- # 🧬 Analogy: DNA and Programming - DNA = **biological program** for cells - Programming = creating **digital instructions** - Both involve: - Sequence of instructions - Logical flow - Reproducibility --- # 📊 Data in Biology - You're already working with **data**: - Phenotyping results - Gene expression - Environmental sensors - Programming helps: - Clean, analyze, and visualize data - Automate repetitive tasks - Avoid human error --- # 🌾 Algorithms = Pathways - Calvin cycle → sequence of biochemical steps - Algorithm → sequence of computational steps - Programming helps design and test models, like: - Growth simulation - Climate interaction - Trait prediction --- # 🧪 Reproducible Science - Programming supports: - Transparent workflows - Reusable analysis scripts - Version control (Git) --- # 🌱 Why Learn Programming? - Manage large datasets easily - Increase research productivity - Enable collaborations across disciplines - Use AI & machine learning tools in biology --- # 👩🔬 Tools for Biologists - R (great for statistics, plotting) - Python (versatile, AI/ML support) - RStudio / Jupyter Notebooks - Packages like: - `tidyverse`, `ggplot2`, `dplyr` (for R) - `pandas`, `matplotlib` (for Python) --- # 🌱 Why Learn R? - R is a powerful tool for: - Data analysis - Visualization - Statistics - Widely used in: - Ecology - Genetics - Plant breeding - Phenology studies --- # 🌾 Real-World Examples - **Model leaf-level photosynthesis** using the Farquhar model → e.g., simulate net CO₂ assimilation as a function of light or temperature - **Analyze crop biomass accumulation** over time → e.g., fit logistic or exponential growth models to total biomass data (e.g., rice or wheat) - **Estimate water use efficiency (WUE)** → e.g., WUE = total biomass / total water used - **Visualize diurnal photosynthesis data** → plot hourly rates of CO₂ uptake or stomatal conductance - **Predict flowering or harvest dates** → build regression models using temperature and photoperiod data ### All of these can be done using R (& Rmarkdown makes it easier) --- # 🖥️ Understanding the RStudio Interface .pull-left[  ] .pull-right[ - **Top-Left**: Script Editor (write R code) - **Bottom-Left**: Console (interactive commands) - **Top-Right**: Environment/History - **Bottom-Right**: Files, Plots, Packages, Help > Customize layout: > `Tools` → `Global Options` → `Pane Layout` ] --- # 📁 What is a Working Directory? R needs to know **where your files are located** and **where to save your output**. This location is called your **working directory**. ### `getwd()` — Get Working Directory Use this function to check **where R is currently looking** for files: ### `setwd()` — Change Working Directory Use this function to change **where R is currently looking** for files: ## You can avoid this issue by working with R Project --- # 📁 Starting a New R Project Creating a new R Project helps keep your files, data, and scripts organized in one folder. ### 🪜 Steps to Create an R Project: 1. Open RStudio. 2. Go to **File → New Project...** 3. Choose **New Directory** or **Existing Directory**. 4. Select a folder name and location. 5. Click **Create Project**. 🎯 This creates a dedicated working environment with a `.Rproj` file. Using projects ensures your working directory is always consistent, making your code **easier to manage and reproduce**. --- # 🗂️ Organizing Your R Project Folder To keep your work clean and manageable, create the following subfolders inside your project: ``` project-folder/ │ ├── code/ # R scripts and RMarkdown files ├── inputs/ # Raw input data files (CSV, Excel, etc.) ├── outputs/ │ ├── graphs/ # Plots and visualizations │ └── texts/ # Output reports, summaries, or tables └── project.Rproj # R Project file ``` 🔹 This structure makes it easy to **find**, **reuse**, and **share** your work. --- # 🚀 Start Simple: Calculation of total biomass of a rice plant ``` r # Assign values to plant parts (in kg/ha) leaf_biomass <- 45 stem_biomass <- 80 grain_biomass <- 120 root_biomass <- 30 # Total biomass is the sum of all parts total_biomass <- leaf_biomass + stem_biomass + grain_biomass + root_biomass # Print the result print(paste("Total biomass (g):", total_biomass)) ``` ``` ## [1] "Total biomass (g): 275" ``` --- # 🆕 Creating an R Script for Biomass Calculation ### ✅ Steps in RStudio: 1. Open R Project 2. Go to **File** → **New File** → **R Script** 3. Type the following R code: ```r # Rice Plant Biomass Calculation leaf_biomass <- 45 stem_biomass <- 80 grain_biomass <- 120 root_biomass <- 30 # Total biomass is the sum of all parts total_biomass <- leaf_biomass + stem_biomass + grain_biomass + root_biomass ``` --- # 💾 Saving and Running Your R Script ### 📝 Saving Your Script - Go to **File** → **Save As** - Choose a name like: `yourname_1.R` (**Save inside code subfolder**) - Select a folder to save (e.g., `Documents`, `RiceBiomass`) ### ▶️ Running Your Code - Place your cursor on a line and click **Run**, or press `Ctrl + Enter` (Windows) / `Cmd + Enter` (Mac) - Output will appear in the **Console** (bottom pane of RStudio) --- ✅ Tip: You can also highlight multiple lines and run them together. 🧪 This code helps you compute the **total biomass** of a rice plant. --- # 🔢 R as a Calculator You can also directly type: ```r 2 + 3 45 + 80 + 120 + 30 ``` Try it in the **Console**. --- # 🔍 Summary of tools | Tool | Description | File Type | |----------------|------------------------------------------|---------------| | **R** | Language for computation & analysis | Application | | **RStudio** | Interface to write/run R code | Application | | **R Script** | Code-only file | `.R` | --- # 🧮 Operators and Variables in R ### 🔤 What is a Variable? - A **variable** stores a value (like a number or text) in R. - Think of it like a labeled jar that holds something. ```r leaf <- 45 ``` This means: “Put the number 45 in a jar labeled `leaf`.” ```r plant_organ <- "leaf" ``` This means: “Put the text leaf in a jar labeled `plant_organ`.” --- # 🧮 Operators and Variables in R ### ✅ Valid Variable Name Rules - Must start with: - A **letter (A–Z or a–z)** or - A **period (.)**, but **not followed by a number** - Can contain: - **Letters** - **Digits (0–9)** - **Underscore `_`** - **Periods `.`** - ❌ **Cannot start with a number** - ❌ **Cannot contain special characters** - `@`, `#`, `$`, `-`, `!`, etc. - ❌ **Cannot be a reserved word** - Examples: `if`, `TRUE`, `function`, `else`, `for` --- # 🧮 Operators and Variables in R - A variable is like a **container** that holds data. - In R, different types of data are stored in **different types of variables**. - Example: In a rice plant study, we might measure: - Total biomass - Leaf color - Number of tillers - Alive or dead status --- # 🧮 Operators and Variables in R ### 📂 Major Variable Types in R | Type | Example | Biological Analogy | |--------------|----------------------------------|--------------------------------| | Numeric | `24.5`, `130.2` | Biomass (g), Leaf area (cm²) | | Integer | `1`, `100`, `200` | No. of leaves or tillers | | Character | `"green"`, `"flowering"` | Leaf color, Growth stage | | Logical | `TRUE`, `FALSE` | Is alive? Has AM fungi? | | Factor | `"TreatmentA"`, `"Control"` | Fertilizer type or season | --- # 🧮 Operators and Variables in R ### ➕ Common Operators | Symbol | Meaning | Example | |--------|----------------|-------------------| | `+` | Addition | `leaf + stem` | | `-` | Subtraction | `stem - root` | | `*` | Multiplication | `grain * 2` | | `/` | Division | `stem / 2` | | `<-` | Assignment | `x <- 10` | --- # 🍚 Biomass Example (Variables and Operators) ```r # Assign values to plant parts (in kg/ha) leaf_biomass <- 45 stem_biomass <- 80 grain_biomass <- 120 root_biomass <- 30 # Total biomass is the sum of all parts total_biomass <- leaf_biomass + stem_biomass + grain_biomass + root_biomass # Print the result print(paste("Total biomass (g):", total_biomass)) ``` ✅ You’ve just used **variables** and **operators** to calculate total plant biomass! --- # ✏️ Try it Yourself ### 🔁 Example 1: Change a value - Change the value of `grains` to 150. - Run the code again. - What is the new total biomass? ``` ## [1] 305 ``` ### 📊 Example 2: Aboveground vs Belowground Ratio - Aboveground = leaf + stem + grains - Belowground = roots - Calculate the ratio: ``` ## [1] 9.166667 ``` ### 📈 Example 3: Percent Contribution of Each Part - Use the total biomass to calculate percentage: ``` ## 14.7541 26.22951 49.18033 9.836066 ``` 🧪 This helps you experiment and learn how variables and operators work! --- # Break --- # Vectors in R ## Earlier Example ``` r # Assign values to plant parts (in kg/ha) leaf_biomass <- 45 stem_biomass <- 80 grain_biomass <- 120 root_biomass <- 30 # Total biomass is the sum of all parts total_biomass <- leaf_biomass + stem_biomass + grain_biomass + root_biomass ``` --- # Vectors in R In real-world plant data, biomass changes over time. Suppose you're measuring the biomass of **different plant organs** (leaf, stem, root, grain) at **10 different time points**. --- # Vectors in R ## ❓ The Problem Should we write variables like: - `leaf_biomass_time1`, `leaf_biomass_time2`, ... - `stem_biomass_time1`, `stem_biomass_time2`, ... This approach quickly becomes **tedious, hard to manage, and error-prone**. --- # Vectors in R ### ✅ The Solution: Use Vectors R provides a simple and powerful structure called a **vector** to handle such data. - A **vector** is a **one-dimensional array**. - All elements in a vector are of the **same data type**. - You can perform operations on all elements at once. --- # Vectors in R ### 🌾 Example: Rice Plant Biomass Over Time Let's define vectors to store biomass values (in g/plant) measured at 10 time points: ``` r # Biomass vectors leaf_biomass <- c(0.5, 1.2, 2.5, 4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0) stem_biomass <- c(0.2, 0.8, 1.5, 3.0, 5.0, 6.5, 7.8, 8.5, 9.0, 9.2) root_biomass <- c(0.3, 1.0, 2.0, 3.0, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5) grain_biomass <- c(0, 0, 0, 0, 0, 1.0, 3.0, 6.0, 10.0, 15.0) ``` --- # Vectors in R Each vector stores the biomass (g/plant) of a specific plant part at 10 time points. | Vector Name | Meaning | Length | Data Type | | --------------- | ----------------------------- | ------ | --------- | | `leaf_biomass` | Leaf biomass over time | 10 | Numeric | | `stem_biomass` | Stem biomass over time | 10 | Numeric | | `root_biomass` | Root biomass over time | 10 | Numeric | | `grain_biomass` | Grain biomass over time | 10 | Numeric | --- # Vectors in R ## 🧪 Exercise: Vector Operations and Summary Statistics ### Exercise: Calculate Total Biomass Over Time Each participant should compute the **total biomass** at each time point by adding: ``` r leaf_biomass <- c(0.5, 1.2, 2.5, 4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0) stem_biomass <- c(0.2, 0.8, 1.5, 3.0, 5.0, 6.5, 7.8, 8.5, 9.0, 9.2) root_biomass <- c(0.3, 1.0, 2.0, 3.0, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5) grain_biomass <- c(0, 0, 0, 0, 0, 1.0, 3.0, 6.0, 10.0, 15.0) ``` ``` ## [1] 1.0 3.0 6.0 10.0 13.5 16.0 19.3 23.0 27.5 32.7 ``` --- # 🛠 What is a Function (for Now)? A **function** in R is like a **tool** that performs a specific task. You give it **input values** (called *arguments*), and it gives you an **output** (a result or action). --- # 🧪 You've Already Used Functions! Base function (included when you install R) ``` r # Combine Values into a Vector or List leaf_biomass <- c(0.5, 1.2, 2.5, 4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0) # Print Values print(leaf_biomass) ``` ``` ## [1] 0.5 1.2 2.5 4.0 5.0 5.0 5.0 5.0 5.0 5.0 ``` ``` r leaf_biomass ``` ``` ## [1] 0.5 1.2 2.5 4.0 5.0 5.0 5.0 5.0 5.0 5.0 ``` In R, when you just type the name of an object or variable, R automatically uses the print() function behind the scenes to display its contents. --- # 🧪 Exploring some more base function (included in R) Let’s look at some **useful functions** that come with **base R** (i.e., available without installing any package): ``` r # summary(): gives summary statistics summary(leaf_biomass) ``` ``` ## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 0.500 2.875 5.000 3.820 5.000 5.000 ``` ``` r # str(): shows the internal structure str(leaf_biomass) ``` ``` ## num [1:10] 0.5 1.2 2.5 4 5 5 5 5 5 5 ``` --- # How to Learn About Any Function If you know the name of a function and want to learn how to use it, just type ? function name in console. This will open help page for that function. Try following: ``` r ?summary ?c ?print ``` --- # Some more commonly used base R functions There are some basic functions that you can use (similar to **c()** and **print()**) | Function | Description | Example (`leaf_biomass`) | | ---------- | -------------------------------- | ------------------------ | | `length()` | Number of elements in the vector | `length(leaf_biomass)` | | `sum()` | Total sum of all values | `sum(leaf_biomass)` | | `mean()` | Average value | `mean(leaf_biomass)` | | `min()` | Minimum value | `min(leaf_biomass)` | | `max()` | Maximum value | `max(leaf_biomass)` | | `range()` | Returns min and max | `range(leaf_biomass)` | | `sd()` | Standard deviation | `sd(leaf_biomass)` | --- # Some more commonly used base R function ### Example : Calculate Mean and Standard Deviation of Leaf Biomass Find the mean biomass of the leaf across all time points. Find the standard deviation to understand variation during the growing stages. ``` r mean_leaf <- mean(leaf_biomass) sd_leaf <- sd(leaf_biomass) ``` ``` r print(mean_leaf) print(sd_leaf) ``` --- # Did You Know? There are hundreds of functions in base R for handling data, performing calculations, and working with objects. In addition to base R, the R community has created packages that provide specialized functions. One such package is **BioCro** — designed for dynamic simulation of plant growth. But before we jump into using packages like **BioCro**, we’ll continue learning some more basic concepts in R to ensure a solid foundation. --- # Break --- # Vector to Data Frames We used **vectors** to represent biomass of different plant organs measured at different times. Biomass changes over time and growth stage. We can store this information in vectors too. To better understand the growth stages, here’s an illustration of **rice phenology**.  --- # Vector to Data Frames We can create two new vectors, one for date of measurement and another for phenological stage ``` r # Dates of measurement measurement_date <- c("10 Jul", "30 Jul", "10 Aug", "30 Aug", "10 Sep", "30 Sep", "10 Oct", "30 Oct", "10 Nov", "30 Nov") # Phenological stages of crop phenological_stage <- c("vegetative", "vegetative", "vegetative", "reproductive", "reproductive", "reproductive", "ripening", "ripening", "ripening", "ripening") ``` - Right now, we have **multiple related vectors**, each with 10 values. - These are all **part of the same dataset**, but stored **separately**. - It would be much easier if we had **a single object** where: - Each **row** = one measurement time - Each **column** = one variable (leaf, stem, date, stage, etc.) ✅ That’s exactly what a **data frame** does in R! --- # Creating a Data Frame in R Let’s combine our biomass and metadata vectors into a single **data frame**: ``` r biomass_data <- data.frame( Date = measurement_date, Stage = phenological_stage, Leaf = leaf_biomass, Stem = stem_biomass, Root = root_biomass, Grain = grain_biomass ) ``` --- # 🔍 Exploring the Data Frame You can now analyze or visualize your data more easily. ``` r # Check structure str(biomass_data) # Get summary of all variables summary(biomass_data) ``` You can also use environment panel (of Rstudio) --- ## 🧠 Key Takeaways - **Vectors** hold individual columns of data (one type only). - A **data frame** is a **table** that holds multiple vectors as columns. - All columns (vectors) must be of the **same length**. - Data frames are perfect for storing **tabular biological data**. --- # Importing and 📤 Exporting Data Frames in R In many R projects, we receive data from others (e.g., lab mates) in `.csv` format, process it in R, and then save the results. ### 📥 Importing Data Read a `.csv` file from the `inputs/` folder: ``` r # Read CSV file biomass_data <- read.csv("inputs/biomass.csv") ``` Make sure the file biomass.csv exists inside the inputs/ folder of your R Project directory. ### Do some calculations 1. Access individual column of the dataframe (try biomass_data$Leaf,biomass_data[["Leaf"]], biomass_data[,"Leaf"]) 2. Add an additional column for total biomass 3. Calculate mean and sd of all the plant organs --- # Importing and 📤 Exporting Data Frames in R ### Exporting Data After all the calculations are done, save your processed data to a new .csv file: # Write to CSV in outputs/texts folder ``` r write.csv(biomass_total, file = "outputs/texts/biomass_total.csv") write.csv(biomass_mean, file = "outputs/texts/biomass_mean.csv" ) ``` If our output is figure, we can put figures in outputs/graphs (instead of outputs/texts). Now we will do that. --- # 📦 Visualization & Plotting We can use base R functions to plot (`plot(biomass_data$Leaf)`) but there are specific libraries developed by people to make beautiful plots and graphs using specific functions. One popular library is ggplot, we will use that to do some basic plotting ``` r library(ggplot2) # biomass_data <- read.csv("inputs/input_biomass_data.csv") ggplot(biomass_data, aes(x = Date, y = Leaf)) + geom_line() + geom_point() ``` ``` ## `geom_line()`: Each group consists of only one observation. ## ℹ Do you need to adjust the group aesthetic? ``` <!-- --> ``` r # The plot looks weird because X axis is organized alphabetically ``` --- # 📦 Visualization & Plotting Let's try to add an additional column Date in right format (Date) ``` r library(ggplot2) biomass_data$measurement_date <- as.Date(c("2024-7-10","2024-7-30","2024-8-10", "2024-8-30","2024-9-10","2024-9-30","2024-10-10", "2024-10-30","2024-11-10","2024-11-30")) ``` We are using two functions c and as.Date --- # 📦 Visualization & Plotting Now we can use this new variables in our dataframe on X axis for plotting ``` r ggplot(biomass_data, aes(x = measurement_date, y = Leaf)) + geom_line() + geom_point() ``` <!-- --> --- # 📦 Visualization & Plotting | Date | Leaf | Stem | Root | Grain | | ------ | ---- | ---- | ---- | ----- | | 10 Jul | 0.5 | 0.2 | 0.3 | 0 | | ... | ... | ... | ... | ... | Can we plot all the variables together using ggplot? Yes, but we need to process the data before plotting. Our Current Data is in **wide format** --- # 📦 Visualization & Plotting | Date | Organ | Biomass | | ------ | ----- | ------- | | 10 Jul | Leaf | 0.5 | | 10 Jul | Stem | 0.2 | | 10 Jul | Root | 0.3 | | 10 Jul | Grain | 0 | | ... | ... | ... | But ggplot() works best when all variables to be plotted together are in a single column (called **long format**) --- # 📦 Visualization & Plotting We can use another package called functions in R package tidyr to change the format of your data ``` r library(tidyr) biomass_long_data <- pivot_longer( biomass_data, cols = Leaf:Grain, # or use names of columns to pivot names_to = "Organ", values_to = "Biomass" ) ``` --- # 📦 Visualization & Plotting Now use the long format with ggplot function ``` r ggplot(biomass_long_data, aes(x = measurement_date, y = Biomass)) + geom_line(aes(colour = Organ)) + geom_point(aes(shape=Stage)) ``` <!-- --> How did we display stage in this plot? --- # Plotting Exercise 1. **Add a new column named `TotalBiomass`** to the original data frame. - This column should represent the **sum of Leaf, Stem, Root, and Panicle biomass** for each observation. 2. **Add a column called `MeasuredBy`** - Fill it with the names of **three of your best friends**. - You can assign the names randomly or in a repeating pattern. 3. **Replot the data** using `ggplot2`, showing the values of: - `Leaf`, `Stem`, `Root`, and `TotalBiomass` 4. Use the `MeasuredBy` column to: - Differentiate who measured what — using **shape** in the plot. --- # break --- # 🧠 What is a List in R? - A **list** is like a **folder**. - It can hold **different types** of objects: numbers, strings, vectors, even other lists. # 🌿 Why Use Lists? - Great for storing **related but different types** of data. - Example: A plant’s name, height, and whether it is flowering. - Storing elements of different length (data.frame needs all columns of same length) - You want to store different types of objects (data frame, image, function,etc.) together. Everything in R (including list) is an object --- # 🔧 Creating a List ``` r plant_info <- list( species = "Oryza sativa", height_cm = 120, is_flowering = TRUE, leaf_lengths = c(10.5, 12.3, 11.7) ) ``` --- # Aceessing it's element ``` r plant_info$species # "Oryza sativa" ``` ``` ## [1] "Oryza sativa" ``` ``` r plant_info[["height_cm"]] # 120 ``` ``` ## [1] 120 ``` ``` r plant_info$leaf_lengths # c(10.5, 12.3, 11.7) ``` ``` ## [1] 10.5 12.3 11.7 ``` --- # Name (or Rename) it's element later ``` r my_list <- list("rice", 140, FALSE) names(my_list) <- c("species", "height", "is_flowering") my_list ``` ``` ## $species ## [1] "rice" ## ## $height ## [1] 140 ## ## $is_flowering ## [1] FALSE ``` --- # List of lists (nested lists) ``` r experiment <- list( plant1 = list(species = "Rice", height = 100), plant2 = list(species = "Wheat", height = 80) ) experiment$plant1$height # 100 ``` ``` ## [1] 100 ``` --- # 🌿 Exercise: Using Lists to Store Photosynthesis Data Create a list called `ps_data` with the following information for a plant: - **Species name**: `"Oryza sativa"` - **Photosynthesis rate** (in µmol CO₂ m⁻² s⁻¹): `18.7` - **Leaf temperature** (in °C): `28.5` - **Time of measurements**: a vector with three time points — `"08:00"`, `"12:00"`, `"16:00"` - **Light intensity** (in µmol m⁻² s⁻¹): a numeric vector — `c(500, 1200, 800)` --- Day 2 --- # What is Crop Modeling? Crop modeling is the **mathematical representation of plant growth processes** over time. - Simulates how crops grow, develop, and yield under different environmental and management conditions. - Helps in forecasting yields, analyzing stress impacts, guiding agricultural management, and formulating policies (climate change adaptation, biofuels expansions) - Two major types: - **Statistical models**: Use historical data to find patterns and correlations (e.g., yield vs. rainfall). - **Dynamic (process-based) models**: Represent underlying biological and physical processes (e.g., CERES, APSIM, BioCro). --- # C.T. de Wit: The Father of Crop Modeling - **C.T. de Wit (1924–1993)**, a Dutch scientist, is widely regarded as the **father of crop modeling**. - He pioneered the use of **systems analysis and mathematical models** to describe crop growth. - His work laid the foundation for modern models like SUCROS, WOFOST, and influenced generations of agroecological research. > *"Modelling is not merely fitting equations to data, but understanding processes behind them."* – C.T. de Wit --- # Major (Process-Based) Crop Models | Model | Origin | Type | Key Features | |------------------|--------------------|------------------------|-------------------------------------------------------------------------------| | CERES | USA (1980s) | Process-based | Simulates daily crop growth and yield; part of DSSAT | | APSIM | Australia | Process-based | Modular, extensible, supports management and systems research | | WOFOST | Netherlands | Process-based | Developed by C.T. de Wit’s group; strong physiological detail | | STICS | France | Process-based | Soil–crop–climate interactions; supports decision-making | | CropSyst | USA | Process-based | Handles rotations, erosion, and long-term management scenarios | | ORYZA | IRRI (Philippines) | Process-based | Specially designed for rice growth and water management | | **BioCro** | USA | Biophysical, R-based | Photosynthesis-focused; canopy and carbon dynamics; integrates with R | --- # BioCro [Visualization](https://drive.google.com/file/d/1wHn6yIw2vIW18LHn0McmPrYyYiY1qYPT/view?usp=drive_link) to show several processes working together to simulate whole plant growth simulation --- # BioCro ## Running a Crop Growth Simulation in BioCro [Latest version]  (A) A schematic of building a car by selecting parts from a catalog and sending them with specifications to a factory for expert assembly. (B) Similarly, a crop simulation is built by selecting equations from a library, adding specifications, and sending them to the BioCro engine, which assembles and runs the model. --- # BioCro ## What Are Modules in BioCro? - 🧩 **Modules are the building blocks** of a BioCro model. - Each module represents a specific **biological or environmental process** (e.g., photosynthesis, stomatal conductance, biomass partitioning). - 🔄 **Two types of modules**: - **Direct modules**: Compute instantaneous values (e.g., light interception, gas exchange). - **Differential modules**: Define time-dependent changes using differential equations (e.g., growth over time). --- # BioCro ## What Are Modules in BioCro? - 🧠 Each module: - Has **input variables** (e.g., temperature, radiation). - Calculates **output variables** (e.g., assimilation rate, leaf mass gain). - 💼 Modules can be: - Swapped or replaced independently. - Combined to create custom crop models without rewriting core code. - 🔍 BioCro includes a **library of standard modules**, and you can also write your own. --- # BioCro ## Advantages of BioCro’s Modular Approach - 🔄 **Separation of concerns**: Model equations, parameters, and numerical solvers are handled independently—making models easier to develop, update, and reuse. - 🧩 **Easily swap components**: Users can replace sub-models (e.g., photosynthesis or partitioning) without rewriting the entire model—useful for testing alternatives like RUE vs. FvCB. - 🧪 **Simplified sensitivity analysis**: With parameters external to the modules, users can easily change values and assess their influence on simulation output. - ⚙️ **Flexible numerical solving**: The solver is not hard-coded. Users can choose appropriate ODE solvers, improving accuracy and stability for complex or stiff systems. - 📦 **Plug-and-play simulation**: Modules can be reused across simulations and shared publicly or privately—encouraging collaborative model development. - 📈 **Cross-platform and scalable**: BioCro II can integrate with other systems or sensor data, allowing for fusion with real-time inputs from smart agriculture. - 🔍 **Compare models easily**: The framework enables quantitative comparison between alternative models or submodels—supporting model calibration and improvement. - 💡 **Focus on science, not code**: The R interface allows users to simulate, visualize, and analyze without delving into C/C++ backend. --- # BioCro ## A Brief History of BioCro - 🌱 BioCro traces its roots to **WIMOVAC** (*Windows Intuitive Model of Vegetation response to Atmospheric and Climate Change*), developed at the **University of Essex** in the 1990s. - 🧪 WIMOVAC originated in the **lab of Prof. Steve Long** as part of the **PhD thesis of Steve Humphries**—a monumental work that took over **10 years** to complete. - 📖 [The thesis](https://drive.google.com/file/d/1KFcPurfN0vOt661ZuIbwvgM8dGUUYtQg/view?usp=sharing), over **300 pages long**, is a **valuable resource** for understanding how individual physiological processes work together to simulate plant growth mathematically. - 💻 Unfortunately, WIMOVAC was written in **Visual Basic** and relied on outdated **Windows-specific dependencies**. Eventually, **only one computer** in the world could still run the program. - 🔁 Around **2010**, the decision was made to **re-develop** WIMOVAC using **C and R**, leading to the **first version of BioCro** (though not publicly released). - 📦 The most recent public version is **BioCro 3.2.0**, released on **CRAN** last year, featuring a **substantially improved software design** and package structure. --- # BioCro ## [Public BioCro Documentation Web Site](https://biocro.github.io/BioCro-documentation/latest/pkgdown/) -- 📄 **Reference Page** Contains a list of all **modules**, **functions**, and **default data** included with the package. Great for quick look-ups. -- 📚 **Article & Documentation** Comes with several documents to help you get started, including **“A Practical Guide to BioCro”**. 👉 **Today, we will work with one of these documents**. -- 🛠️ **Developer’s Manual** Useful **only if you plan to contribute** new modules or modify existing ones. Not necessary for general users or running simulations.