Threshold Indicator Taxa Analysis (TITAN)
By- Rounak Choudhary
By- Rounak Choudhary
TITAN stands for Threshold Indicator Taxa Analysis. It's an advanced statistical method used in ecology to detect thresholds or tipping points in community-level responses (usually of species or taxa) to environmental gradients or stressors (like pollution, land use, temperature, etc.).
Pre Requirements:- You will need two separate CSVs as follows:
CSV 1= titanmetrix.csv
it contains the occurrence of species at different sites
CSV 2= titanenv.csv
it contains the environmental gradients at different sites
# Install and load the TITAN2 package for Threshold Indicator Taxa Analysis
install.packages("TITAN2")
library(TITAN2)
# Load species and environmental data from CSV files
# species_data: matrix of species (columns) by sites (rows), values = abundance or presence/absence
# env_data: data frame with environmental gradient(s), here assumed to be tree or bare cover
species_data <- read.csv("C:/Users/Rounak Choudhary/Desktop/titanmetrix.csv", row.names = 1)
env_data <- read.csv("C:/Users/Rounak Choudhary/Desktop/titanenv.csv", row.names = 1)
# Extract the environmental gradient (e.g., % of bare cover)
tree_cover <- env_data$BareP
# Count total number of sampling sites
n_sites <- nrow(species_data)
# Count how many sites each species appears in (non-zero entries)
species_occurrence <- colSums(species_data > 0)
# Filter: Keep only species found in at least 3 sites and not in all sites
# This avoids overfitting and ensures variability
filtered_species <- species_data[, species_occurrence >= 3 & species_occurrence < n_sites]
# Print how many species were retained after filtering
cat("Species retained:", ncol(filtered_species), "\n")
# Run TITAN analysis using the filtered species and environmental gradient
# minSplt = 5: Minimum number of sites needed in each group during splitting
# boot = 500: Number of bootstrap replicates for estimating uncertainty
# imax = 100: Max number of iterations for internal procedures (optional)
# pur.cut and rel.cut = 0.95: High stringency for considering a taxon a reliable indicator
titan_result <- titan(
env = tree_cover,
txa = filtered_species,
minSplt = 5,
boot = 500,
imax = 100,
pur.cut = 0.95,
rel.cut = 0.95
)
# Print a summary of significant taxa ordered by their indicator strength
summary(titan_result, sort = TRUE)
# Access the core table with maximum z-scores and thresholds for each taxon
titan_result$sppmax
# Save this result table to a CSV file for external review
write.csv(titan_result$sppmax, "C:/Users/Rounak Choudhary/Desktop/bare_cover_thresholds.csv")
# Convert sppmax result to a data frame for further analysis
summary_df <- as.data.frame(titan_result$sppmax)
# Check column names to understand what's available (e.g., filter, maxgrp, z-scores, purity)
colnames(summary_df)
# Filter to keep only species:
# - with filter > 0 (meaning they passed the purity/reliability criteria)
# - that are negatively responding to the gradient (maxgrp == 2)
good_species <- summary_df[summary_df$filter > 0 & summary_df$maxgrp == 2, ]
# Print the species that are good negative indicators (decline with more bare cover)
print(good_species)