Welcome to MixSIAR_Global analysis
This analysis is based on R language, mainly based on the Bayesian principle, using different particulate isotope data to analyze the source of the component. Its operation requires three files: sample isotope data (sample_data), emission source isotope end member values (sources), and isotope fractionation information (fractionation). Specific examples can be found in the data table provided together. Its detailed R language code is as follows. After installing the R language, users can directly import the code and sample data for analysis.

###################################################################################################
library(MixSIAR)

mix <- load_mix_data(filename="./sample_data.csv",
                     iso_names=c("d-isotope"),
                     factors="Group",     #                    factors=NULL, 
                     # factors=NULL,
                     fac_random= FALSE,   #                     
                  #   fac_random=NULL, 
                 #    fac_nested= FALSE,		#                     
                  fac_nested=NULL,	
                     cont_effects=NULL)   	

# Load source data
source <- load_source_data(filename="./sources.csv",
                           source_factors=NULL,
                           conc_dep=FALSE,
                           #data_type="raw",
                           data_type="means",						   
                           mix)
#print(source)

#print(length(source))
# Load discrimination/TDF data

discr <- load_discr_data(filename="./fractionation.csv", mix)
#For NH4+, fractionation is quantified as the product of εNH4+/NH3 and (1-f), where εNH4+/NH3 represents the experimental nitrogen equilibrium isotope fractionation factor, calculated as 12.4678×1000/T - 7.6694, with T as the ambient temperature in Kelvin. f denotes the molar NH3 conversion ratio. Based on Song et al.'s findings that f varies regionally and over time, we selected appropriate f values for each sample location. For NO3-, isotope fractionation is quantified by the combined effects of the O3 and OH formation pathways, with fractionation details for each path and the ratio r previously outlined in our prior research. This study further refines r based on the latitude of each sample location, given its observed linear relationship with latitude, to account accurately for fractionation during NO3- formation. In SO42- formation, previous findings indicate a strong linear relationship between isotope fractionation and temperature, which we use here to determine the isotopic fractionation characteristics in SO42- production
#print(discr)
#print(mix)
# Make isospace plot
#plot_data(filename="isospace_plot", plot_save_pdf=TRUE, plot_save_png=FALSE, mix,source,discr)
#plot(fr_ave,mix$data_iso)
# Plot your prior
#plot_prior(alpha.prior=1,source)

# Define model structure and write JAGS model file
model_filename <- "MixSIAR_model.txt"
resid_err <- TRUE
process_err <- FALSE #TRUE

write_JAGS_model(model_filename, resid_err, process_err, mix, source)
print("Run the JAGS model")
# Run the JAGS model ("test" first, then "normal")
jags.1 <- run_model(run="test", mix, source, discr, model_filename, alpha.prior=1, resid_err, process_err)
#jags.1 <- run_model(run="normal", mix, source, discr, model_filename, alpha.prior=1, resid_err, process_err)

# create sub-directory and move into it
#mainDir <- getwd()
#subDir <- paste0("model_", runtype)
#dir.create(file.path(mainDir, subDir), showWarnings = FALSE)
#setwd(file.path(mainDir, subDir))

#print("output_JAGS")
options(max.print=1000000)
# Process diagnostics, summary stats, and posterior plots
#output_JAGS(jags.mod[[mod]], mix[[mod]], source[[mod]], output_options=list(

output_JAGS(jags.1, mix, source, output_options=list(
  summary_save = TRUE,                  # Save the summary statistics as a txt file?
  summary_name = "summary_statistics",  # If yes, specify the base file name (.txt will be appended later)
  sup_post = TRUE,                      # Suppress posterior density plot output in R?
  plot_post_save_pdf = TRUE,            # Save posterior density plots as pdfs?
  plot_post_name = "posterior_density", # If yes, specify the base file name(s) (.pdf/.png will be appended later)
  sup_pairs = FALSE,                    # Suppress pairs plot output in R?
  plot_pairs_save_pdf =  TRUE,          # Save pairs plot as pdf?
  plot_pairs_name = "pairs_plot",       # If yes, specify the base file name (.pdf/.png will be appended later)
  sup_xy = TRUE,                        # Suppress xy/trace plot output in R?
  plot_xy_save_pdf = FALSE,             # Save xy/trace plot as pdf?
  plot_xy_name = "xy_plot",             # If yes, specify the base file name (.pdf/.png will be appended later)
  gelman = TRUE,                        # Calculate Gelman-Rubin diagnostic test?
  heidel = FALSE,                       # Calculate Heidelberg-Welch diagnostic test?
  geweke = TRUE,                        # Calculate Geweke diagnostic test?
  diag_save = TRUE,                     # Save the diagnostics as a txt file?
  diag_name = "diagnostics",            # If yes, specify the base file name (.txt will be appended later)
  indiv_effect = FALSE,                 # Is Individual a random effect in the model? (already specified)
  plot_post_save_png = FALSE,           # Save posterior density plots as pngs?
  plot_pairs_save_png = FALSE,          # Save pairs plot as png?
  plot_xy_save_png = FALSE))

graphics.off()
setwd(mainDir)



###########################################################################################