Package 'granular'

Title: Resolving starch granule distributions
Description: Work out distributions.
Authors: Alex Whan [aut, cre], Emi Tanaka [aut]
Maintainer: Alex Whan <[email protected]>
License: GPL-3 | file LICENSE
Version: 0.4.2
Built: 2026-07-05 08:34:23 UTC
Source: https://github.com/csiro-crop-informatics/granular

Help Index


A function to test how well the fit matches the data

Description

A function to test how well the fit matches the data

Usage

check_fit(fit_output, dist, ps)

Arguments

fit_output

A data frame output from mix_dist()

dist

A numeric vector defining the distribution

ps

A numeric vector describing the granule sizes

Value

a ggplot object


An distribution data set

Description

A dataset containing the distributions from three samples

Usage

Dist

Format

A data frame with 100 rows and 4 variables:

size

Size of granule, in um

118 - Average

Distribution of sample

206 - Average

Distribution of sample

85 - Average

Distribution of sample


Get the heights at peaks

Description

Get the heights at peaks

Usage

get_heights(dist, ps, means)

Arguments

dist

A numeric vector defining the distribution

ps

A numeric vector describing the granule sizes

means

A named numeric vector defining the means (center) for each peak

Value

A named vector with heights for each mean


A function for plotting a fit output against the true distribution

Description

A function for plotting a fit output against the true distribution

Usage

ggfit(fit_output, dist, ps, title = NULL)

Arguments

fit_output

A data frame output from mix_dist()

dist

A numeric vector defining the distribution

ps

A numeric vector describing the granule sizes

title

Logical. Should a title be added to the plot?

Value

a ggplot object


Generate fit plots for a grouped tbl

Description

Generate fit plots for a grouped tbl

Usage

ggfit_grp_tbl(.data, fit_output, proportion, size)

Arguments

.data

A tbl output from mix_grp_tbl, with list columns

fit_output

Variable name holding mix_dist_output

proportion

Variable name holding distribution as a list

size

Variable name holding particle size as a list

Value

The original tbl with a list column of ggplot output


Make a mixture distribution

Description

Make a mixture distribution

Usage

make_dist(fit_output, ps)

Arguments

fit_output

A data frame output from mix_dist()

ps

A numeric vector describing the granule sizes

Value

A numeric vector describing the mixture distribution


use mix() to estimate underlying distributions

Description

use mix() to estimate underlying distributions

Usage

mix_dist(dist, ps, mu_vec, pi_vec = NULL, sigma_vec = NULL,
  peak_names = NULL, sample_name = NULL, emnum = 10, log_trans = TRUE)

Arguments

dist

A numeric vector defining the distribution

ps

A numeric vector describing the granule sizes

mu_vec

A vector defining distribution means (required)

pi_vec

A vector defining distribution proportions (optional)

sigma_vec

A vector defining distribution dispersion (optional)

peak_names

A vector defining peak names (optional)

sample_name

A character string defining the sample name (optional)

emnum

passed to mix() - A non-negative integer specifying the number of EM steps to be performed

log_trans

Logical. Should values be log-transformed?

Value

A list with the fit parameters for each distribution, and complete output from mixdist::mix()


Title

Description

Title

Usage

mix_grp_tbl(.data, proportion, size, mu_vec, pi_vec = NULL,
  sigma_vec = NULL, peak_names = NULL, emnum = 10, log_trans = TRUE,
  parallel = FALSE)

Arguments

.data

A tbl grouped by each distribution

proportion

An unquoted variable name

size

An unquoted variable name

mu_vec

A vector defining distribution means (required)

pi_vec

A vector defining distribution proportions (optional)

sigma_vec

A vector defining distribution dispersion (optional)

peak_names

A vector defining peak names (optional)

emnum

passed to mix() - A non-negative integer specifying the number of EM steps to be performed

log_trans

Logical. Should values be log-transformed?

parallel

Logical. Should multidplyr be used to run in parallel? (EXPERIMENTAL)

Value

A mutated tbl with list column output


An example mix_dist output

Description

A dataset containing the output from 118 - Average

Usage

ms1

Format

A data frame with 3 rows and 8 variables:

sample

Name of the sample

peak

Peak name

pi

Distribution proportion

mu

Distribution mean

sigma

Distribution sd

pi.se

proportion standard error

mu.se

mean standard error

sigma.se

sd standard error


An example mix_dist output

Description

A dataset containing the output from 85 - Average

Usage

ms2

Format

A data frame with 3 rows and 8 variables:

sample

Name of the sample

peak

Peak name

pi

Distribution proportion

mu

Distribution mean

sigma

Distribution sd

pi.se

proportion standard error

mu.se

mean standard error

sigma.se

sd standard error


An example mix_dist output

Description

A dataset containing the output from 206 - Average

Usage

ms3

Format

A data frame with 3 rows and 8 variables:

sample

Name of the sample

peak

Peak name

pi

Distribution proportion

mu

Distribution mean

sigma

Distribution sd

pi.se

proportion standard error

mu.se

mean standard error

sigma.se

sd standard error


Run the granular shiny app locally

Description

Run the granular shiny app locally

Usage

run_granular(port = NULL, launch.browser = TRUE,
  host = getOption("shiny.host", "127.0.0.1"))

Arguments

port

The TCP port that the application should listen on. Defaults to choosing a random port.

launch.browser

If true, the system's default web browser will be launched automatically after the app is started. defaults to true in interactive sessions only.

host

The IPv4 address that the application should listen on. Defaults to the shiny.host option, if set, or "127.0.0.1" if not.