% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sex_ratio_on_grid.r
\name{sex_ratio_on_grid}
\alias{sex_ratio_on_grid}
\title{Plot sex ratio spatial distribution}
\usage{
sex_ratio_on_grid(
  mTATBsp,
  depth,
  wd = NA,
  map_range,
  threshold = 30,
  verbose = FALSE,
  save = TRUE
)
}
\arguments{
\item{mTATBsp}{A spatial version of the merged TA-TB dataset, processed through `overlayGrid()`, containing sex information.}

\item{depth}{Character string specifying the depth range used for filtering (e.g., `"10,800"`). Must correspond to available internal GFCM grid masks.}

\item{wd}{Working directory. Used to save output files if `save = TRUE`.}

\item{map_range}{numeric vector with coordinates defining the map extent (`xmin`, `xmax`, `ymin`, `ymax`).}

\item{threshold}{Minimum number of individuals required per haul to be included in the sex ratio estimation. Default is 30.}

\item{verbose}{Logical. If `TRUE`, informative messages are printed to the console.}

\item{save}{Logical. If `TRUE`, the plot and sex ratio table are saved to the working directory.}
}
\value{
A `data.frame` containing sex ratio (`ratio`), standard deviation (`sd`), and coefficient of variation (`CV`) for each GFCM grid cell.
}
\description{
This function calculates and plots the spatial distribution of sex ratio (F / (F + M)) over the GFCM grid for a given species. It uses data from merged MEDITS datasets (TA, TB, TC), previously spatialized with `overlayGrid()`. The function filters hauls by total abundance threshold and depth range, calculates sex ratio per grid cell, and plots the output using color-coded categories based on quantiles. The result is a choropleth map of sex ratio patterns, useful to highlight spatial differences in sex structure. Raw sex ratio estimates per grid cell can also be exported.
}
\examples{
data(TA)
data(TB)
data(TC)
m <- merge_TATBTC(TA[TA$AREA == 10, ], TB[TB$AREA == 10, ], TC[TC$AREA == 10, ],
                  species = "MERLMER", country = "all", verbose = FALSE)
mTATBsp <- overlayGrid(m[[1]], m[[2]], GSA = 10, save = FALSE, verbose = FALSE)[[1]]
map_range <- c(9, 15, 39, 42)
sex_ratio_on_grid(mTATBsp, depth = "10,800", map_range = map_range, threshold = 5,
                  save = FALSE, verbose = FALSE)
}
