Summarize MiteMap data at the individual (File) level
summarize_mitemap.RdSummarize MiteMap data at the individual (File) level
Arguments
- MiteMap
(required) The result of
import_mitemap()- selected_cols
(default = NULL) A character vector of column names to include in the summary in addition to
File_name. If NULL, all columns are used.
Value
A summary table (tibble) with one line per File_name and summary statistics.
New columns are created with the suffixes corresponding to the applied summary function:
For numeric columns summary statistics include mean, standard deviation, minimum, and maximum values.
For character and factor columns, the first unique value is retained. As file_name (individual mite) have unique metadata, all factor columns have one value by file_name.
For logical columns, the proportion (mean) and number of TRUE values is calculated. The number of FALSE is also calculated.
A column
total_pointsindicates the number of data points (rows) for each File_name.
Details
The returns for the applied summary functions used. If you want custom function such as quantile, median, you can use dplyr functions directly inspired by this function (see examples).
Examples
mm_csv <- MM_data
sum_mm <- summarize_mitemap(mm_csv)
#> Warning: There were 18 warnings in `summarise()`.
#> The first warning was:
#> ℹ In argument: `across(...)`.
#> ℹ In group 133: `File_name = "MM012022_05_17_20h27m19s"`.
#> Caused by warning in `min()`:
#> ! no non-missing arguments to min; returning Inf
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 17 remaining warnings.
dim(sum_mm)
#> [1] 251 106
sum_mm_selected <- summarize_mitemap(mm_csv,
selected_cols = c(
"speed_mm_s",
"distance_from_sources",
"in_left_half_HH",
"in_left_half_CH",
"turning_angle",
"turning_angle_odor",
"turning_angle_ratio_odor",
"Treatment"
)
)
#> Warning: There were 12 warnings in `summarise()`.
#> The first warning was:
#> ℹ In argument: `across(...)`.
#> ℹ In group 133: `File_name = "MM012022_05_17_20h27m19s"`.
#> Caused by warning in `min()`:
#> ! no non-missing arguments to min; returning Inf
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 11 remaining warnings.
ggplot(sum_mm_selected, aes(x = Treatment, y = distance_from_sources_mean, fill = Treatment)) +
ggrain::geom_rain() +
coord_flip()
#> Registered S3 methods overwritten by 'ggpp':
#> method from
#> heightDetails.titleGrob ggplot2
#> widthDetails.titleGrob ggplot2
# Use custom summary with dplyr functions without the use of summarize_mitemap
mm_csv |>
select("File_name", "Treatment", "Biomol_sp", "speed_mm_s") |>
group_by(File_name) |>
summarise(
mean_speed = mean(speed_mm_s, na.rm = TRUE),
across(where(is.character), ~ unique(.x)[1], .names = "{col}")
) |>
ggplot(aes(x = Treatment, y = mean_speed, fill = Treatment)) +
geom_col() +
facet_wrap(~Biomol_sp)